[英]Discord bot doesnt respond
这是我第一次制作 discord 机器人。 我已经按照教程的每个步骤进行操作,但我的机器人对 .test 命令没有反应。 我确实在 discord 服务器中看到了该机器人。 请帮忙
这是我第一次制作 discord 机器人。 我已经按照教程的每个步骤进行操作,但我的机器人对 .test 命令没有反应。 我确实在 discord 服务器中看到了该机器人。 请帮忙
首先,在第 15 行, if(message.content.startswith(:test):
的 if 语句位于返回之后。机器人永远不会到达这些行。您将不得不将缩进移回(python 中的缩进很烦人)。
if message.author == client.user:
return
if message.content.startswith('!test'):
await message.channel.send("Hello!")
await client.process_commands(message)
其次, await client.process_commands(message)
仅适用于命令客户端,不适用于基础 discord.Client()。 客户必须是类似的东西
from discord.ext import commands
client = commands.Bot(command_prefix="!")
请参阅Bot 和 Client 之间有什么区别? 对于 discord.Client() 和 commands.Bot() 之间的区别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.