pibot package

Subpackages

Submodules

pibot.bot module

The custom bot class for PiBot.

class pibot.bot.Bot(*args, **kwargs)

Bases: Bot

The custom bot class for PiBot.

async load_cogs() None

Load all cogs.

async on_guild_available(guild: Guild) None

When a guild becomes available.

async on_guild_join(guild: Guild) None

When the bot joins a guild.

async on_guild_remove(guild: Guild) None

When the bot leaves a guild.

async on_message(message: Message, /) None

When a message is sent.

async on_ready() None

When the bot is ready.

async setup_hook() None

Set up the hooks for the bot.

async sync_commands() None

Sync the app commands with Discord (see commandSyncBehavior).

property version: str

Return the bot version from package metadata.

pibot.bot.getVersion() str

Return the bot version from package metadata (pyproject.toml).

pibot.database module

Custom database class for the application.

class pibot.database.Database(client: MongoClient)

Bases: object

Custom database class for the application.

async check_if_guild_exists_else_initialize(guild: Guild)

Check if a guild exists in the database. If not, add it.

Parameters:

guild – The guild to check.

async get_prefix(message: Message)

Get the prefix for a guild.

Parameters:
  • _ – The bot.

  • message – The message including guild info to get the prefix for.

Returns:

The prefix.

async get_setting(guild: Guild, setting: str)

Get a setting for a guild.

Parameters:
  • guild – The guild to get the setting for.

  • setting – The key for the setting to get.

Returns:

The value of the setting.

async initialize_guild(guild: Guild)

Initialize a guild in the database.

Parameters:

guild – The guild to initialize.

async remove_guild(guild: Guild)

Remove a guild from the database.

Parameters:

guild – The guild to remove.

async set_setting(guild: Guild, setting: str, value)

Set a setting for a guild.

Parameters:
  • guild – The guild to set the setting for.

  • setting – The key for the setting to set.

  • value – The value to set the setting to.

pibot.errors module

Custom errors for the bot.

exception pibot.errors.BotNotConnectedToVoice

Bases: AppCommandError

Raised when the bot is not connected to a voice channel.

exception pibot.errors.BotNotPlayingAudio

Bases: AppCommandError

Raised when the bot is not playing anything.

exception pibot.errors.UserNotConnectedToVoice

Bases: AppCommandError

Raised when a user is not connected to a voice channel.

Module contents

PiBot Discord Bot Package.

pibot.run() None

Entry point for the CLI.