【问题标题】:Discord selfbot checks for other usersDiscord selfbot 检查其他用户
【发布时间】: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


【解决方案1】:

尝试await ctx.send('Pong!') 而不是ctx.send('Pong!')。此外,您可以删除client = discord.Client(),因为您在下一行为客户端定义了一个新值。

【讨论】:

  • 嗨!感谢您的回答,但这不是我的问题,只是一个错字
猜你喜欢
  • 1970-01-01
  • 2020-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-06
  • 2021-05-30
  • 2020-11-23
  • 2021-01-26
相关资源
最近更新 更多