diff --git a/README.md b/README.md index 2f0b368..a12e60c 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,12 @@
> [!NOTE] -> This bot is heavily customized and may not be a good starting point template wise. But if you wanna use this bot, or maybe add to your own server, download it by clicking the button below. +> **Download** +> +> This bot is heavily customized and may not be a good starting point template wise. But if you wanna use this bot, or maybe add to your own server, [download](#download) it by clicking the button below. After downloading run `/help` to get started. -### Download -
- - Download - -
- -### Commands +## Commands | Command group | Subcommands | | --- | --- | @@ -39,6 +34,16 @@ | idevice | `idevice`, `noapps`, `errorcode` | | miscellaneous | `keanu`, `labubu` | +## Download + +
+ + Download + +
+ + + ## Contributing diff --git a/cogs/idevice/idevice.py b/cogs/idevice/idevice.py index bc05afe..81ac98f 100644 --- a/cogs/idevice/idevice.py +++ b/cogs/idevice/idevice.py @@ -98,7 +98,7 @@ class ErrorCodesBrowserView(discord.ui.View): inline=True ) - # Add empty fields to maintain 3x3 grid if needed + while len(current_codes) % 3 != 0: embed.add_field(name="\u200b", value="\u200b", inline=True) @@ -151,7 +151,7 @@ class ideviceSelect(discord.ui.Select): ), discord.SelectOption( label="Error Codes", - value="errorcodes_ephemeral", + value="errorcodes", description="Browse idevice error codes", ), ] @@ -159,21 +159,40 @@ class ideviceSelect(discord.ui.Select): async def callback(self, interaction: discord.Interaction): command_name = self.values[0] - - if command_name == "errorcodes_ephemeral": - # Send success message first - embed = discord.Embed( - title="Command Executed", - description="Successfully executed `/errorcodes`", - color=0x00FF00 - ) - embed.set_author(name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png") - await interaction.response.edit_message(embed=embed, view=None) - - # Follow up with the error codes browser - view = ErrorCodesBrowserView() - embed = view.create_embed() - await interaction.followup.send(embed=embed, view=view, ephemeral=True) + + if command_name == "errorcodes": + try: + view = ErrorCodesBrowserView() + embed = view.create_embed() + + success_embed = discord.Embed( + title="Command Executed", + description="Successfully executed `/errorcodes`", + color=0x00FF00 + ) + success_embed.set_author(name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png") + await interaction.response.edit_message(embed=success_embed, view=None) + + await interaction.followup.send(embed=embed, view=view, ephemeral=True) + + except discord.Forbidden: + self.bot.logger.warning(f"Bot missing permissions in server {interaction.guild.name} (ID: {interaction.guild.id}) - cannot execute errorcodes command") + embed = discord.Embed( + title="Permission Error", + description="The bot doesn't have the required permissions in this server to execute this command. Use the slash command `/errorcodes` instead.", + 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 errorcodes 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) return command = self.bot.get_command(command_name) @@ -194,7 +213,7 @@ class ideviceSelect(discord.ui.Select): 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 this command. Use the slash command `/{command_name}` instead.", + description=f"The bot doesn't have the required permissions in this server to execute this command. Use the slash command `/{command_name}` instead.", color=0xFF0000 ) embed.set_author(name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png") @@ -248,4 +267,4 @@ class idevice(commands.Cog, name="idevice"): async def setup(bot) -> None: - await bot.add_cog(idevice(bot)) + await bot.add_cog(idevice(bot)) \ No newline at end of file