2024-05-03 06:20:48 发布
网友
我想知道是否有人知道如何使用其他命令禁用Discord.py命令。如果我们必须使用Json之类的东西,这并不重要,我只是想找到一种方法
将command.update()与kwarg enabled一起使用
command.update()
enabled
@bot.command() async def foo(ctx): await ctx.send('whatever') @foo.error async def foo_error(ctx, error): """Simply an error handler""" if isinstance(error, commands.DisabledCommand): await ctx.send('Command is disabled') @bot.command() async def disable_foo(ctx): """Disabled the `foo` command""" foo.update(enabled=False) @bot.command() async def enable_foo(ctx): """Enables the `foo` command""" foo.update(enabled=True)
如果命令被禁用,commands.DisabledCommand将被抛出。 Reference
commands.DisabledCommand
将
command.update()
与kwargenabled
一起使用如果命令被禁用,
commands.DisabledCommand
将被抛出。 Reference相关问题 更多 >
编程相关推荐