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

classmethod expire_cache()[source]

Expires all the caches for a user.

Parameters

user_id (int) – The user ID to expire caches for.

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
Returns

The Profile of the user.

Return type

Profiles

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

CallbackButtonView

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

@model[source]

Marks a command with list of Models it is accessing.

Parameters

models (Union[List[Model], Model]) – The models to be accessed.

Returns

The decorated function.

Return type

Callable

@suggest_actions[source]

Suggests actions to be taken when a command fails.

Parameters

commands (List[Tuple[str, str, Optional[Dict[str, Any]]]]) – The commands to be suggested. (Category, Command, Kwargs)

Returns

The decorated function.

Return type

Callable

@override_docs[source]

Overrides the docstring of a command.

Parameters

modifier (Callable[[str], str]) – The function to replace the docstring.

Returns

The decorated function.

Return type

Callable