From 517a13b7c3fdd8ad6f383852313c362ad2cc801b Mon Sep 17 00:00:00 2001 From: Abigail Gold Date: Fri, 4 Oct 2019 18:26:20 -0400 Subject: [PATCH] add shutdown command --- cogs/basecog.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cogs/basecog.py b/cogs/basecog.py index d4137ce..262546c 100644 --- a/cogs/basecog.py +++ b/cogs/basecog.py @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., import discord import discord.ext.commands as commands +import os class BaseCog(commands.Cog): def __init__(self, bot): @@ -51,6 +52,17 @@ class BaseCog(commands.Cog): except: return + @commands.command(name="shutdown") + async def _shutdown_bot(self, ctx): + """Shuts down the bot.""" + if ctx.author.id in self.gs.opt.owners_uids: + await ctx.message.add_reaction("✅") + os._exit(42) + else: + try: + await ctx.message.add_reaction("❌") + except: + return def setup(bot): bot.add_cog(BaseCog(bot))