discord-bot/cogs/moderation/moderationCog.py
rzmk 2b8e2345f9 First official build of bot!
Co-authored-by: iakrules <64628083+iakrules@noreply.github.com>
2021-08-01 14:36:34 -04:00

31 lines
No EOL
1.2 KiB
Python

import discord
from discord.ext import commands
class ModerationCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# Commands
@commands.command()
@commands.has_permissions(kick_members = True)
async def kick(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Kick a user from the server"""
try:
await member.kick(reason=reason)
await ctx.send(member.mention + " has been kicked.")
except:
await ctx.send(f"Unable to kick {member.mention}.\nIs {member.mention} at the same role level or higher than {self.bot.user.name}?")
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member : commands.MemberConverter, *, reason="No reason provided."):
"""Ban a user from the server"""
try:
await member.ban(reason=reason)
await ctx.send(member.mention + " has been banned.")
except:
await ctx.send(f"Unable to ban {member.mention}.\nIs {member.mention} at the same role level or higher than {self.bot.user.name}?")
def setup(bot):
bot.add_cog(ModerationCog(bot))