【发布时间】:2021-10-22 21:55:09
【问题描述】:
我希望我的机器人在提到某个用户时做出响应。我只在谷歌上找到了答案的 sn-ps,我不能把它们放在一起。我注意到,如果我调用一个字符串来代替用户 ID,它会起作用,但是如果我在同一条消息中调用带有用户 ID 的字符串,它不会返回任何内容。
感谢您的任何见解,工作如下(当然,将所需的用户 ID 替换为 ):
@client.event
async def on_message(message):
if message.author == client.user:
return
#Making sure it doesn't respond to itself
if "@here" in message.content:
return
if "@everyone" in message.content:
return
#Making sure it doesn't respond to tags including everyone
if '<@user_id>' in message.content:
clock = get_time()
clock = json.dumps(clock, indent=4)
await message.channel.send("The time in Athens is currently: ")
await message.channel.send(clock[-11: -6])
client.run(os.environ['TOKEN'])
【问题讨论】:
标签: discord.py