Botcore#
Useful utilities and tools for Discord bot development.
- class BotBase(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, **kwargs)[source]#
- Bases: - discord.ext.commands.bot.Bot- A sub-class that implements many common features that Python Discord bots use. - __init__(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, **kwargs)[source]#
- Initialise the base bot instance. - Parameters
- guild_id ( - int) – The ID of the guild use for- wait_until_guild_available().
- allowed_roles ( - list) – A list of role IDs that the bot is allowed to mention.
- http_session (aiohttp.ClientSession) – The session to use for the bot. 
- redis_session ( - Optional[- RedisSession]) – The async_rediscache.RedisSession to use for the bot.
- api_client ( - Optional[- APIClient]) – The- botcore.site_api.APIClientinstance to use for the bot.
 
 
 - add_command(command)[source]#
- Add - commandas normal and then add its root aliases to the bot.- Return type
 
 - clear()[source]#
- Not implemented! Re-instantiate the bot instead of attempting to re-use a closed one. - Return type
 
 - async close()[source]#
- Close the Discord connection, and the aiohttp session, connector, statsd client, and resolver. - Return type
 
 - async load_extensions(module)[source]#
- Load all the extensions within the given module and save them to - self.all_extensions.- Return type
 
 - async on_guild_available(guild)[source]#
- Set the internal guild available event when self.guild_id becomes available. - If the cache appears to still be empty (no members, no channels, or no roles), the event will not be set and guild_available_but_cache_empty event will be emitted. - Return type
 
 - Clear the internal guild available event when self.guild_id becomes unavailable. - Return type
 
 - async ping_services()[source]#
- Ping all required services on setup to ensure they are up before starting. - Return type
 
 - remove_command(name)[source]#
- Remove a command/alias as normal and then remove its root aliases from the bot. - Individual root aliases cannot be removed by this function. To remove them, either remove the entire command or manually edit bot.all_commands. 
 - async setup_hook()[source]#
- An async init to startup generic services. - Connects to statsd, and calls - AsyncStatsClient.create_socketand- ping_services().- Return type
 
 - async wait_until_guild_available()[source]#
- Wait until the guild that matches the - guild_idgiven at init is available (and the cache is ready).- The on_ready event is inadequate because it only waits 2 seconds for a GUILD_CREATE gateway event before giving up and thus not populating the cache for unavailable guilds. - Return type