mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
fix(sidestore & idevice): error handling for missing permissions
This commit is contained in:
@@ -62,13 +62,32 @@ class SidestoreSelect(discord.ui.Select):
|
||||
command = self.bot.get_command(command_name)
|
||||
|
||||
if command:
|
||||
ctx = await self.bot.get_context(interaction.message)
|
||||
if ctx:
|
||||
await ctx.invoke(command)
|
||||
try:
|
||||
ctx = await self.bot.get_context(interaction.message)
|
||||
if ctx:
|
||||
await ctx.invoke(command)
|
||||
embed = discord.Embed(
|
||||
title="Command Executed",
|
||||
description=f"Successfully executed `/{command_name}`",
|
||||
color=0x00FF00
|
||||
)
|
||||
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="Command Executed",
|
||||
description=f"Successfully executed `/{command_name}`",
|
||||
color=0x00FF00
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user