【发布时间】:2020-12-26 12:13:09
【问题描述】:
有没有办法检测用户(而不是机器人本身)何时发送了消息?我了解 on_message 事件允许与预期的命令/响应 (https://discordpy.readthedocs.io/en/latest/api.html) 进行比较,但对于我的项目,没有设置用户响应。这使得机器人每次检测到自己的消息时都会触发。我该如何解决?
【问题讨论】:
标签: python discord.py discord.py-rewrite
有没有办法检测用户(而不是机器人本身)何时发送了消息?我了解 on_message 事件允许与预期的命令/响应 (https://discordpy.readthedocs.io/en/latest/api.html) 进行比较,但对于我的项目,没有设置用户响应。这使得机器人每次检测到自己的消息时都会触发。我该如何解决?
【问题讨论】:
标签: python discord.py discord.py-rewrite
试试这个
client = discord.Client()
@bot.event
async def on_message(message):
if message.author == client.user:
return
#then write the code down here so if the person who send message is bot it wont count
【讨论】: