我正在尝试执行一个命令,当用户指定的时间内没有消息发送时,bot会发送一个随机主题,但是,我似乎无法正确把握时间
我的问题是:如何检查X分钟内是否没有消息在通道中发送? 下面是我想出的代码:
@bot.command()
async def timedtopic(ctx, time : int):
global keepLooping
timer = dt.datetime.utcnow() + dt.timedelta(seconds=time)
keepLooping = True
embed = discord.Embed(title="Reviver's topic is", description=(random.choice(List)))
await asyncio.sleep(time)
while keepLooping:
if timer > ctx.channel.last_message.created_at and ctx.channel.last_message.author != bot.user:
await ctx.send(embed=embed)
试试这个
相关问题 更多 >
编程相关推荐