fix: permission checking

This commit is contained in:
neoarz
2026-04-14 16:34:03 -04:00
parent 70c21cdc0d
commit cad8995324
3 changed files with 60 additions and 0 deletions

View File

@@ -21,6 +21,17 @@ def archive_command():
:param context: The hybrid command context.
:param limit: The limit of messages that should be archived. Default is 10.
"""
if not context.author.guild_permissions.manage_messages:
embed = discord.Embed(
title="Missing Permissions!",
description="You are missing the permission(s) `manage_messages` to execute this command!",
color=0xE02B2B,
).set_author(
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
)
await context.send(embed=embed, ephemeral=True)
return
log_file = f"{context.channel.id}.log"
messages = []

View File

@@ -23,6 +23,33 @@ def hackban_command():
:param reason: The reason for the ban. Default is "Not specified".
"""
try:
if (
not context.author.guild_permissions.ban_members
and context.author != context.guild.owner
):
embed = discord.Embed(
title="Missing Permissions!",
description="You don't have the `Ban Members` permission to use this command.",
color=0xE02B2B,
).set_author(
name="Moderation",
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
)
await context.send(embed=embed, ephemeral=True)
return
if not context.guild.me.guild_permissions.ban_members:
embed = discord.Embed(
title="Missing Permissions!",
description="I am missing the permission(s) `ban_members` to execute this command!",
color=0xE02B2B,
).set_author(
name="Moderation",
icon_url="https://yes.nighty.works/raw/CPKHQd.png",
)
await context.send(embed=embed, ephemeral=True)
return
await self.bot.http.ban(user_id, context.guild.id, reason=reason)
user = self.bot.get_user(int(user_id)) or await self.bot.fetch_user(
int(user_id)

View File

@@ -15,6 +15,28 @@ def purge_command():
user="The user whose messages should be deleted (optional).",
)
async def purge(self, context, amount: int, user: discord.Member = None):
if not context.author.guild_permissions.manage_messages:
embed = discord.Embed(
title="Missing Permissions!",
description="You are missing the permission(s) `manage_messages` to execute this command!",
color=0xE02B2B,
).set_author(
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
)
await context.send(embed=embed, ephemeral=True)
return
if not context.guild.me.guild_permissions.manage_messages:
embed = discord.Embed(
title="Missing Permissions!",
description="I am missing the permission(s) `manage_messages` to execute this command!",
color=0xE02B2B,
).set_author(
name="Moderation", icon_url="https://yes.nighty.works/raw/CPKHQd.png"
)
await context.send(embed=embed, ephemeral=True)
return
if context.interaction:
await context.defer(ephemeral=True)