Adding new moderation cog

pull/8/head
sgoudham 4 years ago
parent 7325b957d5
commit 4c0ccb4317

@ -0,0 +1,66 @@
from discord import Member
from discord.ext import commands
from discord.ext.commands import command, guild_only, has_guild_permissions
class Moderation(commands.Cog):
"""Moderation Commands! (Kick/Ban/Mute etc)"""
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print(f"{self.__class__.__name__} Cog has been loaded\n-----")
@command()
@guild_only()
@has_guild_permissions(kick_members=True)
async def kick(self, ctx, member: Member, *, reason="No Reason Given"):
"""Kick Members from Server"""
await ctx.guild.kick(user=member, reason=reason)
await ctx.send(f"{ctx.author.name} **kicked** {member.name}"
f"\n**Reason:** {reason}")
@command()
@guild_only()
@has_guild_permissions(ban_members=True)
async def ban(self, ctx, member: Member, *, reason="No Reason Given"):
"""Ban Members from Server"""
await ctx.guild.ban(user=member, reason=reason)
await ctx.send(f"{ctx.author.name} **banned** {member.name}"
f"\n**Reason:** {reason}")
@command()
@guild_only()
@has_guild_permissions(ban_members=True)
async def unban(self, ctx, member: int, *, reason="No Reason Given"):
"""Unban Member from Server"""
member = await self.bot.fetch_user(member)
await ctx.guild.unban(member, reason=reason)
await ctx.send(f"{ctx.author.name} **unbanned** {member.name}"
f"\n**Reason:** {reason}")
@command()
@guild_only()
@has_guild_permissions(manage_messages=True)
async def purge(self, ctx, amount=100):
"""Purge Messages from Channel"""
channel = ctx.message.channel
messages = []
async for message in channel.history(limit=amount):
messages.append(message)
await channel.delete_messages(messages)
await ctx.send('Messages deleted.')
def setup(bot):
bot.add_cog(Moderation(bot))

@ -66,6 +66,7 @@ enso_modmail_ID = 728083016290926623
# Returns a list of all the cogs
def extensions():
ext = ['cogs.interactive', 'cogs.anime', 'cogs.relationship',
'cogs.info', 'cogs.fun', 'cogs.enso', 'cogs.modmail']
'cogs.info', 'cogs.fun', 'cogs.enso',
'cogs.modmail', 'cogs.moderation']
return ext

Loading…
Cancel
Save