Skip to content

Commit

Permalink
fixed heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCataliasTNT2k committed Apr 2, 2024
1 parent a1af59c commit 2df5d44
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions information/heartbeat/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def __init__(self):
@tasks.loop(seconds=20)
async def status_loop(self):
now = utcnow()
with open(Path("health"), "r") as f:
data = f.readlines()
if data and data[0].strip().isnumeric():
data[0] = str(int(datetime.now().timestamp())) + "\n"
else:
data = [str(int(datetime.now().timestamp())) + "\n"] + data
with open(Path("health"), "w+") as f:
f.writelines(data)
for owner in get_owners(self.bot):
try:
await send_editable_log(
Expand All @@ -38,14 +46,6 @@ async def status_loop(self):
t.heartbeat,
format_dt(now, style="D") + " " + format_dt(now, style="T"),
)
with open(Path("health"), "r") as f:
data = f.readlines()
if data and data[0].strip().isnumeric():
data[0] = str(int(datetime.now().timestamp())) + "\n"
else:
data = [str(int(datetime.now().timestamp())) + "\n"] + data
with open(Path("health"), "w+") as f:
f.writelines(data)

except Forbidden:
pass
Expand All @@ -67,10 +67,9 @@ async def on_ready(self):
except Forbidden:
pass

if owners:
try:
self.status_loop.start()
except RuntimeError:
self.status_loop.restart()
try:
self.status_loop.start()
except RuntimeError:
self.status_loop.restart()

self.initialized = True

0 comments on commit 2df5d44

Please sign in to comment.