[英]discord.py certain people execute command
所以我试图发出一个只有我和另一个人可以关闭机器人的注销命令,
trusted = {id, id}
@commands.command()
async def test(self, ctx):
if ctx.author.id in trusted:
await ctx.send(f"{ctx.author.mention} Closing Bot")
await self.bot.close()
else:
await ctx.send("Only (me) and (my friend) can execute this")
出于某种原因,每当我尝试这样做时,它都没有意识到我是受信任的并且不会执行。
您可以检查用户 ID 是否在列表中。 如果作者不在那里,那么它只会跳过他,您可以使用 error_handler 来发送错误。
def me_and_friends(ctx):
trusted = [id, id]
return ctx.author.id in trusted
@commands.command()
@commands.check(me_and_friends)
async def test(self, ctx):
await ctx.send('This is either me or a friend')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.