mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
* Make Requires.verify() wait until rules are loaded Also ensures `Requires` objects are reset when unloaded, particularly in case a `Command` object manages to stay in memory between cog unload and load, and its permissions rules change between those events. Also, this PR re-ordered some of the event loop policy stuff, because it was required that the event loop policy be set before creating any `Requires` objects. This may or may not have an effect on other `get_event_loop()` calls elsewhere (either in our code, a dependency's, or asyncio's). Either way, these effects would be a *correction*, and any bugs that arise from it are likely to have been occurring silently beforehand. Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Remove calls to `remove_listener()` in permissions Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Fix adding rules for permissions cog/commands itself Also addresses feedback Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Clean up indentation when setting uvloop policy Signed-off-by: Toby Harradine <tobyharradine@gmail.com> * Use `set(walk_commands())` to traverse `Group` subcommands Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
13 lines
421 B
Python
13 lines
421 B
Python
from .permissions import Permissions
|
|
|
|
|
|
async def setup(bot):
|
|
cog = Permissions(bot)
|
|
await cog.initialize()
|
|
# We should add the rules for the Permissions cog and its own commands *before* adding the cog.
|
|
# The actual listeners ought to skip the ones we're passing here.
|
|
await cog._on_cog_add(cog)
|
|
for command in cog.__cog_commands__:
|
|
await cog._on_command_add(command)
|
|
bot.add_cog(cog)
|