async def purge(self, ctx, amount: int): if amount > 200: embed3 = discord.Embed( color=discord.Color.from_rgb(self.color[0], self.color[1], self.color[2]), title=f"➜ Too Many Messages", description= f"‣ Please put a value equal to or under 200 messages.") await ctx.send(embed=embed3) else: await ctx.channel.purge(limit=amount) embed3 = discord.Embed( color=discord.Color.from_rgb(self.color[0], self.color[1], self.color[2]), title=f"➜ Moderation Logs", description=f"‣ **Purged:** {amount} messages") embed3.add_field(name="➜ Moderator:", value=ctx.author) embed3.add_field(name="➜ Reason:", value="N/A") await self.mod_logging.send(embed=embed3) logger.info( f"Moderation | Sent Purge: {ctx.author} | Purged: {amount} messages" )
async def resetnick(self, ctx, member: discord.Member): if ctx.guild.me.top_role < member.top_role: await ctx.send(embed=higher_permissions) elif ctx.author.top_role <= member.top_role: await ctx.send(embed=user_higher_permissions) elif ctx.guild.me.top_role > member.top_role: embed = discord.Embed( color=discord.Color.from_rgb(self.color[0], self.color[1], self.color[2]), title="➜ Nickname Successfully Reset", description=f"‣ Successfully Changed: {member.mention}") await member.edit(nick=None) await ctx.send(embed=embed) embed3 = discord.Embed( color=discord.Color.from_rgb(self.color[0], self.color[1], self.color[2]), title=f"➜ Moderation Logs", description=f"‣ **Reset Nickname:** {member}") embed3.add_field(name="➜ Moderator:", value=ctx.author) embed3.add_field(name="➜ Reason:", value="N/A") await self.mod_logging.send(embed=embed3) logger.info( f"Moderation | Sent Reset Nickname: {ctx.author} | To: {member}" )
async def resetnick(self, ctx, member: discord.Member): if ctx.guild.me.top_role < member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description="• The user has higher permissions than me!") await ctx.send(embed=embed) elif ctx.author.top_role <= member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description= "• The user has higher permissions than you or equal permissions!" ) await ctx.send(embed=embed) elif ctx.guild.me.top_role > member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="• Resetnick Command", description=f"{member.mention}'s → Nickname has been **Reset!**" ) await member.edit(nick=None) await ctx.send(embed=embed) logger.info( f"Moderation | Sent Reset Nickname: {ctx.author} | To: {member}" ) else: traceback.print_exc()
async def warn(self, ctx, member: discord.Member, *, reason="No reason provided!"): if ctx.guild.me.top_role < member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description="• The user has higher permissions than me!") await ctx.send(embed=embed) elif ctx.guild.me.top_role > member.top_role: sender = ctx.author embed = discord.Embed( color=self.bot.embed_color, title="• Warn Command", description=f"{member.mention} → has been **Warned!**") await ctx.send(embed=embed) embed2 = discord.Embed(color=self.bot.embed_color, title=f"{member} → You have been warned!") embed2.add_field(name=f"• Moderator", value=f"`{sender}`") embed2.add_field(name="• Reason", value=f"`{reason}`") embed2.set_footer(text=f"Warning sent from: {ctx.guild}") await member.send(embed=embed2) logger.info( f"Moderation | Sent Warn: {ctx.author} | Warned: {member} | Reason: {reason}" )
async def remove_role( self, ctx, role: discord.Role, member: discord.Member, ): if ctx.guild.me.top_role < member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description="• The user has higher permissions than me!") await ctx.send(embed=embed) elif ctx.author.top_role <= member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description= "• The user has higher permissions than you or equal permissions!" ) await ctx.send(embed=embed) elif ctx.guild.me.top_role > member.top_role: await member.remove_roles(role) embed = discord.Embed( color=self.bot.embed_color, title="• Remove Role Command", description=f"{member.mention} → Lost the role `{role}`") await ctx.send(embed=embed) logger.info( f"Moderation | Sent Remove Role: {ctx.author} | Removed Role: {role} | To: {member}" ) else: traceback.print_exc()
async def unban(self, ctx, *, id: int): await ctx.guild.unban(discord.Object(id)) embed = discord.Embed( color=self.bot.embed_color, title="• Unban Command", description=f"<@{id}> → has been **Unbanned!** Welcome back! :wave:" ) await ctx.send(embed=embed) logger.info(f"Moderation | Sent Unban: {ctx.author} | Unbanned: {id}")
async def forceban(self, ctx, *, id: int): await ctx.guild.ban(discord.Object(id)) embed = discord.Embed( color=self.bot.embed_color, title="• Forceban Command", description= f"<@{id}> → has been **Forcefully banned!** Bye bye! :wave:") await ctx.send(embed=embed) logger.info( f"Moderation | Sent Force Ban: {ctx.author} | Force Banned: {id}")
async def unban(self, ctx, *, id: int): await ctx.guild.unban(discord.Object(id)) embed = discord.Embed(color=discord.Color.from_rgb( self.color[0], self.color[1], self.color[2]), title="➜ User Successfully Unbanned", description=f"‣ Successfully unbanned: <@{id}>") await ctx.send(embed=embed) embed3 = discord.Embed(color=discord.Color.from_rgb( self.color[0], self.color[1], self.color[2]), title=f"➜ Moderation Logs", description=f"‣ **Unbanned:** <@{id}>") embed3.add_field(name="➜ Moderator:", value=ctx.author) embed3.add_field(name="➜ Reason:", value="N/A") await self.mod_logging.send(embed=embed3) logger.info(f"Moderation | Sent Unban: {ctx.author} | Unbanned: {id}")
async def ban(self, ctx, member: discord.Member, *, reason="No valid reason provided."): if ctx.guild.me.top_role < member.top_role: await ctx.send(embed=higher_permissions) elif ctx.author.top_role <= member.top_role: await ctx.send(embed=user_higher_permissions) elif ctx.guild.me.top_role > member.top_role: embed = discord.Embed( color=discord.Color.from_rgb(self.color[0], self.color[1], self.color[2]), title="➜ User Successfully Banned", description=f"‣ Successfully banned: {member.mention}" f"\n‣ Reason: `{reason}`") await member.ban(reason=reason) await ctx.send(embed=embed) embed2 = discord.Embed(color=discord.Color.from_rgb( self.color[0], self.color[1], self.color[2]), title=f"Kick Ban To: {member}") embed2.add_field(name=f"‣ Moderator:", value=f"`{ctx.author}`") embed2.add_field(name="‣ Reason:", value=f"`{reason}`") embed2.set_footer(icon_url=ctx.guild.icon_url_as( size=4096, format=None, static_format="png"), text=f"— Banned from: {ctx.guild}") logger.info( f"Moderation | Sent Ban: {ctx.author} | Banned: {member} | Reason: {reason}" ) embed3 = discord.Embed(color=discord.Color.from_rgb( self.color[0], self.color[1], self.color[2]), title=f"➜ Moderation Logs", description=f"‣ **Banned:** {member}") embed3.add_field(name="➜ Moderator:", value=ctx.author) embed3.add_field(name="➜ Reason:", value=reason) await self.mod_logging.send(embed=embed3) await member.send(embed=embed2)
async def ban(self, ctx, member: discord.Member, *, reason="No reason provided!"): if ctx.guild.me.top_role < member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description="• The user has higher permissions than me!") await ctx.send(embed=embed) elif ctx.author.top_role <= member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="→ User Information", description= "• The user has higher permissions than you or equal permissions!" ) await ctx.send(embed=embed) elif ctx.guild.me.top_role > member.top_role: embed = discord.Embed( color=self.bot.embed_color, title="• Ban command", description= f"{member.mention} → has been **Banned!** Bye bye! :wave:") sender = ctx.author await member.ban(reason=reason) await ctx.send(embed=embed) embed2 = discord.Embed(color=self.bot.embed_color, title=f"{member} → You Have Been Banned!") embed2.add_field(name=f"• Moderator", value=f"{sender}") embed2.add_field(name="• Reason", value=f"{reason}") embed2.set_footer(text=f"Banned from: {ctx.guild}") await member.send(embed=embed2) logger.info( f"Moderation | Sent Ban: {ctx.author} | Banned: {member} | Reason: {reason}" ) else: traceback.print_exc()
async def purge(self, ctx, amount: int): await ctx.channel.purge(limit=amount) logger.info( f"Moderation | Sent Purge: {ctx.author} | Purged: {amount} messages" )