add optional reason when kicking banning or unbanning users with the built in commands
@@ -11,7 +11,7 @@ class AdminCmds(commands.Cog):
@commands.has_permissions(manage_messages=True)
@commands.guild_only()
async def purge_messages(self, ctx, n: int):
- if n < 999:
+ if n <= 9999:
try:
await ctx.channel.purge(limit=n+1)
except Exception:
@@ -22,13 +22,13 @@ class AdminCmds(commands.Cog):
else:
limit_embed = discord.Embed(
color=discord.Color.green(),
- description='''You cannot purge more than 999 messages at one time!''')
+ description='''You cannot purge more than 9999 messages at one time!''')
await ctx.send(embed=limit_embed)
@commands.command(name="ban")
@commands.guild_only()
@commands.has_permissions(ban_members=True)
- async def ban_user(self, ctx, *, user: discord.User):
+ async def ban_user(self, ctx, user: discord.User, *, reason="No reason provided."):
for entry in await ctx.guild.bans():
if entry[1].id == user.id:
already_banned_embed = discord.Embed(
@@ -37,7 +37,7 @@ class AdminCmds(commands.Cog):
await ctx.send(embed=already_banned_embed)
return
- await ctx.guild.ban(user)
+ await ctx.guild.ban(user, reason=reason)
banned_embed = discord.Embed(
color=discord.Color.green(),
description=f"Successfully banned **{str(user)}**.")
@@ -46,10 +46,10 @@ class AdminCmds(commands.Cog):
@commands.command(name="pardon")
@commands.guild_only()
@commands.has_permissions(ban_members=True)
- async def pardon_user(self, ctx, *, user: discord.User):
+ async def pardon_user(self, ctx, user: discord.User, *, reason="No reason provided."):
for entry in await ctx.guild.bans():
if entry[1].id == user.id:
- await ctx.guild.unban(user)
+ await ctx.guild.unban(user, reason=reason)
unban_embed = discord.Embed(
color=discord.Color.green(),
description=f"Successfully unbanned **{str(user)}**.")
@@ -64,8 +64,8 @@ class AdminCmds(commands.Cog):
@commands.command(name="kick")
@commands.guild_only()
@commands.has_permissions(kick_members=True)
- async def kick_user(self, ctx, *, user: discord.User):
- await ctx.guild.kick(user)
+ async def kick_user(self, ctx, user: discord.User, *, reason="No reason provided."):
+ await ctx.guild.kick(user, reason=reason)
kick_embed = discord.Embed(
color=discord.Color.green(),
description=f"Successfully kicked **{str(user)}**.")
@@ -74,7 +74,7 @@ class AdminCmds(commands.Cog):
@commands.command(name="warn")
@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: str):
+ async def warn(self, user: discord.User, *, reason="No reason provided"):
await self.db.add_warn()
