DiscordPHP Documentation

ChannelSelect extends SelectMenu
in package

A Channel Select is an interactive component that allows users to select one or more channels in a message.

Options are automatically populated based on available channels in the server and can be filtered by channel types.

Channel Selects can be configured for both single-select and multi-select behavior. When a user finishes making their choice(s) your app receives an interaction.

Channel Selects must be placed inside an Action Row and are only available in messages. An Action Row can contain only one select menu and cannot contain buttons if it has a select menu.

Tags
link
https://discord.com/developers/docs/components/reference#channel-select
since
10.11.0

Table of Contents

Constants

TYPES  = [ 0 => \Discord\Parts\Channel\Message\Component::class, // Fallback for unknown types \Discord\Builders\Components\Component::TYPE_ACTION_ROW => \Discord\Parts\Channel\Message\ActionRow::class, \Discord\Builders\Components\Component::TYPE_BUTTON => \Discord\Parts\Channel\Message\Button::class, \Discord\Builders\Components\Component::TYPE_STRING_SELECT => \Discord\Parts\Channel\Message\StringSelect::class, \Discord\Builders\Components\Component::TYPE_TEXT_INPUT => \Discord\Parts\Channel\Message\TextInput::class, \Discord\Builders\Components\Component::TYPE_USER_SELECT => \Discord\Parts\Channel\Message\UserSelect::class, \Discord\Builders\Components\Component::TYPE_ROLE_SELECT => \Discord\Parts\Channel\Message\RoleSelect::class, \Discord\Builders\Components\Component::TYPE_MENTIONABLE_SELECT => \Discord\Parts\Channel\Message\MentionableSelect::class, \Discord\Builders\Components\Component::TYPE_CHANNEL_SELECT => \Discord\Parts\Channel\Message\ChannelSelect::class, \Discord\Builders\Components\Component::TYPE_SECTION => \Discord\Parts\Channel\Message\Section::class, \Discord\Builders\Components\Component::TYPE_TEXT_DISPLAY => \Discord\Parts\Channel\Message\TextDisplay::class, \Discord\Builders\Components\Component::TYPE_THUMBNAIL => \Discord\Parts\Channel\Message\Thumbnail::class, \Discord\Builders\Components\Component::TYPE_MEDIA_GALLERY => \Discord\Parts\Channel\Message\MediaGallery::class, \Discord\Builders\Components\Component::TYPE_FILE => \Discord\Parts\Channel\Message\File::class, \Discord\Builders\Components\Component::TYPE_SEPARATOR => \Discord\Parts\Channel\Message\Separator::class, \Discord\Builders\Components\Component::TYPE_CONTAINER => \Discord\Parts\Channel\Message\Container::class, ]
Available components and their respective classes.

Properties

$channel_types  : array<string|int, int>|null
$created  : bool
Is the part already created in the Discord servers?
$custom_id  : string
$custom_id  : string
$default_values  : ExCollectionInterface|array<string|int, DefaultValue>|null
$disabled  : bool|null
$id  : string|null
$id  : string|null
$id  : string|null
$max_values  : int|null
$min_values  : int|null
$placeholder  : string|null
$scriptData  : mixed
Custom script data.
$type  : int
$type  : int
$type  : int
$attributes  : array<string|int, mixed>
The parts attributes.
$discord  : Discord
The Discord client.
$factory  : Factory
The factory.
$fillable  : mixed
{@inheritDoc}
$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.

Methods

__construct()  : mixed
Create a new part instance.
__debugInfo()  : array<string|int, mixed>
__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
Converts the part to a string.
__unserialize()  : void
fetch()  : PromiseInterface<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.
getDiscord()  : Discord
Get the Discord instance that owns this Part.
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.
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.
serialize()  : string|null
Serializes the data. Used for Serializable.
unserialize()  : void
Unserializes some data and stores it. Used for Serializable.
afterConstruct()  : void
Called after the part has been constructed.
getComponentsAttribute()  : ExCollectionInterface|array<string|int, Component>|null
Gets the components of the interaction.
getDefaultValuesAttribute()  : ExCollectionInterface|null
makeOptionalAttributes()  : array<string|int, mixed>
Return key-value attributes if it has been filled.
checkForGetMutator()  : string|false
Checks if there is a get mutator present.
checkForSetMutator()  : string|false
Checks if there is a set 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

TYPES

Available components and their respective classes.

public array<int, string> TYPES = [ 0 => \Discord\Parts\Channel\Message\Component::class, // Fallback for unknown types \Discord\Builders\Components\Component::TYPE_ACTION_ROW => \Discord\Parts\Channel\Message\ActionRow::class, \Discord\Builders\Components\Component::TYPE_BUTTON => \Discord\Parts\Channel\Message\Button::class, \Discord\Builders\Components\Component::TYPE_STRING_SELECT => \Discord\Parts\Channel\Message\StringSelect::class, \Discord\Builders\Components\Component::TYPE_TEXT_INPUT => \Discord\Parts\Channel\Message\TextInput::class, \Discord\Builders\Components\Component::TYPE_USER_SELECT => \Discord\Parts\Channel\Message\UserSelect::class, \Discord\Builders\Components\Component::TYPE_ROLE_SELECT => \Discord\Parts\Channel\Message\RoleSelect::class, \Discord\Builders\Components\Component::TYPE_MENTIONABLE_SELECT => \Discord\Parts\Channel\Message\MentionableSelect::class, \Discord\Builders\Components\Component::TYPE_CHANNEL_SELECT => \Discord\Parts\Channel\Message\ChannelSelect::class, \Discord\Builders\Components\Component::TYPE_SECTION => \Discord\Parts\Channel\Message\Section::class, \Discord\Builders\Components\Component::TYPE_TEXT_DISPLAY => \Discord\Parts\Channel\Message\TextDisplay::class, \Discord\Builders\Components\Component::TYPE_THUMBNAIL => \Discord\Parts\Channel\Message\Thumbnail::class, \Discord\Builders\Components\Component::TYPE_MEDIA_GALLERY => \Discord\Parts\Channel\Message\MediaGallery::class, \Discord\Builders\Components\Component::TYPE_FILE => \Discord\Parts\Channel\Message\File::class, \Discord\Builders\Components\Component::TYPE_SEPARATOR => \Discord\Parts\Channel\Message\Separator::class, \Discord\Builders\Components\Component::TYPE_CONTAINER => \Discord\Parts\Channel\Message\Container::class, ]

Properties

$channel_types

public array<string|int, int>|null $channel_types

List of channel types to include in the channel select component.

$created

Is the part already created in the Discord servers?

public bool $created = false

Whether the part has been created.

$custom_id

public string $custom_id

Developer-defined identifier, max 100 characters

$custom_id

public string $custom_id

Developer-defined identifier for the select menu; max 100 characters.

$default_values

public ExCollectionInterface|array<string|int, DefaultValue>|null $default_values

List of default values for auto-populated select menu components; number of default values must be in the range defined by min_values and max_values.

$disabled

public bool|null $disabled

Whether select menu is disabled (defaults to false).

$id

public string|null $id

32 bit integer used as an optional identifier for component.

$id

public string|null $id

32 bit integer used as an optional identifier for component.

$id

public string|null $id

Optional identifier for component.

$max_values

public int|null $max_values

Maximum number of items that can be chosen (defaults to 1); max 25.

$min_values

public int|null $min_values

Minimum number of items that must be chosen (defaults to 1); min 0, max 25.

$placeholder

public string|null $placeholder

Placeholder text if nothing is selected; max 150 characters.

$scriptData

Custom script data.

Relying on this variable with dynamic caching is discouraged.

public mixed $scriptData

Used for storing custom information, used by end products.

$type

public int $type

The type of the component.

$attributes

The parts attributes.

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

The parts attributes and content.

$discord

The Discord client.

protected Discord $discord

Client.

$fillable

{@inheritDoc}

protected mixed $fillable = ['type', 'id', 'custom_id', 'channel_types', 'placeholder', 'default_values', 'min_values', 'max_values', 'disabled']

$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 = []

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.

__debugInfo()

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

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

__toString()

Converts the part to a string.

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

This function encodes getPublicAttributes into JSON.

Return values
string

A JSON string of attributes.

__unserialize()

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

fetch()

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

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

The part is not fetchable.

Return values
PromiseInterface<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.

Tags
see
self::setAttribute()

getCreatableAttributes()

Returns the attributes needed to create.

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

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>

Note: The order matters for repository tree (top to bottom).

Return values
array<string|int, mixed>

Attributes.

getUpdatableAttributes()

Returns the updatable attributes.

public getUpdatableAttributes() : array<string|int, mixed>
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
Part::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

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.

Attributes
#[ReturnTypeWillChange]

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.

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

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

The attribute key.

serialize()

Serializes the data. Used for Serializable.

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

A string of serialized data.

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.

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void

makeOptionalAttributes()

Return key-value attributes if it has been filled.

protected makeOptionalAttributes(array<string|int, mixed> $attributes) : array<string|int, mixed>

To be used with fields marked "optional?" from the API.

Parameters
$attributes : array<string|int, mixed>

Names of optional attribute

Return values
array<string|int, mixed>

checkForGetMutator()

Checks if there is a get mutator present.

private checkForGetMutator(string $key) : string|false
Parameters
$key : string

The attribute name to check.

Tags
since
10.0.0

Replaces checkForMutator($key, 'get')

Return values
string|false

Either a string if it is a method or false.

checkForSetMutator()

Checks if there is a set mutator present.

private checkForSetMutator(string $key) : string|false
Parameters
$key : string

The attribute name to check.

Tags
since
10.0.0

Replaces checkForMutator($key, 'set')

Return values
string|false

Either a string if it is a method 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.

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

        
On this page

Search results