From ed7ada0f53740416581151cb92a5401940d53bd4 Mon Sep 17 00:00:00 2001 From: horsie Date: Wed, 24 May 2017 19:25:07 -0400 Subject: [PATCH] added a moderation cog --- plugins/admin/moderation.py | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 plugins/admin/moderation.py diff --git a/plugins/admin/moderation.py b/plugins/admin/moderation.py new file mode 100644 index 0000000..7728376 --- /dev/null +++ b/plugins/admin/moderation.py @@ -0,0 +1,63 @@ +import discord +from discord.ext import commands +import asyncio +from plugins.utils import checks + +# idk if this works + +class Mod: + """Moderation.""" + def __init__(self, bot): + self.bot = bot + + + @commands.command(no_pm=True) + @checks.admin_or_permissions(kick_members=True) + async def kick(self, *, member: discord.Member): + """ + Kicks a member. You need appropriate permissions. + """ + + try: + await self.bot.kick(member) + except discord.Forbidden: + await self.bot.say('I have failed, my master. **KICKING ERROR**') + except discord.HTTPException: + await self.bot.say('HTTP Exception, could not kick. **HTTP**') + else: + await self.bot.say('Ding dong, the witch is dead.') + + @commands.command(no_pm=True) + @checks.admin_or_permissions(ban_members=True) + async def ban(self, *, member: discord.Member): + """ + Bans a member. You need appropriate permissions. + """ + try: + await self.bot.ban(member) + except discord.Forbidden: + await self.bot.say('Aww, man. I missed. **BAN ERROR**') + except discord.HTTPException: + await self.bot.say('BONK!') + else: + await self.bot.say('Kek.') + + @commands.command(no_pm=True) + @checks.admin_or_permissions(ban_members=True) + async def softban(self, *, member: discord.Member): + """Soft bans a member from the server. + You must have perms. + """ + + try: + await self.bot.ban(member) + await self.bot.unban(member.server, member) + except discord.Forbidden: + await self.bot.say('The bot does not have permissions to ban this member.') + except discord.HTTPException: + await self.bot.say('Banning failed.') + else: + await self.bot.say('\U0001f44c') + + def setup(bot): + bot.add_cog(Mod(bot))