BaseBot
A subclass of discord.ext.commands.Bot. This bot implement some manage commands errors.
import discord
from discord_slash import SlashCommand
import baseDiscord
mybot = baseDiscord.BaseBot(
token="my token", # token of your bot
prefix="!", # prefix of your bot
color=discord.Colour.blue(), # color embed
color_error=discord.Colour.red(), # color embed for error message
intents=discord.Intents.all() # intents
)
slash = SlashCommand(bot, sync_commands=True) # For slash commands
Parameters
BaseBot.__init__(self, token: str, *args, color: discord.Colour, color_error: discord.Colour, send_errors: bool = False, permissions: int = 0, logger=None, **kwargs)
Parameter
Type
Description
Required
Default
color
Union[discord.Colour, Tuple[R, G, B]]
The main color of Bot (for embeds).
✔️
color_error
Union[discord.Colour, Tuple[R, G, B]]
The color for errors messages (embeds)
✔️
send_errors
bool
If True, the bot send a error message to owner of application for all commands errors not manage
❌
False
logger
logging.Logger
A logger to use in the application. If None
, a default logger in debug level with the class name of bot is used.
❌
None
Attributes
Attributes of discord.ext.commands.Bot
+
Name
Type
Description
color
Union[discord.Colour, Tuple[R, G, B]]
The main color of Bot (for embeds).
color_error
Union[discord.Colour, Tuple[R, G, B]]
The color for errors messages (embeds)
send_errors
bool
If True, the bot send a error message to owner of application for all commands errors not manage
logger
logging.Logger
A logger to use in the application.
avatar_url
str
Avatar URL of bot loaded in on_ready
event
Methods
Methods of discord.ext.commands.Bot
+
messages_on_ready
: messages to display on an on_ready event.Default: display informations on bot (name and id)
async init_on_ready
: asynchrone method to initialize attributes on an on_ready event.Default: initialize
app_info
andavatar_url
attributes
get_invitation
: method to get invitation URL with permissions define bypermissions
attributeParameters
permissions
: int =None
: permission to use, if None, use thepermissions
attribute
Returns
invitation_url
: str : The invitation URL of bot
Methods overwrite
async on_command_error
: manage some commands errors :
Error
Do
commands.errors.CommandNotFound
Ignore this exception
commands.errors.BadArgument
Send an error message to user
MissingRequiredArgument
Send an error message to user
MissingPermissions
Send an error message to user with required permissions
MissingRoles
Send an error message to user with roles required
BotMissingPermissions
Send an error message to user with permissions required
BotMissingRole
Send an error message to user with roles required
Last updated
Was this helpful?