Python Discord.py如何使用Discord.ext.commands禁用命令
我想禁用一个命令,但我不知道它是如何工作的 这是我要禁用的命令Python Discord.py如何使用Discord.ext.commands禁用命令,python,discord,discord.py,Python,Discord,Discord.py,我想禁用一个命令,但我不知道它是如何工作的 这是我要禁用的命令 @client.command(description="Sends an random gif", aliases=['gifje', 'GIF', 'Gif'], brief="Sends an random gif (NO NSFW)") discord.ext.commands.Command(name="gif", cls=None, enabled=False) #@commands.cooldown(1, 10, co
@client.command(description="Sends an random gif", aliases=['gifje', 'GIF', 'Gif'], brief="Sends an random gif (NO NSFW)")
discord.ext.commands.Command(name="gif", cls=None, enabled=False)
#@commands.cooldown(1, 10, commands.BucketType.user)
async def gif(ctx):
links = ["https://gph.is/1N1s5AR",
"https://gph.is/2nmNhuw",
"https://gph.is/g/ajWp6mj",
"https://gph.is/g/apbGw0O",
"https://gph.is/g/Z5YMP9Q",
"https://gph.is/g/aQOvqQ5",
"https://gph.is/g/ajW9Nx8",
"https://gph.is/2CF8W7r",
"http://gph.is/17GL4ua",
"https://gph.is/12kQg0y"]
await ctx.send(random.choice(links))
我相信我必须使用discord.ext.commands来完成,但我不知道如何(我不想使用cogs)
客户端。删除命令(名称)
您可以创建一个运行此命令的命令,该命令将不可用,直到添加回或重新启动bot
.update(enabled=False)
您可以通过查找要查找的命令来获取对象。找到正确的命令对象后,可以使用其方法编辑属性
将此属性设置为
False
将导致在调用命令时引发错误,您可以按照自己的意愿处理该错误。我知道remove命令,但我希望将其禁用,以便轻松生成disabledcommand错误。您可以通过在命令上调用update
来更新命令的属性。这样,您可以将enabled
属性设置为False,然后引发错误。