chore: add permission checks

This commit is contained in:
neoarz
2025-10-20 12:21:43 -04:00
parent 898e01abf4
commit a5f94df549
6 changed files with 309 additions and 67 deletions

View File

@@ -34,7 +34,7 @@ def mcquote_command():
if isinstance(context.channel, discord.PartialMessageable):
embed = discord.Embed(
title="Error",
description="The bot needs send messages permissions in this channel.",
description="The bot needs the `send messages` permission in this channel.",
color=0xE02B2B,
)
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
@@ -127,16 +127,36 @@ def mcquote_command():
interaction = getattr(context, "interaction", None)
if interaction is not None:
await context.channel.send(embed=embed)
await context.channel.send(file=file)
try:
await interaction.delete_original_response()
except:
pass
await context.channel.send(embed=embed)
await context.channel.send(file=file)
try:
await interaction.delete_original_response()
except:
pass
except discord.Forbidden:
embed = discord.Embed(
title="Permission Error",
description="The bot needs the `send messages` permission to execute this command.",
color=0xE02B2B,
)
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
await interaction.followup.send(embed=embed, ephemeral=True)
return
else:
await processing_msg.delete()
await context.channel.send(embed=embed)
await context.channel.send(file=file)
try:
await processing_msg.delete()
await context.channel.send(embed=embed)
await context.channel.send(file=file)
except discord.Forbidden:
embed = discord.Embed(
title="Permission Error",
description="The bot needs the `send messages` permission to execute this command.",
color=0xE02B2B,
)
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
await context.send(embed=embed, ephemeral=True)
return
os.remove(temp_file_path)
except aiohttp.ClientError: