diff options
Diffstat (limited to 'cogs/moderator.py')
-rw-r--r-- | cogs/moderator.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cogs/moderator.py b/cogs/moderator.py new file mode 100644 index 0000000..ebc25cf --- /dev/null +++ b/cogs/moderator.py @@ -0,0 +1,69 @@ +from discord.ext import commands +import discord +import asyncio + +class Admin(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command(aliases=['quit'], hidden=True) + async def force_exit(self, ctx): + await ctx.send("Self Destructing!") + await ctx.bot.close() + + @commands.command(aliases=['unload'], hidden=True) + async def _unload(self, ctx, ext): + await ctx.send(f"Unloading {ext}...") + try: + self.bot.unload_extension(f'cogs.{ext}') + await ctx.send(f"{ext} has been unloaded.") + except commands.ExtensionNotFound: + await ctx.send(f"{ext} doesn't exist!") + except commands.ExtensionNotLoaded: + await ctx.send(f"{ext} is not loaded!") + except commands.ExtensionFailed: + await ctx.send(f"{ext} failed to unload!") + + @commands.command(aliases=['reload'], hidden=True) + async def _reload(self, ctx, ext): + await ctx.send(f"Reloading {ext}...") + try: + self.bot.reload_extension(f'cogs.{ext}') + await ctx.send(f"{ext} has been reloaded.") + except commands.ExtensionNotFound: + await ctx.send(f"{ext} doesn't exist!") + except commands.ExtensionNotLoaded: + await ctx.send(f"{ext} is not loaded!") + except commands.ExtensionFailed: + await ctx.send(f"{ext} failed to reload!") + + @commands.command(aliases=['load'], hidden=True) + async def _load(self, ctx, ext): + await ctx.send(f"Loading {ext}...") + try: + self.bot.load_extension(f"cogs.{ext}") + await ctx.send(f"{ext} has been loaded.") + except commands.ExtensionNotFound: + await ctx.send(f"{ext} doesn't exist!") + except commands.ExtensionFailed: + await ctx.send(f"{ext} failed to load!") + + @commands.command(aliases=['clearchat'], hidden=True) + async def _clearchat(self, ctx, numb: int=50): + deleted_msg = await ctx.message.channel.purge(limit=int(numb)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) + + msg_num = max(len(deleted_msg) - 1, 0) + + if msg_num == 0: + resp = "Deleted `0 message` 🙄 " + # resp = "Deleted `0 message` 🙄 \n (I can't delete messages "\ + # "older than 2 weeks due to discord limitations)" + else: + resp = "Deleted `{} message{}` 👌 ".format(msg_num, + "" if msg_num <\ + 2 else "s") + + await ctx.send(resp) + +def setup(bot): + bot.add_cog(Admin(bot)) |