From b3266a7a471049843305326dbf22ba15e3a39c68 Mon Sep 17 00:00:00 2001 From: Swee Date: Sun, 10 Nov 2024 12:39:36 -0800 Subject: [PATCH] Update guild2.py --- guild2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/guild2.py b/guild2.py index 810e758..1fc891c 100644 --- a/guild2.py +++ b/guild2.py @@ -57,6 +57,10 @@ class SweeBotTestException(Exception): pass class SweeBotSystemException(Exception): pass +def die(): + client.close() + os.system("python " + " ".join(sys.argv)) + sys.exit() # Client itself @client.event async def on_ready(): @@ -101,8 +105,7 @@ async def on_message(message): if "restart" in getperms(message.author.id) or "full" in getperms(message.author.id): mess = await message.reply(embed=guilded.Embed(title=":sweebot-success: Command complete.",description="Restarting bot...")) print("[" + BLUE + "..." + RESET + "] Restarting script... (initiated by " + message.author.name + ")") - subprocess.Popen(["python"] + sys.argv) - exit() + die() else: mess = await message.reply(embed=guilded.Embed(title=":sweebot-fail: Permission denied.")) print("[" + RED + "FAIL" + RESET + "] Not restarting script, Permission Denied for " + message.author.name) @@ -135,6 +138,7 @@ async def on_message(message): p.stdout.close() p.wait() await mess.edit(embed=guilded.Embed(title=":sweebot-success: Done, restarting bot...", description="```\n" + output + "```")) + die() else: mess = await message.reply(embed=guilded.Embed(title=":sweebot-fail: Permission denied.")) print("[" + RED + "FAIL" + RESET + "] Not restarting script, Permission Denied for " + message.author.name)