【发布时间】:2022-02-23 13:58:59
【问题描述】:
看来我的检查不起作用,我相信功能设置正确但我可能错了我应该如何解决这个错误?
@client.command()
@commands.check(is_server_owner)
async def serversetup(guild,ctx):
await guild.create_role(name='safe')
await ctx.send('Please put the safe role above the AntiNuke role so those people will not be punished by the antinuke! | Server is setup!')
这是我遇到的错误
Ignoring exception in command serversetup:
Traceback (most recent call last):
File "/home/runner/AntiNuke/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/AntiNuke/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
await self.prepare(ctx)
File "/home/runner/AntiNuke/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 778, in prepare
raise CheckFailure('The check functions for command {0.qualified_name} failed.'.format(self))
discord.ext.commands.errors.CheckFailure: The check functions for command serversetup failed.
这里是 is_server_owner 函数
def is_server_owner(ctx):
return ctx.message.author.id == ctx.guild.owner
【问题讨论】:
-
不,不是,我在我拥有的服务器上运行它,所以我不知道为什么它会返回 False。
标签: python discord discord.py