-
class Foo(commands.Cog):
cmds = set()
def deco(cmd, cmds=cmds):
cmds.add(cmd)
return cmd
def cog_check(self, ctx):
return ctx.command in self.cmds
@deco
@commands.command()
async def allowed(self, ctx):
await ctx.send('allowed')
@commands.command()
async def denied(self, ctx):
await ctx.send('illegal') neither of these commands run. why is that? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
For now I will use |
Beta Was this translation helpful? Give feedback.
-
Commands in cogs undergo copy operations to allow multiple cog instances to have separate command instances. Comparison between instances is generally not allowed (evident by the fact there's no |
Beta Was this translation helpful? Give feedback.
Commands in cogs undergo copy operations to allow multiple cog instances to have separate command instances.
Comparison between instances is generally not allowed (evident by the fact there's no
__eq__
or even__hash__
) -- usingCommand.qualified_name
is the proper solution here.