Documentation

Channel extends Part
in package

A Channel can be either a text or voice channel on a Discord guild.

Table of Contents

TYPE_CATEGORY  = 4
TYPE_DM  = 1
TYPE_GAME_STORE  = 6
TYPE_GROUP  = 3
TYPE_NEWS  = 5
TYPE_NEWS_THREAD  = 10
TYPE_PRIVATE_THREAD  = 12
TYPE_PUBLIC_THREAD  = 11
TYPE_STAGE_CHANNEL  = 13
TYPE_TEXT  = 0
TYPE_VOICE  = 2
$application_id  : string
$bitrate  : int
$created  : bool
Is the part already created in the Discord servers?
$default_auto_archive_duration  : int|null
$guild  : Guild
$guild_id  : string|null
$icon  : string
$id  : string
$is_private  : bool
$last_message_id  : string
$last_pin_timestamp  : Carbon
$members  : VoiceMemberRepository
$messages  : MessageRepository
$name  : string
$nsfw  : bool
$overwrites  : OverwriteRepository
$owner_id  : string
$parent_id  : string
$position  : int
$rate_limit_per_user  : int
$recipient  : User
$recipient_id  : string
$recipients  : Collection|array<string|int, User>
$rtc_region  : string|null
$scriptData  : mixed
Custom script data.
$threads  : ThreadRepository
$topic  : string
$type  : int
$user_limit  : int
$video_quality_mode  : int|null
$webhooks  : WebhookRepository
$attributes  : array<string|int, mixed>
The parts attributes.
$discord  : Discord
The Discord client.
$factory  : Factory
The factory.
$fillable  : array<string|int, mixed>
The parts fillable attributes.
$fillAfterSave  : bool
Should we fill the part after saving?
$hidden  : array<string|int, mixed>
Attributes that are hidden from debug info.
$http  : Http
The HTTP client.
$regex  : string
The regex pattern to replace variables with.
$repositories  : array<string|int, mixed>
An array of repositories that can exist in a part.
$repositories_cache  : array<string|int, mixed>
An array of repositories.
$visible  : array<string|int, mixed>
Attributes which are visible from debug info.
__construct()  : mixed
Create a new part instance.
__debugInfo()  : array<string|int, mixed>
Handles debug calls from var_dump and similar functions.
__get()  : mixed
Handles dynamic get calls onto the part.
__set()  : mixed
Handles dynamic set calls onto the part.
__toString()  : string
Converts the part to a string.
allowText()  : bool
Returns if allow text.
allowVoice()  : bool
Returns if allow voice.
broadcastTyping()  : ExtendedPromiseInterface
Broadcasts that you are typing to the channel. Lasts for 5 seconds.
createInvite()  : ExtendedPromiseInterface<string|int, Invite>
Creates an invite for the channel.
createMessageCollector()  : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Creates a message collector for the channel.
deleteMessages()  : ExtendedPromiseInterface
Bulk deletes an array of messages.
editMessage()  : ExtendedPromiseInterface<string|int, Message>
Edit a message in the channel.
fetch()  : ExtendedPromiseInterface<string|int, static>
Fetches any missing information about the part from Discord's servers.
fill()  : void
Fills the parts attributes from an array.
getCreatableAttributes()  : array<string|int, mixed>
Returns the attributes needed to create.
getInvites()  : ExtendedPromiseInterface<string|int, Collection<string|int, Invite>>
Returns the channels invites.
getMessage()  : ExtendedPromiseInterface
Fetches a message object from the Discord servers.
getMessageHistory()  : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Fetches message history.
getPinnedMessages()  : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Returns the channels pinned messages.
getPublicAttributes()  : array<string|int, mixed>
Returns an array of public attributes.
getRawAttributes()  : array<string|int, mixed>
Returns an array of raw attributes.
getRepositoryAttributes()  : array<string|int, mixed>
Gets the attributes to pass to repositories.
getUpdatableAttributes()  : array<string|int, mixed>
Returns the updatable attributes.
isPartial()  : bool
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
jsonSerialize()  : array<string|int, mixed>
Provides data when the part is encoded into JSON. Used for JsonSerializable.
limitDelete()  : ExtendedPromiseInterface
Deletes a given number of messages, in order of time sent.
moveMember()  : ExtendedPromiseInterface
Moves a member to another voice channel.
muteMember()  : ExtendedPromiseInterface
Mutes a member on a voice channel.
offsetExists()  : bool
Checks if an attribute exists via key. Used for ArrayAccess.
offsetGet()  : mixed
Gets an attribute via key. Used for ArrayAccess.
offsetSet()  : mixed
Sets an attribute via key. Used for ArrayAccess.
offsetUnset()  : mixed
Unsets an attribute via key. Used for ArrayAccess.
pinMessage()  : ExtendedPromiseInterface<string|int, Message>
Adds a message to the channels pinboard.
sendEmbed()  : ExtendedPromiseInterface<string|int, Message>
Sends an embed to the channel.
sendFile()  : ExtendedPromiseInterface<string|int, Message>
Sends a file to the channel.
sendMessage()  : ExtendedPromiseInterface<string|int, Message>
Sends a message to the channel.
serialize()  : string
Serializes the data. Used for Serializable.
setOverwrite()  : ExtendedPromiseInterface
Sets an overwrite to the channel.
setPermissions()  : ExtendedPromiseInterface
Sets permissions in a channel.
startThread()  : ExtendedPromiseInterface<string|int, Thread>
Starts a thread in the channel.
unmuteMember()  : ExtendedPromiseInterface
Unmutes a member on a voice channel.
unpinMessage()  : ExtendedPromiseInterface
Removes a message from the channels pinboard.
unserialize()  : mixed
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
getGuildAttribute()  : Guild
Returns the guild attribute.
getIsPrivateAttribute()  : bool
Gets the is_private attribute.
getLastPinTimestampAttribute()  : Carbon
Gets the last pinned message timestamp.
getRecipientAttribute()  : User
Gets the recipient attribute.
getRecipientIdAttribute()  : string
Gets the recipient ID attribute.
getRecipientsAttribute()  : Collection
Gets the recipients attribute.
setPermissionOverwritesAttribute()  : void
Sets the permission overwrites attribute.
_sendMessage()  : ExtendedPromiseInterface
checkForMutator()  : string|false
Checks if there is a mutator present.
getAttribute()  : mixed
Gets an attribute on the part.
setAttribute()  : void
Sets an attribute on the part.

Constants

TYPE_CATEGORY

public mixed TYPE_CATEGORY = 4

TYPE_GAME_STORE

public mixed TYPE_GAME_STORE = 6

TYPE_GROUP

public mixed TYPE_GROUP = 3

TYPE_NEWS

public mixed TYPE_NEWS = 5

TYPE_NEWS_THREAD

public mixed TYPE_NEWS_THREAD = 10

TYPE_PRIVATE_THREAD

public mixed TYPE_PRIVATE_THREAD = 12

TYPE_PUBLIC_THREAD

public mixed TYPE_PUBLIC_THREAD = 11

TYPE_STAGE_CHANNEL

public mixed TYPE_STAGE_CHANNEL = 13

TYPE_TEXT

public mixed TYPE_TEXT = 0

TYPE_VOICE

public mixed TYPE_VOICE = 2

Properties

$application_id

public string $application_id

ID of the group DM creator if it is a bot.

$bitrate

public int $bitrate

The bitrate of the channel. Only for voice channels.

$created

Is the part already created in the Discord servers?

public bool $created = false

Whether the part has been created.

$default_auto_archive_duration

public int|null $default_auto_archive_duration

default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080

$guild

public Guild $guild

The guild that the channel belongs to. Only for text or voice channels.

$guild_id

public string|null $guild_id

The unique identifier of the guild that the channel belongs to. Only for text or voice channels.

$id

public string $id

The unique identifier of the Channel.

$is_private

public bool $is_private

Whether the channel is a private channel.

$last_message_id

public string $last_message_id

The unique identifier of the last message sent in the channel.

$last_pin_timestamp

public Carbon $last_pin_timestamp

When the last message was pinned.

$name

public string $name

The name of the channel.

$nsfw

public bool $nsfw

Whether the channel is NSFW.

$owner_id

public string $owner_id

The ID of the DM creator. Only for DM or group channels.

$parent_id

public string $parent_id

ID of the parent channel.

$position

public int $position

The position of the channel on the sidebar.

$rate_limit_per_user

public int $rate_limit_per_user

Amount of seconds a user has to wait before sending a new message.

$recipient

public User $recipient

The first recipient of the channel. Only for DM or group channels.

$recipient_id

public string $recipient_id

The ID of the recipient of the channel, if it is a DM channel.

$recipients

public Collection|array<string|int, User> $recipients

A collection of all the recipients in the channel. Only for DM or group channels.

$rtc_region

public string|null $rtc_region

voice region id for the voice channel, automatic when set to null

$scriptData

Custom script data.

public mixed $scriptData

Used for storing custom information, used by end products.

$topic

public string $topic

The topic of the channel.

$type

public int $type

The type of the channel.

$user_limit

public int $user_limit

The user limit of the channel.

$video_quality_mode

public int|null $video_quality_mode

the camera video quality mode of the voice channel, 1 when not present

$attributes

The parts attributes.

protected array<string|int, mixed> $attributes = []

The parts attributes and content.

$discord

The Discord client.

protected Discord $discord

Client.

$fillable

The parts fillable attributes.

protected array<string|int, mixed> $fillable = ['id', 'name', 'type', 'topic', 'guild_id', 'position', 'is_private', 'last_message_id', 'permission_overwrites', 'bitrate', 'recipients', 'nsfw', 'user_limit', 'rate_limit_per_user', 'icon', 'owner_id', 'application_id', 'parent_id', 'last_pin_timestamp', 'rtc_region', 'video_quality_mode', 'default_auto_archive_duration']

The array of attributes that can be mass-assigned.

Tags
inheritdoc

$fillAfterSave

Should we fill the part after saving?

protected bool $fillAfterSave = true

Whether the part will be saved after being filled.

$hidden

Attributes that are hidden from debug info.

protected array<string|int, mixed> $hidden = []

Attributes that are hidden from public.

$http

The HTTP client.

protected Http $http

Client.

$regex

The regex pattern to replace variables with.

protected string $regex = '/:([a-z_]+)/'

The regex which is used to replace placeholders.

$repositories

An array of repositories that can exist in a part.

protected array<string|int, mixed> $repositories = ['members' => DiscordRepositoryChannelVoiceMemberRepository::class, 'messages' => DiscordRepositoryChannelMessageRepository::class, 'overwrites' => DiscordRepositoryChannelOverwriteRepository::class, 'webhooks' => DiscordRepositoryChannelWebhookRepository::class, 'threads' => DiscordRepositoryChannelThreadRepository::class]

Repositories.

Tags
inheritdoc

$repositories_cache

An array of repositories.

protected array<string|int, mixed> $repositories_cache = []

$visible

Attributes which are visible from debug info.

protected array<string|int, mixed> $visible = []

Methods

__construct()

Create a new part instance.

public __construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
$discord : Discord

The Discord client.

$attributes : array<string|int, mixed> = []

An array of attributes to build the part.

$created : bool = false

Whether the part has already been created.

Return values
mixed

__debugInfo()

Handles debug calls from var_dump and similar functions.

public __debugInfo() : array<string|int, mixed>
Tags
throws
Exception
see
self::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

__get()

Handles dynamic get calls onto the part.

public __get(string $key) : mixed
Parameters
$key : string

The attributes key.

Tags
throws
Exception
see
self::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

The value of the attribute.

__set()

Handles dynamic set calls onto the part.

public __set(string $key, mixed $value) : mixed
Parameters
$key : string

The attributes key.

$value : mixed

The attributes value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
mixed

__toString()

Converts the part to a string.

public __toString() : string
Tags
throws
Exception
see
self::getPublicAttributes()

This function encodes getPublicAttributes into JSON.

Return values
string

A JSON string of attributes.

allowText()

Returns if allow text.

public allowText() : bool
Return values
bool

if we can send text or not.

allowVoice()

Returns if allow voice.

public allowVoice() : bool
Return values
bool

if we can send voice or not.

broadcastTyping()

Broadcasts that you are typing to the channel. Lasts for 5 seconds.

public broadcastTyping() : ExtendedPromiseInterface
Return values
ExtendedPromiseInterface

createInvite()

Creates an invite for the channel.

public createInvite([bool $options = [] ]) : ExtendedPromiseInterface<string|int, Invite>
Parameters
$options : bool = []

['unique'] Whether the invite code should be unique (useful for creating many unique one time use invites).

Return values
ExtendedPromiseInterface<string|int, Invite>

createMessageCollector()

Creates a message collector for the channel.

public createMessageCollector(callable $filter[, int $options = [] ]) : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Parameters
$filter : callable

The filter function. Returns true or false.

$options : int = []

['limit'] The amount of messages allowed or false.

Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Message>>

deleteMessages()

Bulk deletes an array of messages.

public deleteMessages(array<string|int, mixed>|Traversable $messages) : ExtendedPromiseInterface
Parameters
$messages : array<string|int, mixed>|Traversable

An array of messages to delete.

Return values
ExtendedPromiseInterface

editMessage()

Edit a message in the channel.

public editMessage(MessageBuilder $message, MessageBuilder $builder) : ExtendedPromiseInterface<string|int, Message>
Parameters
$message : MessageBuilder

Contains the new contents of the message. Note that fields not specified in the builder will not be overwritten.

$builder : MessageBuilder
Tags
deprecated
7.0.0

Use Message::edit instead

Return values
ExtendedPromiseInterface<string|int, Message>

fetch()

Fetches any missing information about the part from Discord's servers.

public fetch() : ExtendedPromiseInterface<string|int, static>
Tags
throws
RuntimeException

The part is not fetchable.

Return values
ExtendedPromiseInterface<string|int, static>

fill()

Fills the parts attributes from an array.

public fill(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>

An array of attributes to build the part.

Return values
void

getCreatableAttributes()

Returns the attributes needed to create.

public getCreatableAttributes() : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

getInvites()

Returns the channels invites.

public getInvites() : ExtendedPromiseInterface<string|int, Collection<string|int, Invite>>
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Invite>>

getMessage()

Fetches a message object from the Discord servers.

public getMessage(string $id) : ExtendedPromiseInterface
Parameters
$id : string

The message snowflake.

Tags
deprecated
7.0.0

Use $message->messages->fetch($id).

Return values
ExtendedPromiseInterface

getMessageHistory()

Fetches message history.

public getMessageHistory(array<string|int, mixed> $options) : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Parameters
$options : array<string|int, mixed>
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Message>>

getPinnedMessages()

Returns the channels pinned messages.

public getPinnedMessages() : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Message>>

getPublicAttributes()

Returns an array of public attributes.

public getPublicAttributes() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

An array of public attributes.

getRawAttributes()

Returns an array of raw attributes.

public getRawAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Raw attributes.

getRepositoryAttributes()

Gets the attributes to pass to repositories.

public getRepositoryAttributes() : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

Attributes.

getUpdatableAttributes()

Returns the updatable attributes.

public getUpdatableAttributes() : array<string|int, mixed>
Tags
inheritdoc
Return values
array<string|int, mixed>

isPartial()

Whether the part is considered partial i.e. missing information which can be fetched from Discord.

public isPartial() : bool
Return values
bool

jsonSerialize()

Provides data when the part is encoded into JSON. Used for JsonSerializable.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
Exception
see
self::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

limitDelete()

Deletes a given number of messages, in order of time sent.

public limitDelete(int $value) : ExtendedPromiseInterface
Parameters
$value : int
Return values
ExtendedPromiseInterface

moveMember()

Moves a member to another voice channel.

public moveMember(mixed $member) : ExtendedPromiseInterface
Parameters
$member : mixed
Return values
ExtendedPromiseInterface

muteMember()

Mutes a member on a voice channel.

public muteMember(mixed $member) : ExtendedPromiseInterface
Parameters
$member : mixed
Return values
ExtendedPromiseInterface

offsetExists()

Checks if an attribute exists via key. Used for ArrayAccess.

public offsetExists(string $key) : bool
Parameters
$key : string

The attribute key.

Return values
bool

Whether the offset exists.

offsetGet()

Gets an attribute via key. Used for ArrayAccess.

public offsetGet(string $key) : mixed
Parameters
$key : string

The attribute key.

Tags
throws
Exception
see
self::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

offsetSet()

Sets an attribute via key. Used for ArrayAccess.

public offsetSet(string $key, mixed $value) : mixed
Parameters
$key : string

The attribute key.

$value : mixed

The attribute value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
mixed

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

public offsetUnset(string $key) : mixed
Parameters
$key : string

The attribute key.

Return values
mixed

pinMessage()

Adds a message to the channels pinboard.

public pinMessage(Message $message) : ExtendedPromiseInterface<string|int, Message>
Parameters
$message : Message

The message to pin.

Return values
ExtendedPromiseInterface<string|int, Message>

sendEmbed()

Sends an embed to the channel.

public sendEmbed(Embed $embed) : ExtendedPromiseInterface<string|int, Message>
Parameters
$embed : Embed

Embed to send.

Return values
ExtendedPromiseInterface<string|int, Message>

sendFile()

Sends a file to the channel.

public sendFile(string $filepath[, string|null $filename = null ][, string|null $content = null ][, bool $tts = false ]) : ExtendedPromiseInterface<string|int, Message>
Parameters
$filepath : string

The path to the file to be sent.

$filename : string|null = null

The name to send the file as.

$content : string|null = null

Message content to send with the file.

$tts : bool = false

Whether to send the message with TTS.

Tags
deprecated
7.0.0

Use Channel::sendMessage to send files.

Return values
ExtendedPromiseInterface<string|int, Message>

sendMessage()

Sends a message to the channel.

public sendMessage(MessageBuilder $message) : ExtendedPromiseInterface<string|int, Message>
Parameters
$message : MessageBuilder

The message builder that should be converted into a message.

Return values
ExtendedPromiseInterface<string|int, Message>

serialize()

Serializes the data. Used for Serializable.

public serialize() : string
Return values
string

A string of serialized data.

setOverwrite()

Sets an overwrite to the channel.

public setOverwrite(Part $part, Overwrite $overwrite) : ExtendedPromiseInterface
Parameters
$part : Part

A role or member.

$overwrite : Overwrite

An overwrite object.

Return values
ExtendedPromiseInterface

setPermissions()

Sets permissions in a channel.

public setPermissions(Part $part[, array<string|int, mixed> $allow = [] ][, array<string|int, mixed> $deny = [] ]) : ExtendedPromiseInterface
Parameters
$part : Part

A role or member.

$allow : array<string|int, mixed> = []

An array of permissions to allow.

$deny : array<string|int, mixed> = []

An array of permissions to deny.

Return values
ExtendedPromiseInterface

startThread()

Starts a thread in the channel.

public startThread(string $name[, bool $private = false ][, int $auto_archive_duration = 1440 ]) : ExtendedPromiseInterface<string|int, Thread>
Parameters
$name : string

the name of the thread.

$private : bool = false

whether the thread should be private. cannot start a private thread in a news channel.

$auto_archive_duration : int = 1440

number of minutes of inactivity until the thread is auto-archived. one of 60, 1440, 4320, 10080.

Return values
ExtendedPromiseInterface<string|int, Thread>

unmuteMember()

Unmutes a member on a voice channel.

public unmuteMember(mixed $member) : ExtendedPromiseInterface
Parameters
$member : mixed
Return values
ExtendedPromiseInterface

unpinMessage()

Removes a message from the channels pinboard.

public unpinMessage(Message $message) : ExtendedPromiseInterface
Parameters
$message : Message

The message to un-pin.

Return values
ExtendedPromiseInterface

unserialize()

Unserializes some data and stores it. Used for Serializable.

public unserialize(string $data) : mixed
Parameters
$data : string

Some serialized data.

Tags
see
self::setAttribute()

The unserialized data is stored with setAttribute.

Return values
mixed

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void
Tags
inheritdoc
Return values
void

getGuildAttribute()

Returns the guild attribute.

protected getGuildAttribute() : Guild
Return values
Guild

The guild attribute.

getIsPrivateAttribute()

Gets the is_private attribute.

protected getIsPrivateAttribute() : bool
Return values
bool

Whether the channel is private.

getLastPinTimestampAttribute()

Gets the last pinned message timestamp.

protected getLastPinTimestampAttribute() : Carbon
Return values
Carbon

getRecipientAttribute()

Gets the recipient attribute.

protected getRecipientAttribute() : User
Return values
User

The recipient.

getRecipientIdAttribute()

Gets the recipient ID attribute.

protected getRecipientIdAttribute() : string
Return values
string

getRecipientsAttribute()

Gets the recipients attribute.

protected getRecipientsAttribute() : Collection
Tags
throws
Exception
Return values
Collection

A collection of recepients.

setPermissionOverwritesAttribute()

Sets the permission overwrites attribute.

protected setPermissionOverwritesAttribute(array<string|int, mixed> $overwrites) : void
Parameters
$overwrites : array<string|int, mixed>
Return values
void

checkForMutator()

Checks if there is a mutator present.

private checkForMutator(string $key, string $type) : string|false
Parameters
$key : string

The attribute name to check.

$type : string

Either get or set.

Return values
string|false

Either a string if it is callable or false.

getAttribute()

Gets an attribute on the part.

private getAttribute(string $key) : mixed
Parameters
$key : string

The key to the attribute.

Tags
throws
Exception
Return values
mixed

Either the attribute if it exists or void.

setAttribute()

Sets an attribute on the part.

private setAttribute(string $key, mixed $value) : void
Parameters
$key : string

The key to the attribute.

$value : mixed

The value of the attribute.

Return values
void

Search results