Buttons#
SButton#
after_resp: Optional[Dict]
property
#
It's a property used to get a dictionary of options which are to be changed after button click
Returns:
Name | Type | Description |
---|---|---|
UpdatedOptions |
Optional[Dict]
|
Dict if there is a query defined or else returns None |
args: Dict
property
#
It's a property used to get kwargs of the button
- Aliases: ['args', 'kwargs']
Returns:
Name | Type | Description |
---|---|---|
Options |
Dict
|
Dictionary of options of a Button |
author: Optional[discord.Member]
property
#
It's a property used to get author of the button
Returns:
Name | Type | Description |
---|---|---|
author |
Optional[discord.Member]
|
returns a user obj if one exists |
hidden: bool
property
#
It's a property used to get hidden parm of the button
Returns:
Name | Type | Description |
---|---|---|
hidden |
bool
|
id: Optional[str]
property
#
It's a property used to get ID of the button
Returns:
Name | Type | Description |
---|---|---|
custom_id |
Optional[str]
|
Button ID |
is_ephemeral: bool
property
#
It's a property used to check whether it's ephemeral or not
Returns:
Name | Type | Description |
---|---|---|
ephemeral |
bool
|
true, if the button response type is ephemeral or else false |
name: Optional[str]
property
#
It's a property used to get label of the button
Returns:
Name | Type | Description |
---|---|---|
label |
Optional[str]
|
Label (or) emoji of the Button |
__init__(*, label=None, custom_id=None, disabled=False, style=ButtonStyle.secondary, url=None, emoji=None, row=None, content=None, response=None, rewrite=False, ephemeral=False, delete_msg=False, hidden=False, author=None, verify=True)
#
It is a decorator used to create a Button overwriting ui.Button
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
Label of the Button |
None
|
custom_id |
Optional[str]
|
Unique ID of the Button |
None
|
disabled |
bool
|
It is used to enable/disable the Button, i.e. Preventing user from using it |
False
|
style |
ButtonStyle
|
Color of the Button |
ButtonStyle.secondary
|
url |
Optional[str]
|
Onclick Redirects to the given url |
None
|
emoji |
Optional[Union[str, discord.Emoji, discord.PartialEmoji]]
|
Emoji for the Button |
None
|
row |
Optional[int]
|
Places the Button in given Row |
None
|
content |
Optional[str]
|
content of the message |
None
|
response |
Optional[Union[str, discord.Embed]]
|
Sends the message (str/ embed) in user channel |
None
|
rewrite |
bool
|
It is used to send the message by editing the original message rather than sending a new one |
False
|
ephemeral |
bool
|
It is used to send the message where it's only visible to interacted user or to all |
False
|
delete_msg |
bool
|
Deletes the original message |
False
|
hidden |
bool
|
It hides the Button from View |
False
|
author |
discord.Member
|
Interaction User |
None
|
verify |
bool
|
It is used to make the func to check for author parameter or not |
True
|
add_coro_func(function, *args, **kwargs)
async
#
It's an asynchronous function which stores same function type and adds the func to button for execution after getting clicked
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
Callable
|
takes asynchronous function |
required |
*args |
Any
|
takes args of the function provided by a user |
()
|
**kwargs |
Any
|
takes kwargs of the function provided by a user |
{}
|
add_func(function, *args, **kwargs)
#
It's a function which stores same function type and adds the func to button for execution after getting clicked
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
Callable
|
takes a function |
required |
*args |
Any
|
takes args of the function provided by a user |
()
|
**kwargs |
Any
|
takes kwargs of the function provided by a user |
{}
|
after_response(**options)
#
It's an event type function which changes the provided options after button ( onclick )
options are same as those in SButton
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**options |
Any
|
takes Button options |
{}
|
Raises:
Type | Description |
---|---|
ButtonException
|
raises the exception if the option is invalid |
has_any_role(*roles, error_msg=None)
#
It's used to check whether the interaction user has any one of the mentioned roles of interaction guild
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles |
Union[int, str]
|
Takes either ID's or Name's of the roles of interaction guild |
()
|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the user (Interaction.User) if the condition not satisfies |
None
|
has_permissions(*, error_msg=None, **perms)
#
It's used to check whether the interaction user has the mentioned permissions of the interaction guild/ channel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the interaction user if the condition not satisfies |
None
|
**perms |
Any
|
Takes the permissions flags |
{}
|
has_roles(*roles, error_msg=None)
#
It's used to check whether the interaction user has the mentioned roles of interaction guild
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles |
Union[int, str]
|
Takes either ID's or Name's of the roles of interaction guild |
()
|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the user (Interaction.User) if the condition not satisfies |
None
|
is_any_user(*users, error_msg=None)
#
It's used to check whether the interaction user is in mentioned users or not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*users |
Union[str, int]
|
Takes either ID's or Name's of the members of interaction guild |
()
|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the interaction user if the condition not satisfies |
None
|
is_author(error_msg=None)
#
It's used to check whether the Interaction.user
and SButton.author
are same or not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the interaction user if the condition not satisfies |
None
|
is_owner(error_msg=None)
#
It's used to check whether the interaction user is the owner of interaction guild
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error_msg |
Union[str, discord.Embed]
|
Sends a message to the user (Interaction.User) if the condition not satisfies |
None
|
update(**options)
#
Updates the options of the Button
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**options |
Any
|
takes Button options |
{}
|
Raises:
Type | Description |
---|---|
ButtonException
|
raises the exception if the option is invalid |
update_one(details, option)
#
Updates the option of the Button
Parameters:
Name | Type | Description | Default |
---|---|---|---|
details |
Any
|
Takes any datatype for updating |
required |
option |
str
|
The option which should be overwritten |
required |
Raises:
Type | Description |
---|---|
ButtonException
|
raises the exception if the option is invalid |
Types of Buttons#
here are some examples
DuoButton
#
MultiButton
#
__init__(author, buttons, /, timeout=DEFAULT_TIMEOUT)
#
Responsive Buttons
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author |
discord.Member
|
Interaction User |
required |
buttons |
List[SButton]
|
Takes Button Type SButton |
required |
timeout |
Optional[float]
|
Interaction Timeout |
DEFAULT_TIMEOUT
|
view()
#
Returns:
Name | Type | Description |
---|---|---|
view |
ui.View
|
discord.ui.View |
QuartetButton
#
__init__(author, button1, button2, button3, button4, /, timeout=DEFAULT_TIMEOUT)
#
Responsive Buttons
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author |
discord.Member
|
Interaction User |
required |
button1 |
SButton
|
Takes Button Type SButton |
required |
button2 |
SButton
|
Takes Button Type SButton |
required |
button3 |
SButton
|
Takes Button Type SButton |
required |
button4 |
SButton
|
Takes Button Type SButton |
required |
timeout |
Optional[float]
|
Interaction Timeout |
DEFAULT_TIMEOUT
|
view()
#
Returns:
Name | Type | Description |
---|---|---|
view |
ui.View
|
discord.ui.View |
QuintetButton
#
__init__(author, button1, button2, button3, button4, button5, /, timeout=DEFAULT_TIMEOUT)
#
Responsive Buttons
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author |
discord.Member
|
Interaction User |
required |
button1 |
SButton
|
Takes Button Type SButton |
required |
button2 |
SButton
|
Takes Button Type SButton |
required |
button3 |
SButton
|
Takes Button Type SButton |
required |
button4 |
SButton
|
Takes Button Type SButton |
required |
button5 |
SButton
|
Takes Button Type SButton |
required |
timeout |
Optional[float]
|
Interaction Timeout |
DEFAULT_TIMEOUT
|
view()
#
Returns:
Name | Type | Description |
---|---|---|
view |
ui.View
|
discord.ui.View |
SingleButton
#
__init__(author, button1, /, timeout=DEFAULT_TIMEOUT)
#
Responsive Button
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author |
discord.Member
|
Interaction User |
required |
button1 |
SButton
|
Takes Button Type SButton |
required |
timeout |
Optional[float]
|
Interaction Timeout |
DEFAULT_TIMEOUT
|
view()
#
Returns:
Name | Type | Description |
---|---|---|
view |
ui.View
|
discord.ui.View |
TrioButton
#
__init__(author, button1, button2, button3, /, timeout=DEFAULT_TIMEOUT)
#
Responsive Buttons
Parameters:
Name | Type | Description | Default |
---|---|---|---|
author |
discord.Member
|
Interaction User |
required |
button1 |
SButton
|
Takes Button Type SButton |
required |
button2 |
SButton
|
Takes Button Type SButton |
required |
button3 |
SButton
|
Takes Button Type SButton |
required |
timeout |
Optional[float]
|
Interaction Timeout |
DEFAULT_TIMEOUT
|
view()
#
Returns:
Name | Type | Description |
---|---|---|
view |
ui.View
|
discord.ui.View |