Basecommand¶
This module contains the Abstract Base Class for Commands. It also has some useful decorators for the commands.
- class Commands[source]¶
The Base command class which serves as the starting point for all commands. Can also be used to enable or disable entire categories.
- Parameters
ctx (
bot.PokeGambler
) – The PokeGambler client.
- property enable: bool¶
Quickly Enable a Commands Category module.
- Returns
True
- Return type
bool
- property disable: bool¶
Quickly Disable a Commands Category module.
- Returns
False
- Return type
bool
- async paginate()[source]¶
Convenience method for conditional pagination.
- Parameters
message (
discord.Message
) – The Message which triggered the command.embeds (List[
discord.Embed
]) – The Embeds to paginate.files (Optional[List[
discord.File
]]) – Optional Files to paginate.content (Optional[str]) – Optional content to include in the message.
- async handle_low_balance()[source]¶
Handles a user with a low balance.
- Parameters
message (
discord.Message
) – The message that triggered the command.user (
discord.Member
) – The user with a low balance.private (Optional[bool]) – Whether to send the message in a DM.
channel (Optional[
discord.TextChannel
]) – The channel to send the message in.embed_content (Optional[str]) – The content to include in the embed.
is_pokebonds (Optional[bool]) – Whether the user has PokeBonds.
- Default private
True
- Default is_pokebonds
False
- async get_profile()[source]¶
Retrieves the Profile for a user (creates for new users). If the user is not found in the guild, returns None.
- Parameters
ctx (
bot.PokeGambler
) – The PokeGambler bot class.message (
discord.Message
) – The message that triggered the command.user (Union[int, str,
discord.Member
]) – The user to get the Profile for.
- Returns
The Profile of the user.
- Return type
- get_commands_btn_view()[source]¶
Get a CallbackButtonView for a list of commands.
- Parameters
message (Union[Message, CustomInteraction]) – The message to be used for the CallbackButtonView.
cmds (List[Coroutine]) – The list of commands to be used for the CallbackButtonView.
cmd_kwargs (Optional[List[Dict[str, Any]]]) – The kwargs to be used for the Commands.
- Returns
The CallbackButtonView.
- Return type
Decorators¶
Permissions
- @admin_only[source]¶
Only the admins can access these commands.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @dealer_only[source]¶
Only the dealers can access these commands.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @owner_only[source]¶
Only the owners can access these commands.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @os_only[source]¶
These commands can only run in the official server.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
Decorators without arguments
- @cache_images[source]¶
Cache sent images for a particular user.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @check_completion[source]¶
Checks if a command is already in progress for a user.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @ctx_command[source]¶
Marks a command as a context menu command.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @defer[source]¶
Defers a function to be executed later.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @ensure_item[source]¶
Make sure that the Item with the given ID exists already.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @ensure_user[source]¶
Make sure user ID is given in the command.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @maintenance[source]¶
Disable a broken/wip function to prevent it from affecting rest of the bot.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @no_log[source]¶
Pevents a command from being logged in the DB. Useful for debug related commands.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
- @no_slash[source]¶
Prevents a command from being triggered by a slash.
- Parameters
func (Callable) – The command to be decorated.
- Returns
The decorated function.
- Return type
Callable
Decorators with arguments
- @alias[source]¶
Add an alias to a function.
- Parameters
alt_names (Union[List[str], str]) – The alternative names of the function.
- Returns
The decorated function.
- Return type
Callable
- @autocomplete[source]¶
Add an autocomplete callback dictionary to the command.
- Parameters
callback_dict (Dict[str, Coroutine]) – The callback dictionary.
- Returns
The decorated function.
- Return type
Callable
- @cooldown[source]¶
Add a custom cooldown for a command.
- Parameters
secs (int) – The cooldown in seconds.
- Returns
The decorated function.
- Return type
Callable
- @needs_ticket[source]¶
Checks if user has the tickets in inventory.
- Parameters
name (str) – The name of the ticket.
- Returns
The command which triggered the check.
- Return type
Callable