DiscordPHP Documentation

Channel extends Part
in package

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

Tags
link
https://discord.com/developers/docs/resources/channel#channel-object
since
2.0.0

Refactored as Part

since
1.0.0

Table of Contents

FLAG_PINNED  = 1 << 1
FLAG_REQUIRE_TAG  = 1 << 4
FORUM_LAYOUT_GRID_VIEW  = 2
FORUM_LAYOUT_LIST_VIEW  = 1
FORUM_LAYOUT_NOT_SET  = 0
SORT_ORDER_CREATION_DATE  = 1
SORT_ORDER_LATEST_ACTIVITY  = 0
TYPE_ANNOUNCEMENT  = self::TYPE_GUILD_ANNOUNCEMENT
TYPE_ANNOUNCEMENT_THREAD  = 10
TYPE_CATEGORY  = self::TYPE_GUILD_CATEGORY
TYPE_DIRECTORY  = self::TYPE_GUILD_DIRECTORY
TYPE_DM  = 1
TYPE_FORUM  = self::TYPE_GUILD_FORUM
TYPE_GROUP  = self::TYPE_GROUP_DM
TYPE_GROUP_DM  = 3
TYPE_GUILD_ANNOUNCEMENT  = 5
TYPE_GUILD_CATEGORY  = 4
TYPE_GUILD_DIRECTORY  = 14
TYPE_GUILD_FORUM  = 15
TYPE_GUILD_STAGE_VOICE  = 13
TYPE_GUILD_TEXT  = 0
TYPE_GUILD_VOICE  = 2
TYPE_NEWS  = self::TYPE_GUILD_ANNOUNCEMENT
TYPE_NEWS_THREAD  = self::TYPE_ANNOUNCEMENT_THREAD
TYPE_PRIVATE_THREAD  = 12
TYPE_PUBLIC_THREAD  = 11
TYPE_STAGE_CHANNEL  = self::TYPE_GUILD_STAGE_VOICE
TYPE_TEXT  = self::TYPE_GUILD_TEXT
TYPE_VOICE  = self::TYPE_GUILD_VOICE
VIDEO_QUALITY_AUTO  = 1
VIDEO_QUALITY_FULL  = 2
$application_id  : string|null
$available_tags  : Collection|array<string|int, Tag>
$bitrate  : int|null
$created  : bool
Is the part already created in the Discord servers?
$default_auto_archive_duration  : int|null
$default_forum_layout  : int|null
$default_reaction_emoji  : Array|null
$default_sort_order  : Array|null
$default_thread_rate_limit_per_user  : int|null
$flags  : int|null
$guild  : Guild|null
$guild_id  : string|null
$icon  : Array|null
$id  : string
$invites  : InviteRepository
$is_private  : bool
$last_message_id  : Array|null
$last_pin_timestamp  : Carbon|null
$members  : VoiceMemberRepository
$messages  : MessageRepository
$name  : Array|null
$nsfw  : bool|null
$overwrites  : OverwriteRepository
$owner_id  : string|null
$parent_id  : Array|null
$permissions  : string|null
$position  : int|null
$rate_limit_per_user  : int|null
$recipient  : User|null
$recipient_id  : string|null
$recipients  : Collection|array<string|int, User>
$rtc_region  : Array|null
$scriptData  : mixed
Custom script data.
$stage_instances  : StageInstanceRepository
$threads  : ThreadRepository
$topic  : Array|null
$type  : int
$user_limit  : int|null
$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.
$hidden  : array<string|int, mixed>
Attributes that are hidden from debug info.
$http  : Http
The HTTP client.
$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.
__serialize()  : array<string|int, mixed>
__set()  : void
Handles dynamic set calls onto the part.
__toString()  : string
Returns a formatted mention for text channel or name of the channel.
__unserialize()  : void
allowInvite()  : bool
Returns if allow invite.
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.
canInvite()  : bool
Returns if invite can be created in this type of channel.
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.
ExtendedPromiseInterface()  : void
fetch()  : ExtendedPromiseInterface<string|int, self>
Fetches any missing information about the part from Discord's servers.
fill()  : void
Fills the parts attributes from an array.
getBotPermissions()  : RolePermission|null
Returns the bot's permissions in the channel.
getCreatableAttributes()  : array<string|int, mixed>
Returns the attributes needed to create.
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.
isTextBased()  : bool
Returns if channel type is text based.
isVoiceBased()  : bool
Returns if channel type is voice based.
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()  : void
Sets an attribute via key. Used for ArrayAccess.
offsetUnset()  : void
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|null
Serializes the data. Used for Serializable.
setCategory()  : ExtendedPromiseInterface<string|int, self>
Change category of a channel.
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()  : void
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
getAvailableTagsAttribute()  : Collection|array<string|int, Tag>
Gets the available tags attribute.
getDefaultReactionEmojiAttribute()  : Reaction|null
Gets the default reaction emoji attribute.
getGuildAttribute()  : Guild|null
Returns the guild attribute.
getIsPrivateAttribute()  : bool
Gets the is_private attribute.
getLastPinTimestampAttribute()  : Carbon|null
Gets the last pinned message timestamp.
getRecipientAttribute()  : User|null
Gets the recipient attribute.
getRecipientIdAttribute()  : string|null
Gets the recipient ID attribute.
getRecipientsAttribute()  : Collection
Gets the recipients attribute.
setPermissionOverwritesAttribute()  : void
Sets the permission overwrites attribute.
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.
studly()  : string
Converts a string to studlyCase.

Constants

FLAG_PINNED

public mixed FLAG_PINNED = 1 << 1
Tags
deprecated
10.0.0

Use Thread::FLAG_PINNED

FLAG_REQUIRE_TAG

public mixed FLAG_REQUIRE_TAG = 1 << 4

FORUM_LAYOUT_GRID_VIEW

public mixed FORUM_LAYOUT_GRID_VIEW = 2

FORUM_LAYOUT_LIST_VIEW

public mixed FORUM_LAYOUT_LIST_VIEW = 1

FORUM_LAYOUT_NOT_SET

public mixed FORUM_LAYOUT_NOT_SET = 0

SORT_ORDER_CREATION_DATE

public mixed SORT_ORDER_CREATION_DATE = 1

SORT_ORDER_LATEST_ACTIVITY

public mixed SORT_ORDER_LATEST_ACTIVITY = 0

TYPE_ANNOUNCEMENT

public mixed TYPE_ANNOUNCEMENT = self::TYPE_GUILD_ANNOUNCEMENT
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_ANNOUNCEMENT

TYPE_ANNOUNCEMENT_THREAD

public mixed TYPE_ANNOUNCEMENT_THREAD = 10

TYPE_CATEGORY

public mixed TYPE_CATEGORY = self::TYPE_GUILD_CATEGORY
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_CATEGORY

TYPE_DIRECTORY

public mixed TYPE_DIRECTORY = self::TYPE_GUILD_DIRECTORY
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_DIRECTORY

TYPE_FORUM

public mixed TYPE_FORUM = self::TYPE_GUILD_FORUM
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_FORUM

TYPE_GROUP

public mixed TYPE_GROUP = self::TYPE_GROUP_DM
Tags
deprecated
10.0.0

Use Channel::TYPE_GROUP_DM

TYPE_GROUP_DM

public mixed TYPE_GROUP_DM = 3

TYPE_GUILD_ANNOUNCEMENT

public mixed TYPE_GUILD_ANNOUNCEMENT = 5

TYPE_GUILD_CATEGORY

public mixed TYPE_GUILD_CATEGORY = 4

TYPE_GUILD_DIRECTORY

public mixed TYPE_GUILD_DIRECTORY = 14

TYPE_GUILD_FORUM

public mixed TYPE_GUILD_FORUM = 15

TYPE_GUILD_STAGE_VOICE

public mixed TYPE_GUILD_STAGE_VOICE = 13

TYPE_GUILD_TEXT

public mixed TYPE_GUILD_TEXT = 0

TYPE_GUILD_VOICE

public mixed TYPE_GUILD_VOICE = 2

TYPE_NEWS

public mixed TYPE_NEWS = self::TYPE_GUILD_ANNOUNCEMENT
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_ANNOUNCEMENT

TYPE_NEWS_THREAD

public mixed TYPE_NEWS_THREAD = self::TYPE_ANNOUNCEMENT_THREAD
Tags
deprecated
10.0.0

Use Channel::TYPE_ANNOUNCEMENT_THREAD

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 = self::TYPE_GUILD_STAGE_VOICE
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_STAGE_VOICE

TYPE_TEXT

public mixed TYPE_TEXT = self::TYPE_GUILD_TEXT
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_TEXT

TYPE_VOICE

public mixed TYPE_VOICE = self::TYPE_GUILD_VOICE
Tags
deprecated
10.0.0

Use Channel::TYPE_GUILD_VOICE

VIDEO_QUALITY_AUTO

public mixed VIDEO_QUALITY_AUTO = 1

VIDEO_QUALITY_FULL

public mixed VIDEO_QUALITY_FULL = 2

Properties

$application_id

public string|null $application_id

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

$available_tags

public Collection|array<string|int, Tag> $available_tags

Set of tags that can be used in a forum channel, limited to 20.

$bitrate

public int|null $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.

$default_forum_layout

public int|null $default_forum_layout

The default layout type used to display posts in a forum channel. Defaults to 0, which indicates a layout view has not been set by a channel admin.

$default_reaction_emoji

public Array|null $default_reaction_emoji

Emoji to show in the add reaction button on a thread in a forum channel.

$default_sort_order

public Array|null $default_sort_order

The default sort order type used to order posts in forum channels.

$default_thread_rate_limit_per_user

public int|null $default_thread_rate_limit_per_user

The initial rate_limit_per_user to set on newly created threads in a forum channel. this field is copied to the thread at creation time and does not live update.

$flags

public int|null $flags

Channel flags combined as a bitfield.

$guild read-only

public Guild|null $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.

$icon

public Array|null $icon

Icon hash.

$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 Array|null $last_message_id

The unique identifier of the last message sent in the channel (or thread for forum channels) (may not point to an existing or valid message or thread).

$last_pin_timestamp

public Carbon|null $last_pin_timestamp

When the last message was pinned.

$name

public Array|null $name

The name of the channel.

$nsfw

public bool|null $nsfw

Whether the channel is NSFW.

$owner_id

public string|null $owner_id

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

$parent_id

public Array|null $parent_id

ID of the parent channel.

$permissions

public string|null $permissions

Computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on an application command interaction.

$position

public int|null $position

The position of the channel on the sidebar.

$rate_limit_per_user

public int|null $rate_limit_per_user

Amount of seconds a user has to wait before sending a new message (slow mode).

$recipient read-only

public User|null $recipient

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

$recipient_id read-only

public string|null $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 Array|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.

Tags
deprecated
10.0.0

Relying on this variable with dynamic caching is discouraged.

$topic

public Array|null $topic

The topic of the channel (0-4096 characters for forum channels, 0-1024 characters for all others).

$type

public int $type

The type of the channel.

$user_limit

public int|null $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', 'type', 'guild_id', 'position', 'name', 'topic', 'nsfw', 'last_message_id', 'bitrate', 'user_limit', 'rate_limit_per_user', 'recipients', 'icon', 'owner_id', 'application_id', 'parent_id', 'last_pin_timestamp', 'rtc_region', 'video_quality_mode', 'default_auto_archive_duration', 'permissions', 'flags', 'available_tags', 'default_reaction_emoji', 'default_thread_rate_limit_per_user', 'default_sort_order', 'default_forum_layout', // @internal 'is_private', // repositories 'permission_overwrites', ]

The array of attributes that can be mass-assigned.

$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.

$repositories

An array of repositories that can exist in a part.

protected array<string|int, mixed> $repositories = ['overwrites' => \Discord\Repository\Channel\OverwriteRepository::class, 'members' => \Discord\Repository\Channel\VoiceMemberRepository::class, 'messages' => \Discord\Repository\Channel\MessageRepository::class, 'webhooks' => \Discord\Repository\Channel\WebhookRepository::class, 'threads' => \Discord\Repository\Channel\ThreadRepository::class, 'invites' => \Discord\Repository\Channel\InviteRepository::class, 'stage_instances' => \Discord\Repository\Channel\StageInstanceRepository::class]

Repositories.

$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
Part::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
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

The value of the attribute.

__serialize()

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

__set()

Handles dynamic set calls onto the part.

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

The attributes key.

$value : mixed

The attributes value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
void

__toString()

Returns a formatted mention for text channel or name of the channel.

public __toString() : string
Return values
string

A formatted mention for text channel or name of the channel.

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

allowInvite()

Returns if allow invite.

public allowInvite() : bool
Tags
deprecated
10.0.0

Use Channel::canInvite()

Return values
bool

if we can make invite or not.

allowText()

Returns if allow text.

public allowText() : bool
Tags
deprecated
10.0.0

Use Channel::isTextBased()

Return values
bool

if we can send text or not.

allowVoice()

Returns if allow voice.

public allowVoice() : bool
Tags
deprecated
10.0.0

Use Channel::isVoiceBased()

Return values
bool

if we can send voice or not.

canInvite()

Returns if invite can be created in this type of channel.

public canInvite() : bool
Return values
bool

Whether the channel type is possible for creating invite.

createInvite()

Creates an invite for the channel.

public createInvite([array<string|int, mixed> $options = [] ][, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Invite>
Parameters
$options : array<string|int, mixed> = []

An array of options. All fields are optional.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#create-channel-invite
throws
NoPermissionsException

Missing create_instant_invite permission.

Return values
ExtendedPromiseInterface<string|int, Invite>

createMessageCollector()

Creates a message collector for the channel.

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

The filter function. Returns true or false.

$options : array<string|int, mixed> = []
Return values
ExtendedPromiseInterface<string|int, Collection<string|int, Message>>

deleteMessages()

Bulk deletes an array of messages.

public deleteMessages(array<string|int, mixed>|Traversable $messages[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$messages : array<string|int, mixed>|Traversable

An array of messages to delete.

$reason : string|null = null

Reason for Audit Log (only for bulk messages).

Tags
link
https://discord.com/developers/docs/resources/channel#bulk-delete-messages
throws
InvalidArgumentException
throws
NoPermissionsException

Missing manage_messages permission.

Return values
ExtendedPromiseInterface

ExtendedPromiseInterface()

public ExtendedPromiseInterface() : void

<Message> sendMessage(MessageBuilder $builder)

Return values
void

fetch()

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

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

The part is not fetchable.

Return values
ExtendedPromiseInterface<string|int, self>

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

getMessageHistory()

Fetches message history.

public getMessageHistory(array<string|int, mixed> $options) : ExtendedPromiseInterface<string|int, Collection<string|int, Message>>
Parameters
$options : array<string|int, mixed>
Tags
link
https://discord.com/developers/docs/resources/channel#get-channel-messages
throws
NoPermissionsException

Missing read_message_history permission.

throws
RangeException
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>
Return values
array<string|int, mixed>

Attributes.

isPartial()

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

public isPartial() : bool
Return values
bool

isTextBased()

Returns if channel type is text based.

public isTextBased() : bool
Return values
bool

Whether the channel is possible for sending text.

isVoiceBased()

Returns if channel type is voice based.

public isVoiceBased() : bool
Return values
bool

Wether the channel is possible for voice.

jsonSerialize()

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

public jsonSerialize() : array<string|int, mixed>
Tags
throws
Exception
see
Part::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[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$value : int
$reason : string|null = null

Reason for Audit Log (only for bulk messages).

Tags
link
https://discord.com/developers/docs/resources/channel#bulk-delete-messages
throws
NoPermissionsException

Missing manage_messages permission.

Return values
ExtendedPromiseInterface

moveMember()

Moves a member to another voice channel.

public moveMember(Member|string $member[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$member : Member|string

The member to move. (either a Member part or the member ID)

$reason : string|null = null

Reason for Audit Log.

Tags
throws
RuntimeException
throws
NoPermissionsException

Missing move_members permission.

Return values
ExtendedPromiseInterface

muteMember()

Mutes a member on a voice channel.

public muteMember(Member|string $member[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$member : Member|string

The member to mute. (either a Member part or the member ID)

$reason : string|null = null

Reason for Audit Log.

Tags
throws
RuntimeException
throws
NoPermissionsException

Missing mute_members permission.

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
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

offsetSet()

Sets an attribute via key. Used for ArrayAccess.

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

The attribute key.

$value : mixed

The attribute value.

Tags
see
Part::setAttribute()

This function forwards onto setAttribute.

Return values
void

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

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

The attribute key.

Return values
void

pinMessage()

Adds a message to the channels pinboard.

public pinMessage(Message $message[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Message>
Parameters
$message : Message

The message to pin.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#pin-message
throws
NoPermissionsException

Missing manage_messages permission.

throws
RuntimeException
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.

Tags
deprecated
10.0.0

Use Channel::sendMessage with MessageBuilder::addEmbed()

see
Channel::sendMessage()
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.

see
Channel::sendMessage()
Return values
ExtendedPromiseInterface<string|int, Message>

sendMessage()

Sends a message to the channel.

public sendMessage(MessageBuilder|string $message[, bool $tts = false ][, Embed|array<string|int, mixed>|null $embed = null ][, array<string|int, mixed>|null $allowed_mentions = null ][, Message|null $replyTo = null ]) : ExtendedPromiseInterface<string|int, Message>

Takes a MessageBuilder or content of the message for the first parameter. If the first parameter is an instance of MessageBuilder, the rest of the arguments are disregarded.

Parameters
$message : MessageBuilder|string

The message builder that should be converted into a message, or the string content of the message.

$tts : bool = false

Whether the message is TTS.

$embed : Embed|array<string|int, mixed>|null = null

An embed object or array to send in the message.

$allowed_mentions : array<string|int, mixed>|null = null

Allowed mentions object for the message.

$replyTo : Message|null = null

Sends the message as a reply to the given message instance.

Tags
link
https://discord.com/developers/docs/resources/channel#create-message
throws
RuntimeException
throws
NoPermissionsException

Missing various permissions depending on the message body.

Return values
ExtendedPromiseInterface<string|int, Message>

serialize()

Serializes the data. Used for Serializable.

public serialize() : string|null
Return values
string|null

A string of serialized data.

setCategory()

Change category of a channel.

public setCategory(Channel|string|null $category[, int|null $position = null ][, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, self>
Parameters
$category : Channel|string|null

The category channel to set it to (either a Channel part or the channel ID or null for none).

$position : int|null = null

The new channel position, not relative to category.

$reason : string|null = null

Reason for Audit Log.

Tags
throws
RuntimeException
throws
InvalidArgumentException
throws
NoPermissionsException

Missing manage_channels permission in either channel.

Return values
ExtendedPromiseInterface<string|int, self>

setOverwrite()

Sets an overwrite to the channel.

public setOverwrite(Part $part, Overwrite $overwrite[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$part : Part

A role or member.

$overwrite : Overwrite

An overwrite object.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#edit-channel-permissions
throws
NoPermissionsException

Missing manage_roles permission.

throws
InvalidOverwriteException

Overwrite type is not member or role.

Return values
ExtendedPromiseInterface

setPermissions()

Sets permissions in a channel.

public setPermissions(Part $part[, array<string|int, mixed> $allow = [] ][, array<string|int, mixed> $deny = [] ][, string|null $reason = null ]) : 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.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#edit-channel-permissions
throws
InvalidOverwriteException
Return values
ExtendedPromiseInterface

startThread()

Starts a thread in the channel.

public startThread(array<string|int, mixed> $options[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Thread>
Parameters
$options : array<string|int, mixed>

Thread params.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#start-thread-without-message
link
https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
throws
RuntimeException
throws
NoPermissionsException

Missing various permissions: create_private_threads when creating a private thread. create_public_threads when creating a public thread. send_messages when creating a forum post.

since
10.0.0

Arguments for $name, $private and $auto_archive_duration are now inside $options

Return values
ExtendedPromiseInterface<string|int, Thread>

unmuteMember()

Unmutes a member on a voice channel.

public unmuteMember(Member|string $member[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$member : Member|string

The member to unmute. (either a Member part or the member ID)

$reason : string|null = null

Reason for Audit Log.

Tags
throws
RuntimeException
throws
NoPermissionsException

Missing mute_members permission.

Return values
ExtendedPromiseInterface

unpinMessage()

Removes a message from the channels pinboard.

public unpinMessage(Message $message[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$message : Message

The message to un-pin.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/channel#unpin-message
throws
NoPermissionsException

Missing manage_messages permission.

throws
RuntimeException
Return values
ExtendedPromiseInterface

unserialize()

Unserializes some data and stores it. Used for Serializable.

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

Some serialized data.

Tags
see
Part::setAttribute()

The unserialized data is stored with setAttribute.

Return values
void

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void
Return values
void

getAvailableTagsAttribute()

Gets the available tags attribute.

protected getAvailableTagsAttribute() : Collection|array<string|int, Tag>
Tags
since
7.4.0
Return values
Collection|array<string|int, Tag>

Available forum tags.

getDefaultReactionEmojiAttribute()

Gets the default reaction emoji attribute.

protected getDefaultReactionEmojiAttribute() : Reaction|null
Tags
since
7.4.0
Return values
Reaction|null

Default forum reaction emoji.

getGuildAttribute()

Returns the guild attribute.

protected getGuildAttribute() : Guild|null
Return values
Guild|null

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|null
Tags
throws
Exception
Return values
Carbon|null

getRecipientAttribute()

Gets the recipient attribute.

protected getRecipientAttribute() : User|null
Return values
User|null

The recipient.

getRecipientIdAttribute()

Gets the recipient ID attribute.

protected getRecipientIdAttribute() : string|null
Return values
string|null

getRecipientsAttribute()

Gets the recipients attribute.

protected getRecipientsAttribute() : Collection
Return values
Collection

A collection of recepients.

setPermissionOverwritesAttribute()

Sets the permission overwrites attribute.

protected setPermissionOverwritesAttribute(array<string|int, mixed>|null $overwrites) : void
Parameters
$overwrites : array<string|int, mixed>|null
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

studly()

Converts a string to studlyCase.

private static studly(string $string) : string

This is a port of updated Laravel's implementation, a non-regex with static cache. The Discord\studly() is kept due to unintended bug and we do not want to introduce BC by replacing it. This method is private static as we may move it outside this class in future.

Parameters
$string : string

The string to convert.

Tags
since
10.0.0
Return values
string

Search results