【发布时间】:2018-11-13 01:03:39
【问题描述】:
只有选定的用户 ID 才应有权使用此命令。如下所示,只有添加到此列表中的用户 ID 才能获得使用该命令的权限。
def is_any_user(ids):
async def predicate(ctx):
return ctx.author.id in ids
return commands.check(predicate)
LIST_OF_ADMINS = [3557657657647676, 36567565756766767, 343657687786435432]
@bot.command(pass_context=True)
@is_any_user(LIST_OF_ADMINS)
async def hello(ctx):
await bot.say("Hello {}".format(ctx.message.author.mention))
【问题讨论】:
-
试试
if ctx.(some_id) in LIST_OF_ADMINS?或者为这些人创建一个新角色 -
@cricket_007 我的机器人安装在许多服务器上,因此它们可以创建角色。所以我需要通过一些使用的 ids 列表来限制一些命令。
标签: python-3.x discord.py