我尝试了多种方法;搜索姓名,使用姓名本身加上#和号码(例如john#5645)和用户id(例如4870410505695869),但似乎没有一个有效。这是我目前的代码:
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if db["responding"]:
options = starter_encouragements
if "encouragements" in db.keys():
options = options + db["encouragements"]
if any(word in msg for word in sad_words):
await message.channel.send(random.choice(options))
@client.event
async def on_message(message):
if message.author == client.user:
if message.author.id == my id:
return
await message.channel.send(random.choice(options))
不要使用多个
on_message
事件。您可以在多个事件中执行任何操作,也可以在一个事件中执行
第二个事件中还有一个逻辑错误:
这么说吧,根据你的问题,我相信这就是你想要的:
这样做的目的是确保只有当消息由ID与您提供的ID匹配的人发送时,才发送随机
encouragement
选项如果这仍然不起作用,请确保将任何其他
on_message
事件也移动到此事件中相关问题 更多 >
编程相关推荐