ChannelSelect
extends SelectMenu
in package
Select menu for channels.
Tags
Table of Contents
- TYPE_ACTION_ROW = 1
- TYPE_BUTTON = 2
- TYPE_CHANNEL_SELECT = 8
- TYPE_MENTIONABLE_SELECT = 7
- TYPE_ROLE_SELECT = 6
- TYPE_SELECT_MENU = 3
- TYPE_STRING_SELECT = 3
- TYPE_TEXT_INPUT = 4
- TYPE_USER_SELECT = 5
- $channel_types : array<string|int, int>
- List of channel types to include.
- $custom_id : string
- Custom ID to identify the select menu.
- $disabled : bool|null
- Whether the select menu should be disabled.
- $discord : Discord|null
- Discord instance when the listener is set.
- $listener : callable|null
- Callback used to listen for `INTERACTION_CREATE` events.
- $max_values : int|null
- Maximum number of options that must be selected.
- $min_values : int|null
- Minimum number of options that must be selected.
- $placeholder : string|null
- Placeholder string to display if nothing is selected. Maximum 150 characters.
- $type : int
- Component type.
- __construct() : mixed
- Creates a new select menu.
- getChannelTypes() : array<string|int, mixed>
- Returns the array of channel types that the select menu has.
- getCustomId() : string
- Returns the Custom ID of the select menu.
- getMaxValues() : int|null
- Returns the maximum number of options that must be selected.
- getMinValues() : int|null
- Returns the minimum number of options that must be selected.
- getPlaceholder() : string|null
- Returns the placeholder string of the select menu.
- isDisabled() : bool|null
- Returns wether the select menu is disabled.
- jsonSerialize() : array<string|int, mixed>
- {@inheritDoc}
- new() : static
- Creates a new select menu.
- removeListener() : $this
- Removes the listener from the button.
- setChannelTypes() : $this
- Set the channel types of the select menu.
- setCustomId() : $this
- Sets the custom ID for the select menu.
- setDisabled() : $this
- Sets the select menus disabled state.
- setListener() : $this
- Sets the callable listener for the select menu. The `$callback` function will be called when the selection of the menu is changed.
- setMaxValues() : $this
- Sets the maximum number of options which must be chosen.
- setMinValues() : $this
- Sets the minimum number of options which must be chosen.
- setPlaceholder() : $this
- Sets the placeholder string to display if nothing is selected.
- generateUuid() : string
- Generates a UUID which can be used for component custom IDs.
Constants
TYPE_ACTION_ROW
public
mixed
TYPE_ACTION_ROW
= 1
TYPE_BUTTON
public
mixed
TYPE_BUTTON
= 2
TYPE_CHANNEL_SELECT
public
mixed
TYPE_CHANNEL_SELECT
= 8
TYPE_MENTIONABLE_SELECT
public
mixed
TYPE_MENTIONABLE_SELECT
= 7
TYPE_ROLE_SELECT
public
mixed
TYPE_ROLE_SELECT
= 6
TYPE_SELECT_MENU
public
mixed
TYPE_SELECT_MENU
= 3
Tags
TYPE_STRING_SELECT
public
mixed
TYPE_STRING_SELECT
= 3
TYPE_TEXT_INPUT
public
mixed
TYPE_TEXT_INPUT
= 4
TYPE_USER_SELECT
public
mixed
TYPE_USER_SELECT
= 5
Properties
$channel_types
List of channel types to include.
protected
array<string|int, int>
$channel_types
= []
$custom_id
Custom ID to identify the select menu.
protected
string
$custom_id
$disabled
Whether the select menu should be disabled.
protected
bool|null
$disabled
$discord
Discord instance when the listener is set.
protected
Discord|null
$discord
$listener
Callback used to listen for `INTERACTION_CREATE` events.
protected
callable|null
$listener
$max_values
Maximum number of options that must be selected.
protected
int|null
$max_values
Default 1, maximum 25.
$min_values
Minimum number of options that must be selected.
protected
int|null
$min_values
Default 1, minimum 0, maximum 25.
$placeholder
Placeholder string to display if nothing is selected. Maximum 150 characters.
protected
string|null
$placeholder
$type
Component type.
protected
int
$type
= \Discord\Builders\Components\Component::TYPE_CHANNEL_SELECT
Methods
__construct()
Creates a new select menu.
public
__construct(string|null $custom_id) : mixed
Parameters
- $custom_id : string|null
-
The custom ID of the select menu. If not given, an UUID will be used
Return values
mixed —getChannelTypes()
Returns the array of channel types that the select menu has.
public
getChannelTypes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getCustomId()
Returns the Custom ID of the select menu.
public
getCustomId() : string
Return values
string —getMaxValues()
Returns the maximum number of options that must be selected.
public
getMaxValues() : int|null
Return values
int|null —getMinValues()
Returns the minimum number of options that must be selected.
public
getMinValues() : int|null
Return values
int|null —getPlaceholder()
Returns the placeholder string of the select menu.
public
getPlaceholder() : string|null
Return values
string|null —isDisabled()
Returns wether the select menu is disabled.
public
isDisabled() : bool|null
Return values
bool|null —jsonSerialize()
{@inheritDoc}
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —new()
Creates a new select menu.
public
static new([string|null $custom_id = null ]) : static
Parameters
- $custom_id : string|null = null
-
The custom ID of the select menu.
Return values
static —removeListener()
Removes the listener from the button.
public
removeListener() : $this
Return values
$this —setChannelTypes()
Set the channel types of the select menu.
public
setChannelTypes(array<string|int, int> $channel_types) : $this
Parameters
- $channel_types : array<string|int, int>
-
Array of channel types.
Return values
$this —setCustomId()
Sets the custom ID for the select menu.
public
setCustomId(string $custom_id) : $this
Parameters
- $custom_id : string
Tags
Return values
$this —setDisabled()
Sets the select menus disabled state.
public
setDisabled([bool $disabled = true ]) : $this
Parameters
- $disabled : bool = true
Return values
$this —setListener()
Sets the callable listener for the select menu. The `$callback` function will be called when the selection of the menu is changed.
public
setListener(callable $callback, Discord $discord[, bool $oneOff = false ]) : $this
The callback function is called with the Interaction
object as well as
a Collection
of selected options.
If you do not respond to or acknowledge the Interaction
, it will be
acknowledged for you.
Note that if you intend to respond to or acknowledge the interaction
inside a promise, you should return a promise that resolves after you
respond or acknowledge.
The callback will only be called once with the $oneOff
parameter set to
true.
This can be changed to false, and the callback will be called each time
the selection is changed. To remove the listener, you can pass
$callback
as null.
The select menu listener will not persist when the bot restarts.
Parameters
- $callback : callable
-
Callback to call when the selection is changed. Will be called with the interaction object and collection of options.
- $discord : Discord
-
Discord client.
- $oneOff : bool = false
-
Whether the listener should be removed after the selection is changed for the first time.
Tags
Return values
$this —setMaxValues()
Sets the maximum number of options which must be chosen.
public
setMaxValues(int|null $max_values) : $this
Parameters
- $max_values : int|null
-
Default
1
and maximum25
.null
to set as default.
Tags
Return values
$this —setMinValues()
Sets the minimum number of options which must be chosen.
public
setMinValues(int|null $min_values) : $this
Parameters
- $min_values : int|null
-
Default
1
, minimum0
and maximum25
.null
to set as default.
Tags
Return values
$this —setPlaceholder()
Sets the placeholder string to display if nothing is selected.
public
setPlaceholder(string|null $placeholder) : $this
Parameters
- $placeholder : string|null
-
Maximum 150 characters.
null
to clear placeholder.
Tags
Return values
$this —generateUuid()
Generates a UUID which can be used for component custom IDs.
protected
static generateUuid() : string