wop commited on
Commit
c6b9f53
1 Parent(s): 306f828

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import threading
4
  from threading import Event
5
  from typing import Optional
6
 
 
7
  import discord
8
  import gradio as gr
9
  import gradio_client as grc
@@ -22,6 +23,14 @@ async def wait(job):
22
  while not job.done():
23
  await asyncio.sleep(0.2)
24
 
 
 
 
 
 
 
 
 
25
 
26
  def get_client(session: Optional[str] = None) -> grc.Client:
27
  client = grc.Client("https://wop-xxx-opengpt.hf.space/", hf_token=HF_TOKEN)
@@ -44,6 +53,7 @@ bot = commands.Bot(command_prefix="$", intents=intents)
44
 
45
  @bot.event
46
  async def on_ready():
 
47
  print(f"Logged in as {bot.user} (ID: {bot.user.id})")
48
  event.set()
49
  print("------")
 
4
  from threading import Event
5
  from typing import Optional
6
 
7
+ import datetime
8
  import discord
9
  import gradio as gr
10
  import gradio_client as grc
 
23
  while not job.done():
24
  await asyncio.sleep(0.2)
25
 
26
+ @bot.command()
27
+ async def uptime(ctx):
28
+ """Displays the uptime of the bot."""
29
+ delta = datetime.datetime.utcnow() - bot.start_time
30
+ hours, remainder = divmod(int(delta.total_seconds()), 3600)
31
+ minutes, seconds = divmod(remainder, 60)
32
+ days, hours = divmod(hours, 24)
33
+ await ctx.send(f"Uptime: {days} days, {hours} hours, {minutes} minutes, {seconds} seconds")
34
 
35
  def get_client(session: Optional[str] = None) -> grc.Client:
36
  client = grc.Client("https://wop-xxx-opengpt.hf.space/", hf_token=HF_TOKEN)
 
53
 
54
  @bot.event
55
  async def on_ready():
56
+ bot.start_time = datetime.datetime.utcnow()
57
  print(f"Logged in as {bot.user} (ID: {bot.user.id})")
58
  event.set()
59
  print("------")