discord.zarena
– application commands¶
New in version 2.0.0.
slash_command(**kwargs)
¶
Defines a function as a slash-type application command.
Parameters:
name:
str
The display name of the command. If unspecified, will use the functions name.
guild_id:
Optional[int]
The guild ID this command will belong to. If unspecified, the command will be uploaded globally.
description:
str
The description of the command. If unspecified, will use the functions docstring, or “No description provided” otherwise.
message_command(**kwargs)
¶
Defines a function as a message-type application command.
Parameters:
name:
str
The display name of the command. If unspecified, will use the functions name.
guild_id:
Optional[int]
The guild ID this command will belong to. If unspecified, the command will be uploaded globally.
user_command(**kwargs)
¶
Defines a function as a user-type application command.
Parameters:
name:
str
The display name of the command. If unspecified, will use the functions name.
guild_id:
Optional[int]
The guild ID this command will belong to. If unspecified, the command will be uploaded globally.
describe(**kwargs: str)
¶
Sets the description for the specified parameters of the slash command. Sample usage:
@zarena.slash_command()
@describe(channel="The channel to ping")
async def mention(self, ctx: zarena.Context, channel: discord.TextChannel):
await ctx.send(f'{channel.mention}')
If this decorator is not used, parameter descriptions will be set to “No description provided.” instead.
class Range(min: NumT | None, max: NumT)
¶
Defines a minimum and maximum value for float or int values. The minimum value is optional.
async def number(self, ctx, num: zarena.Range[0, 10], other_num: zarena.Range[10]):
...
class Bot(command_prefix, help_command=<default-help-command>, description=None, **options)
¶
None
Methods:
get_application_command(self, name: str)
Gets and returns an application command by the given name.
Parameters:
name:
str
The name of the command.
Returns:
-
The relevant command object
None
No command by that name was found.
ㅤ
async delete_all_commands(self, guild_id: int | None = None)
Deletes all commands on the specified guild, or all global commands if no guild id was given.
Parameters:
guild_id:
Optional[str]
The guild ID to delete from, or
None
to delete global commands.
ㅤ
async delete_command(self, id: int, guild_id: int | None = None)
Deletes a command with the specified ID. The ID is a snowflake, not the name of the command.
Parameters:
id:
int
The ID of the command to delete.
guild_id:
Optional[str]
The guild ID to delete from, or
None
to delete a global command.
ㅤ
async sync_commands(self)
Uploads all commands from cogs found and syncs them with discord. Global commands will take up to an hour to update. Guild specific commands will update immediately.
class Context(bot: BotT, command: Command[CogT], interaction: discord.Interaction)
¶
The command interaction context.
Attributes
bot:
zarena.Bot
Your bot object.
command: Union[
SlashCommand
,UserCommand
,MessageCommand
]The command used with this interaction.
interaction:
discord.Interaction
The interaction tied to this context.
Methods:
async send(self, content=..., **kwargs)
Responds to the given interaction. If you have responded already, this will use the follow-up webhook instead.
Parameters embed
and embeds
cannot be specified together.
Parameters file
and files
cannot be specified together.
Parameters:
content:
str
The content of the message to respond with
embed:
discord.Embed
An embed to send with the message. Incompatible with
embeds
.
embeds:
List[discord.Embed]
A list of embeds to send with the message. Incompatible with
embed
.
file:
discord.File
A file to send with the message. Incompatible with
files
.
files:
List[discord.File]
A list of files to send with the message. Incompatible with
file
.
ephemeral:
bool
Whether the message should be ephemeral (only visible to the interaction user).
Returns
discord.InteractionMessage
if this is the first time responding.discord.WebhookMessage
for consecutive responses.property cog(self)
The cog this command belongs to.
property guild(self)
The guild this interaction was executed in.
property message(self)
The message that executed this interaction.
property channel(self)
The channel the interaction was executed in.
property author(self)
The user that executed this interaction.
class ApplicationCog(*args: Any, **kwargs: Any)
¶
The cog that must be used for application commands.
Attributes:
bot:
zarena.Bot
The bot instance.