RedBase(*args, cli_flags=None, bot_dir: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/red-discordbot/checkouts/3.0.2/docs'), **kwargs)¶
Mixin for the main bot class.
Selfbots should inherit from this mixin along with
Registers a method to act as an RPC handler if the internal RPC server is active.
When calling this method through the RPC server, use the naming scheme “cogname__methodname”.
All parameters to RPC handler methods must be JSON serializable objects. The return value of handler methods must also be JSON serializable.
Parameters: method (coroutine) – The method to register with the internal RPC server.
Unregisters an RPC method handler.
This will be called automatically for you on cog unload and will pass silently if the method is not previously registered.
Parameters: method (coroutine) – The method to unregister from the internal RPC server.
Adds a “cog” to the bot.
A cog is a class that has its own event listeners and commands.
They are meant as a way to organize multiple relevant commands into a singular class that shares some state or no state at all.
The cog can also have a
__global_checkmember function that allows you to define a global check. See
check()for more info. If the name is
__global_check_oncethen it’s equivalent to the
More information will be documented soon.
Parameters: cog – The cog to register to the bot.
Commandor its superclasses into the internal list of commands.
This is usually not called, instead the
group()shortcut decorators are used instead.
command – The command to add.
add_permissions_hook(hook: Callable[Context, Union[bool, None, Awaitable[Optional[bool]]]]) → None¶
Add a permissions hook.
Permissions hooks are check predicates which are called before calling
Requires.verify, and they can optionally return an override:
Falseto deny, and
Noneto default to normal behaviour.
Parameters: hook – A command check predicate which returns
clear_permission_rules(guild_id: Optional[int]) → None¶
Clear all permission overrides in a scope.
Parameters: guild_id (Optional[int]) – The guild ID to wipe permission overrides for. If
None, this will clear all global rules and leave all guild rules untouched.
Disable Sentry logging for Red.
embed_requested(channel, user, command=None) → bool¶
Determine if an embed is requested for a response.
Trueif an embed is requested
Enable Sentry logging for Red.
Checks if a member is an admin of their guild.
is_automod_immune(to_check: Union[discord.message.Message, redbot.core.commands.context.Context, discord.abc.User, discord.role.Role]) → bool¶
Checks if the user, message, context, or role should be considered immune from automated moderation actions.
This will return
Falsein direct messages.
Parameters: to_check (
discord.Role) – Something to check if it would be immune
Return type: bool
Checks if a member is a mod or admin of their guild.
Checks if a
Memberis the owner of this bot.
owner_idis not set, it is fetched automatically through the use of
Parameters: user (
abc.User) – The user to check for.
Lists packages present in the cogs the folder
Loads an extension.
An extension is a python module that contains commands, cogs, or listeners.
An extension must have a global function,
setupdefined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the
name (str) – The extension name to load. It must be dot separated like regular Python imports if accessing a sub-module. e.g.
foo.testif you want to import
ClientException– The extension does not have a setup function.
ImportError– The extension could not be imported.
Removes a cog from the bot.
All registered commands and event listeners that the cog has registered will be removed as well.
If no cog is found then this method has no effect.
If the cog defines a special member function named
__unloadthen it is called when removal has completed. This function cannot be a coroutine. It must be a regular function.
Parameters: name (str) – The name of the cog to remove.
remove_permissions_hook(hook: Callable[Context, Union[bool, None, Awaitable[Optional[bool]]]]) → None¶
Remove a permissions hook.
Parameters are the same as those in
ValueError– If the permissions hook has not been added.
send_filtered(destination: discord.abc.Messageable, filter_mass_mentions=True, filter_invite_links=True, filter_all_links=False, **kwargs)¶
This is a convienience wrapper around
It takes the destination you’d like to send to, which filters to apply (defaults on mass mentions, and invite links) and any other parameters normally accepted by destination.send
This should realistically only be used for responding using user provided input. (unfortunately, including usernames) Manually crafted messages which dont take any user input have no need of this
Unloads an extension.
When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported.
The extension can provide an optional global function,
teardown, to do miscellaneous clean-up if necessary. This function takes a single parameter, the
bot, similar to
Parameters: name (str) – The extension name to unload. It must be dot separated like regular Python imports if accessing a sub-module. e.g.
foo.testif you want to import
verify_permissions_hooks(ctx: redbot.core.commands.context.Context) → Optional[bool]¶
Run permissions hooks.
Parameters: ctx (commands.Context) – The context for the command being invoked. Returns:
Falseif any hooks returned
Trueif any hooks return
Trueand none returned
Return type: Optional[bool]
Red(*args, cli_flags=None, bot_dir: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/red-discordbot/checkouts/3.0.2/docs'), **kwargs)¶
You’re welcome Caleb.
Logs out of Discord and closes all connections.