Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

added a moderation cog #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions plugins/admin/moderation.py
Original file line number Diff line number Diff line change
@@ -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))