2024-03-29 05:46:46 发布
网友
我想制作一个命令来显示两者的正常运行时间,例如Online Time: 1h 10m 15s
Online Time: 1h 10m 15s
您可以在启动bot时节省时间,然后将其与调用命令的时间进行比较
import datetime as dt # after you initialize bot itself bot.launch_time = dt.datetime.utcnow() @bot.command() async def uptime(ctx): delta_uptime = dt.datetime.utcnow() - bot.launch_time hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600) minutes, seconds = divmod(remainder, 60) days, hours = divmod(hours, 24) await ctx.reply(f"Online Time: {days}d, {hours}h, {minutes}m, {seconds}s")
您可以在启动bot时节省时间,然后将其与调用命令的时间进行比较
相关问题 更多 >
编程相关推荐