fix(error_codes): make command hybrid

This commit is contained in:
neoarz
2025-09-24 00:00:48 -04:00
parent cd810659b4
commit b4df04acc5
3 changed files with 14 additions and 5 deletions

View File

@@ -1,9 +1,10 @@
# Todo List for Syntrel # Todo List for Syntrel
- [x] Finish [idevice commands](https://github.com/jkcoxson/idevice/blob/master/idevice/src/lib.rs#L522) - [ ] Finish [idevice commands](https://github.com/jkcoxson/idevice/blob/master/idevice/src/lib.rs#L522)
- [x] Add /idevice command - [x] Add /idevice command
- [x] Add /no apps command - [x] Add /no apps command
- [x] Add rest of the errors yikes - [x] Add rest of the errors yikes
- [ ] Add ddi mounting command
- [ ] Add unit tests - [ ] Add unit tests

View File

@@ -77,6 +77,7 @@ class Help(commands.Cog, name="help"):
# idevice Commands # idevice Commands
"idevice": "idevice", "idevice": "idevice",
"noapps": "idevice", "noapps": "idevice",
"errorcode": "idevice",
# Owner Commands # Owner Commands
"sync": "owner", "sync": "owner",

View File

@@ -3,6 +3,7 @@ import os
import discord import discord
from discord import app_commands from discord import app_commands
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import Context
class ErrorCodes(commands.Cog, name="errorcodes"): class ErrorCodes(commands.Cog, name="errorcodes"):
@@ -34,10 +35,10 @@ class ErrorCodes(commands.Cog, name="errorcodes"):
break break
return items return items
@app_commands.command(name="errorcode", description="Look up an idevice error code by name or number") @commands.hybrid_command(name="errorcode", description="Look up an idevice error code by name or number")
@app_commands.describe(name="Start typing to search all error names and codes") @app_commands.describe(name="Start typing to search all error names and codes")
@app_commands.autocomplete(name=errorcode_autocomplete) @app_commands.autocomplete(name=errorcode_autocomplete)
async def errorcode(self, interaction: discord.Interaction, name: str): async def errorcode(self, context: Context, name: str):
key = name key = name
if key not in self.key_to_data: if key not in self.key_to_data:
try: try:
@@ -46,7 +47,10 @@ class ErrorCodes(commands.Cog, name="errorcodes"):
except ValueError: except ValueError:
key = None key = None
if key is None or key not in self.key_to_data: if key is None or key not in self.key_to_data:
await interaction.response.send_message("Error not found.", ephemeral=True) if context.interaction:
await context.interaction.response.send_message("Error not found.", ephemeral=True)
else:
await context.send("Error not found.")
return return
title, code = self.key_to_data[key] title, code = self.key_to_data[key]
@@ -65,7 +69,10 @@ class ErrorCodes(commands.Cog, name="errorcodes"):
emoji="<:githubicon:1417717356846776340>" emoji="<:githubicon:1417717356846776340>"
)) ))
await interaction.response.send_message(embed=embed, view=view) if context.interaction:
await context.interaction.response.send_message(embed=embed, view=view)
else:
await context.send(embed=embed, view=view)
async def setup(bot) -> None: async def setup(bot) -> None:
cog = ErrorCodes(bot) cog = ErrorCodes(bot)