【发布时间】:2020-09-19 13:25:16
【问题描述】:
我一直在研究 Discord 自我机器人,只是为了更好地学习 discord.py,但我遇到了问题,我试图做到这一点,以便如果我列入白名单的其他人将他们的 id 放入 .txt 文件中,他们可以运行命令,我会回复该命令的答案,例如,
有人列入白名单:'+ping'
我:“乒乓!”
这是我当前的代码:
client = discord.Client()
client = commands.Bot(command_prefix='+', self_bot=True,
fetch_offline_members=False)
def checkforuser(ctx):
return ctx.message.author.id == 669311027615105030
@client.command()
@commands.check(checkforuser)
async def ping(ctx):
await ctx.send('Pong!')
它不工作且没有错误,任何帮助将不胜感激:)
【问题讨论】:
-
乍一看,用户似乎必须键入“$pong”才能触发该命令。你能显示更多代码吗?
-
@afic 已修复,添加了更多代码
标签: python discord bots self whitelist