warn commands
@@ -71,12 +71,28 @@ class AdminCmds(commands.Cog):
description=f"Successfully kicked **{str(user)}**.")
await ctx.send(embed=kick_embed)
- @commands.command(name="warn")
+ @commands.command(name="warn", aliases="warnuser")
@commands.guild_only()
@commands.check_any(commands.has_permissions(administrator=True), commands.has_permissions(kick_members=True), commands.has_permissions(ban_members=True))
async def warn(self, user: discord.User, *, reason="No reason provided"):
- await self.db.add_warn()
+ reason = (reason[:125] + "...") if len(reason) > 128 else reason
+ await self.db.add_warn(user.id, ctx.author.id, ctx.guild.id, reason)
+ await ctx.send(embed=discord.Embed(color=discord.Color.green(), description=f"{user} was warned by {ctx.author} for reason: *{reason}*"))
+ @commands.command(name="warns", aliases=["getwarns", "getuserwarns"])
+ @commands.guild_only()
+ @commands.check_any(commands.has_permissions(administrator=True), commands.has_permissions(kick_members=True), commands.has_permissions(ban_members=True))
+ async def get_user_warns(self, ctx, user: discord.User):
+ user_warns = await self.db.get_warns(user.id, ctx.guild.id)
+ embed = discord.Embed(color=discord.Color.green(), title=f"{user}s Warnings:")
+ for warning in user_warns:
+ embed.add_field(name=f"Warning by {warning[1]}", value=warning[3], inline=False)
+ await ctx.send(embed=embed)
+
+ @commands.command(name="clearwarns", aliases=["deletewarns", "removewarns"])
+ @commands.guild_only()
+ @commands.check_any(commands.has_permissions(administrator=True), commands.has_permissions(kick_members=True), commands.has_permissions(ban_members=True))
+ async def clear_user_warns(self, ctx, user: discord.User):
def setup(bot):
bot.add_cog(AdminCmds(bot))
