fix(idevice): fix error commands

This commit is contained in:
neoarz
2025-09-24 08:24:42 -04:00
parent 48d1b875a9
commit b492d60db3
2 changed files with 52 additions and 28 deletions

View File

@@ -17,17 +17,12 @@
<br>
> [!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
<div align="left">
<a href="https://discord.com/oauth2/authorize?client_id=1376728824108286034" target="_blank" rel="noopener noreferrer">
<img src="assets/download.png" alt="Download" style="width: 300px; height: auto;">
</a>
</div>
### Commands
## Commands
| Command group | Subcommands |
| --- | --- |
@@ -39,6 +34,16 @@
| idevice | `idevice`, `noapps`, `errorcode` |
| miscellaneous | `keanu`, `labubu` |
## Download
<div align="left">
<a href="https://discord.com/oauth2/authorize?client_id=1376728824108286034" target="_blank" rel="noopener noreferrer">
<img src="assets/download.png" alt="Download" style="width: 300px; height: auto;">
</a>
</div>
## Contributing

View File

@@ -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))