Skip to content

Commit

Permalink
Improved error handling for on-success reboot message
Browse files Browse the repository at this point in the history
  • Loading branch information
LobaDK committed Mar 30, 2024
1 parent 3bf66ce commit 2850edc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions QuantumKat.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ async def on_ready():
IDs = f.read()
# Order: message ID, channel ID, guild ID
IDs = IDs.split("\n")
message = await bot.get_channel(int(IDs[1])).fetch_message(int(IDs[0]))
try:
message = await bot.get_channel(int(IDs[1])).fetch_message(int(IDs[0]))
except Exception:
logger.error("Error fetching message to edit", exc_info=True)
if message:
await message.edit(content="Rebooted successfully!")
try:
await message.edit(content=f"{message.content} Rebooted successfully!")
except Exception:
logger.error("Error editing message", exc_info=True)
else:
# if the message is not found, instead send a message to the bot owner
await bot.get_user(int(OWNER_ID)).send("Rebooted successfully!")
Expand Down

0 comments on commit 2850edc

Please sign in to comment.