-
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.
Answered by
Rapptz
Sep 30, 2020
Replies: 2 comments
-
For now I will use |
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.