discord_py_utilities package

Submodules

discord_py_utilities.bans module

async discord_py_utilities.bans.ban_member(bans_class, interaction, user, reason, days=1, inform=False)[source]
Parameters:
  • bans_class

  • interaction

  • user

  • reason

  • days

  • inform

Returns:

async discord_py_utilities.bans.ban_user(interaction: Interaction, user: User, ban_type, reason_modal, ban_class, inform=True, clean=False)[source]
async discord_py_utilities.bans.dm_user(interaction, reason_modal, user)[source]

discord_py_utilities.exceptions module

exception discord_py_utilities.exceptions.NoChannelException(message='No channel set or does not exist, check the config or fill in the required arguments.')[source]

Bases: Exception

Raised when the server does not have a channel set to send a message

exception discord_py_utilities.exceptions.NoPermissionException(required_perms: str | list, channel: TextChannel = None, guild: Guild = None, message='Missing permission to send message: ')[source]

Bases: Exception

Raised when the bot does not have permission to send a message

discord_py_utilities.messages module

async discord_py_utilities.messages.await_message(interaction, message) Message | bool[source]

Wait for a message from the user that triggered the interaction. If the message is ‘cancel’, return False. :param interaction: :param message: :return:

async discord_py_utilities.messages.delete_message(message: Message | Thread)[source]

Delete a message. If the message is not found, return None. If the message is not found, send a message to the channel. :param message: :return:

async discord_py_utilities.messages.fetch_message_or_none(channel: TextChannel | DMChannel | Thread, id: int, wait=0) Message | None[source]

Fetch a message from a channel. If the message is not found, return None. Wait for a specified amount of time before fetching the message; useful for fetching starting message of threads as they often have delays. :param wait: :return: :param channel: :param id: :return:

async discord_py_utilities.messages.handle_no_permission(channel: TextChannel | User | Member, error_mode: str = 'error')[source]

Handles no permission errors within the code based on error_modes: error, warn, ignore. Error: Raises NoPermissionException Warn: Logs a warning message and sends a message to the owner of the guild. Ignore: Does nothing. :param channel: :param error_mode:

async discord_py_utilities.messages.send_message(channel: TextChannel | User | Member, message: str = None, embed=None, view=None, files=None, error_mode: str = 'error') Message[source]

Send a message to a channel, if there is no permission it will send an error message to the owner. Automatically handles messages longer than 2000 characters by splitting them into multiple messages. :param channel: :param message: :param embed: :param view: :param files: :param error_mode: :return:

async discord_py_utilities.messages.send_response(interaction: Interaction, response, ephemeral=False, view=..., embed=..., error_mode='error')[source]

Sends a response to an interaction. If the interaction is already responded, it will send a followup message. :param error_mode: :param interaction: :param response: :param ephemeral: :param view: :param embed: :return:

discord_py_utilities.permissions module

discord_py_utilities.permissions.check_bot_channel_permissions(channel: TextChannel, permissions: str | list[str] = None) list[str][source]

Check if the bot has the required permissions in the channel, if no permissions are specified, it will return all the permissions the bot has in the channel. :param channel: :param permissions: :return:

discord_py_utilities.permissions.check_missing_channel_permissions(channel: TextChannel, permissions: str | list) list[source]

Check which permissions are missing for the bot in the specified channel. :param channel: :param permissions: :return:

discord_py_utilities.permissions.check_missing_guild_permissions(guild: Guild, permissions: str | list[str]) None | list[str][source]

Check if the bot is missing the required permissions in the guild and returns a list with the missing permissions. :param guild: :param permissions:

discord_py_utilities.permissions.get_bot_permissions(guild: Guild) Permissions | dict[source]

Get all the permissions of the bot in the guild. :param guild:

Module contents