PycordBot¶
The bot is based on Pycord's discord.Bot
class and only overrides or extends certain functionality described below.
Bases: Bot
Discord bot based on discord.Bot.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
dict[str, Any]
|
Bot's configuration loaded from the configuration file or passed on initialization. |
bot_locale |
BotLocale
|
Locale management instance with necessary helper methods. |
default_locale |
str
|
Default locale used by the bot. |
locales |
dict[str, Any]
|
Dictionary with locales. Key is the name of the locale and its value is the locale mapping. |
scheduler |
AsyncIOScheduler | BackgroundScheduler | None
|
Scheduler instance passed on initialization based on APScheduler. |
_ |
Callable
|
A shorthand for the |
in_all_locales |
Callable
|
A shorthand for the |
in_every_locale |
Callable
|
A shorthand for the |
__init__(*args, config=None, config_path=Path('config.json'), locales_root=None, scheduler=None, **kwargs)
¶
Initializes PycordBot instance (child of discord.Bot).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
*tuple[Any]
|
Any positional arguments passed to the initialization of |
()
|
config
|
dict[str, Any] | None
|
Bot's configuration. Not needed if |
None
|
config_path
|
str | Path
|
Path bot's configuration file. Not needed if |
Path('config.json')
|
locales_root
|
str | Path | None
|
Path to a directory where locale files are stored. Defaults to |
None
|
scheduler
|
AsyncIOScheduler | BackgroundScheduler | None
|
Scheduler instance to use. Based on APScheduler. Defaults to |
None
|
**kwargs
|
**dict[str, Any]
|
Any keyword arguments passed to the initialization of |
{}
|
close(scheduler_shutdown=True, scheduler_wait=True)
async
¶
Closes the connection to Discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheduler_shutdown
|
bool
|
Whether to shutdown the scheduler (if it is set) right before disconnecting from Discord. Defaults to |
True
|
scheduler_wait
|
bool
|
Whether to wait for the scheduler to finish all tasks before shutting down. Defaults to |
True
|
start(token, reconnect=True, scheduler_start=True)
async
¶
A shorthand coroutine for login + connect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Bot token used to connect to Discord. |
required |
reconnect
|
bool
|
Whether an automatic reconnect should be attempted on lost connection. Defaults to |
True
|
scheduler_start
|
bool
|
Whether to start the scheduler (if it is set) right before connecting do Discord. Defaults to |
True
|
Raises:
| Type | Description |
|---|---|
TypeError
|
An unexpected keyword argument was received. |