【发布时间】:2020-10-31 21:12:58
【问题描述】:
我想让我的 Discord 机器人能够告诉用户在他们迟到时去睡觉,我正在这样做:
@client.event
async def on_message(message):
now = datetime.datetime.now()
now_hour = now.hour #Gets current time in hours.
if message.author != client.user and now_hour<6: #Runs if the message is not sent by the bot or if the time is between 00:00 and 06:00
await message.channel.send('Are you still awake? You ought to go to bed immediately!')
await client.process_commands(message) #If not included, on_message() will override commands
但目前它会回复该时间段内的每条消息,这很烦人。我知道命令有冷却时间,但我无法为事件找到类似的东西。
所以我的问题是:是否有相当于事件的冷却时间,或者其他聪明的方法?
在此先感谢,对于我应该犯的新手错误,我们深表歉意。
【问题讨论】:
-
你可能会找到答案here
标签: python discord.py