【问题标题】:How do I make my discord bot show its prefix when I mention it (python) [closed]当我提到它时,如何让我的不和谐机器人显示它的前缀(python)[关闭]
【发布时间】:2021-09-11 12:30:50
【问题描述】:

我希望能够输入“@Hu Tao bot 前缀”,bot 会以当前前缀的内容进行响应,由于某种原因它不起作用,并且它也没有显示错误消息,我当前的前缀是: client = commands.Bot(command_prefix = '-')

【问题讨论】:

  • “由于某种原因它无法正常工作”对我们根本没有帮助,提供您尝试过的代码,以便我们为您提供帮助...

标签: python python-3.x discord discord.py


【解决方案1】:

您可以在活动中使用message.mentions:-

@client.event
async def on_message(message):
  if client.user in message.mentions:
    await message.channel.send("You can type `tnj.help` for help")
  await client.process_commands(message)

【讨论】:

  • 谢谢它的工作,但是,当我输入一些单词然后提到@(机器人)它也会发送前缀。当我只发送提及时,我如何让机器人只发送前缀
  • 您可以在await message.channel.send("anything you want to write") 行中输入您想要发送的任何内容
猜你喜欢
  • 1970-01-01
  • 2021-12-17
  • 2020-06-01
  • 1970-01-01
  • 2020-10-29
  • 2020-09-06
  • 1970-01-01
  • 2021-05-19
  • 2021-08-05
相关资源
最近更新 更多