discord_slash.model module
- class discord_slash.model.ChoiceData(name, value)
Bases:
object
Command choice data object
- Variables
name – Name of the choice, this is what the user will see
value – Values of the choice, this is what discord will return to you
- class discord_slash.model.OptionData(name, description, required=False, choices=None, options=None, **kwargs)
Bases:
object
Command option data object
- Variables
name – Name of the option.
description – Description of the option.
required – If the option is required.
choices – A list of
ChoiceData
, cannot be present on subcommand groupsoptions – List of
OptionData
, this will be present if it’s a subcommand group
- class discord_slash.model.CommandData(name, description, options=None, default_permission=True, id=None, application_id=None, version=None, **kwargs)
Bases:
object
Slash command data object
- Variables
name – Name of the command.
description – Description of the command.
default_permission – Indicates whether users should have permissions to run this command by default.
options – List of
OptionData
.id – Command id, this is received from discord so may not be present
application_id – The application id of the bot, required only when the application id and bot id are different. (old bots)
- class discord_slash.model.CommandObject(name, cmd)
Bases:
object
Slash command object of this extension.
Warning
Do not manually init this model.
- Variables
name – Name of the command.
func – The coroutine of the command.
description – Description of the command.
allowed_guild_ids – List of the allowed guild id.
options – List of the option of the command. Used for auto_register.
connector – Kwargs connector of the command.
__commands_checks__ – Check of the command.
- async invoke(*args)
Invokes the command.
- Parameters
args – Args for the command.
- Raises
.error.CheckFailure
- add_check(func)
Adds check to the command.
- Parameters
func – Any callable. Coroutines are supported.
- remove_check(func)
Removes check to the command.
Note
If the function is not found at the command check, it will ignore.
- Parameters
func – Any callable. Coroutines are supported.
- class discord_slash.model.BaseCommandObject(name, cmd)
Bases:
discord_slash.model.CommandObject
BaseCommand object of this extension.
Note
This model inherits
model.CommandObject
, so this has every variables from that.Warning
Do not manually init this model.
- Variables
has_subcommands – Indicates whether this base command has subcommands.
default_permission – Indicates whether users should have permissions to run this command by default.
permissions – Permissions to restrict use of this command.
- add_check(func)
Adds check to the command.
- Parameters
func – Any callable. Coroutines are supported.
- async can_run(ctx) bool
Whether the command can be run.
- Parameters
ctx (.context.SlashContext) – SlashContext for the check running.
- Returns
bool
- async invoke(*args)
Invokes the command.
- Parameters
args – Args for the command.
- Raises
.error.CheckFailure
- remove_check(func)
Removes check to the command.
Note
If the function is not found at the command check, it will ignore.
- Parameters
func – Any callable. Coroutines are supported.
- class discord_slash.model.SubcommandObject(sub, base, name, sub_group=None)
Bases:
discord_slash.model.CommandObject
Subcommand object of this extension.
Note
This model inherits
model.CommandObject
, so this has every variables from that.Warning
Do not manually init this model.
- Variables
base – Name of the base slash command.
subcommand_group – Name of the subcommand group.
None
if not exist.base_description – Description of the base command.
subcommand_group_description – Description of the subcommand_group.
- add_check(func)
Adds check to the command.
- Parameters
func – Any callable. Coroutines are supported.
- async can_run(ctx) bool
Whether the command can be run.
- Parameters
ctx (.context.SlashContext) – SlashContext for the check running.
- Returns
bool
- async invoke(*args)
Invokes the command.
- Parameters
args – Args for the command.
- Raises
.error.CheckFailure
- remove_check(func)
Removes check to the command.
Note
If the function is not found at the command check, it will ignore.
- Parameters
func – Any callable. Coroutines are supported.
- class discord_slash.model.CogBaseCommandObject(*args)
Bases:
discord_slash.model.BaseCommandObject
Slash command object but for Cog.
Warning
Do not manually init this model.
- async invoke(*args, **kwargs)
Invokes the command.
- Parameters
args – Args for the command.
- Raises
.error.CheckFailure
- add_check(func)
Adds check to the command.
- Parameters
func – Any callable. Coroutines are supported.
- async can_run(ctx) bool
Whether the command can be run.
- Parameters
ctx (.context.SlashContext) – SlashContext for the check running.
- Returns
bool
- remove_check(func)
Removes check to the command.
Note
If the function is not found at the command check, it will ignore.
- Parameters
func – Any callable. Coroutines are supported.
- class discord_slash.model.CogSubcommandObject(base, cmd, sub_group, name, sub)
Bases:
discord_slash.model.SubcommandObject
Subcommand object but for Cog.
Warning
Do not manually init this model.
- async invoke(*args, **kwargs)
Invokes the command.
- Parameters
args – Args for the command.
- Raises
.error.CheckFailure
- add_check(func)
Adds check to the command.
- Parameters
func – Any callable. Coroutines are supported.
- async can_run(ctx) bool
Whether the command can be run.
- Parameters
ctx (.context.SlashContext) – SlashContext for the check running.
- Returns
bool
- remove_check(func)
Removes check to the command.
Note
If the function is not found at the command check, it will ignore.
- Parameters
func – Any callable. Coroutines are supported.
- class discord_slash.model.SlashCommandOptionType(value)
Bases:
enum.IntEnum
Equivalent of ApplicationCommandOptionType in the Discord API.
- SUB_COMMAND = 1
- SUB_COMMAND_GROUP = 2
- STRING = 3
- INTEGER = 4
- BOOLEAN = 5
- USER = 6
- CHANNEL = 7
- ROLE = 8
- classmethod from_type(t: type)
Get a specific SlashCommandOptionType from a type (or object).
- Parameters
t – The type or object to get a SlashCommandOptionType for.
- Returns
model.SlashCommandOptionType
orNone
- class discord_slash.model.SlashMessage(*, state, channel, data, _http: discord_slash.http.SlashCommandRequest, interaction_token)
Bases:
discord.message.Message
discord.py’s
discord.Message
but overriddenedit
anddelete
to work for slash command.- async edit(**fields)
Refer
discord.Message.edit()
.
- async delete(*, delay=None)
Refer
discord.Message.delete()
.
- class discord_slash.model.PermissionData(id, type, permission, **kwargs)
Bases:
object
Single slash permission data.
- Variables
id – User or role id, based on following type specfic.
type – The
SlashCommandPermissionsType
type of this permission.permission – State of permission.
True
to allow,False
to disallow.
- class discord_slash.model.GuildPermissionsData(id, guild_id, permissions, **kwargs)
Bases:
object
Slash permissions data for a command in a guild.
- Variables
id – Command id, provided by discord.
guild_id – Guild id that the permissions are in.
permissions – List of permissions dict.
- class discord_slash.model.SlashCommandPermissionType(value)
Bases:
enum.IntEnum
Equivalent of ApplicationCommandPermissionType in the Discord API.
- ROLE = 1
- USER = 2