Make uptime readable

master
Jan Danielzick 2023-01-21 19:58:24 +00:00
parent b9b2c050c3
commit a22bbdc1c5
1 changed files with 4 additions and 4 deletions

8
bot.py
View File

@ -2,7 +2,7 @@
# Code revised by BodgeMaster # Code revised by BodgeMaster
# Code Licensed under GPL 3.0 # Code Licensed under GPL 3.0
import sys, time, json import sys, time, json, datetime
import discord import discord
from discord import app_commands from discord import app_commands
@ -16,8 +16,8 @@ config_file = open("config.json", "r")
config = json.loads(config_file.read()); config = json.loads(config_file.read());
config_file.close() config_file.close()
def seconds_elapsed(): def uptime():
return int(time.time() - BOOT_TIME) return str(datetime.timedelta(seconds=int(time.time() - BOOT_TIME)))
class MyClient(discord.Client): class MyClient(discord.Client):
@ -101,7 +101,7 @@ async def report_message(interaction: discord.Interaction, message: discord.Mess
@client.tree.command(name="status") @client.tree.command(name="status")
async def status(interaction: discord.Interaction): async def status(interaction: discord.Interaction):
embed = discord.Embed(title='/etc/os-release bot by jocadbz') embed = discord.Embed(title='/etc/os-release bot by jocadbz')
embed.add_field(name="Uptime:", value=seconds_elapsed(), inline=True) embed.add_field(name="Uptime:", value=uptime(), inline=True)
embed.add_field(name="Version:", value=config["bot version"], inline=True) embed.add_field(name="Version:", value=config["bot version"], inline=True)
embed.set_footer(text=config["bot issues"]) embed.set_footer(text=config["bot issues"])
url_view = discord.ui.View() url_view = discord.ui.View()