【发布时间】:2021-07-11 12:56:41
【问题描述】:
我想知道如何为提醒命令进行时间转换,因此 1s 转换为 1 秒 1m 转换为 1 分钟,1h 转换为 1 小时
@client.command(aliases=["reminder"])
async def remind(ctx, remindertime, *, msg):
seconds=seconds % (24 * 3600)
hour=seconds // 3600
seconds %= 3600
minutes=seconds // 60
seconds %= 60
s=seconds
h=hour
m=minutes
await asyncio.sleep(remindertime)
await ctx.send(f"{ctx.author.mention} You were going to: {msg} and asked me to remind you.")
【问题讨论】:
-
将所有内容转换为秒,在应该使用
datetime执行时将其添加到数据库中,然后如果时间少于 30 分钟,请在同一命令上等待它,然后如果它更长然后每分钟做一个任务,检查时间是否会执行。 -
@FluxedScript,我相信问题是解析参数并将其转换为时间
-
@Ceres 我知道,但我只是给出建议,为什么它是评论而不是答案
标签: discord discord.py