【问题标题】:Discord bot doesnt respondDiscord 机器人没有响应
【发布时间】:2021-05-25 04:44:49
【问题描述】:
【问题讨论】:
标签:
python
python-3.x
discord
discord.py
【解决方案1】:
首先,在第 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="!")
请参阅What are the differences between Bot and Client? 了解 discord.Client() 和 commands.Bot() 之间的区别。