fix(sidestore & idevice): error handling for missing permissions

This commit is contained in:
neoarz
2025-09-22 00:21:23 -04:00
parent a5faf609fb
commit ede9168c9a
3 changed files with 51 additions and 13 deletions

View File

@@ -3,4 +3,4 @@ PREFIX=YOUR_BOT_PREFIX_HERE
INVITE_LINK=YOUR_BOT_INVITE_LINK_HERE
# Commands you want to disable (comma separated)
DISABLED_COGS=general.context_menus # Context Menus
DISABLED_COGS=general.context_menus

View File

@@ -21,6 +21,7 @@ class IdeviceSelect(discord.ui.Select):
command = self.bot.get_command(command_name)
if command:
try:
ctx = await self.bot.get_context(interaction.message)
if ctx:
await ctx.invoke(command)
@@ -31,6 +32,24 @@ class IdeviceSelect(discord.ui.Select):
)
embed.set_author(name="iDevice", icon_url="https://yes.nighty.works/raw/snLMuO.png")
await interaction.response.edit_message(embed=embed, view=None)
except discord.Forbidden:
self.bot.logger.warning(f"Bot missing permissions in server {interaction.guild.name} (ID: {interaction.guild.id}) - cannot execute {command_name} command")
embed = discord.Embed(
title="Permission Error",
description="The bot doesn't have the required permissions in this server to execute commands. Please contact a server administrator to add the bot to the server.",
color=0xFF0000
)
embed.set_author(name="iDevice", icon_url="https://yes.nighty.works/raw/snLMuO.png")
await interaction.response.edit_message(embed=embed, view=None)
except Exception as e:
self.bot.logger.error(f"Error executing {command_name} command: {e}")
embed = discord.Embed(
title="Error",
description="An error occurred while executing the command.",
color=0xFF0000
)
embed.set_author(name="iDevice", icon_url="https://yes.nighty.works/raw/snLMuO.png")
await interaction.response.edit_message(embed=embed, view=None)
else:
embed = discord.Embed(
title="Error",

View File

@@ -62,6 +62,7 @@ class SidestoreSelect(discord.ui.Select):
command = self.bot.get_command(command_name)
if command:
try:
ctx = await self.bot.get_context(interaction.message)
if ctx:
await ctx.invoke(command)
@@ -72,6 +73,24 @@ class SidestoreSelect(discord.ui.Select):
)
embed.set_author(name="SideStore", icon_url="https://github.com/SideStore/assets/blob/main/icons/classic/Default.png?raw=true")
await interaction.response.edit_message(embed=embed, view=None)
except discord.Forbidden:
self.bot.logger.warning(f"Bot missing permissions in server {interaction.guild.name} (ID: {interaction.guild.id}) - cannot execute {command_name} command")
embed = discord.Embed(
title="Permission Error",
description="The bot doesn't have the required permissions in this server to execute commands. Please contact a server administrator to add the bot to the server.",
color=0xFF0000
)
embed.set_author(name="SideStore", icon_url="https://github.com/SideStore/assets/blob/main/icons/classic/Default.png?raw=true")
await interaction.response.edit_message(embed=embed, view=None)
except Exception as e:
self.bot.logger.error(f"Error executing {command_name} command: {e}")
embed = discord.Embed(
title="Error",
description="An error occurred while executing the command.",
color=0xFF0000
)
embed.set_author(name="SideStore", icon_url="https://github.com/SideStore/assets/blob/main/icons/classic/Default.png?raw=true")
await interaction.response.edit_message(embed=embed, view=None)
else:
embed = discord.Embed(
title="Error",