fix: idevice errorcodes bug (#24)

* very easy fix

* Added self hosting instructions

* nvm this was the actual fix  nooo way

* removed instructions :3

* fix: some stuff

---------

Co-authored-by: neoarz <email@neoarz.dev>
This commit is contained in:
Daisuke
2025-11-15 20:46:39 -05:00
committed by GitHub
parent 11f08556dc
commit bafd8fc19a
4 changed files with 36 additions and 39 deletions

View File

@@ -30,39 +30,9 @@ class Idevice(commands.GroupCog, name="idevice"):
view = ideviceView(self.bot)
await context.send(embed=embed, view=view)
@idevice_group.command(name="help")
async def idevice_group_help(self, context: Context):
embed = discord.Embed(
title="idevice Commands",
description="Choose a command from the dropdown below to get help with specific issues:",
color=0xFA8C4A,
)
embed.set_author(
name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png"
)
view = ideviceView(self.bot)
await context.send(embed=embed, view=view)
async def _invoke_hybrid(self, context: Context, name: str):
command = self.bot.get_command(name)
if command is not None:
await context.invoke(command)
else:
await context.send(f"Unknown idevice command: {name}")
def _require_group_prefix(context: Context) -> bool:
if getattr(context, "interaction", None):
return True
group = getattr(getattr(context, "cog", None), "qualified_name", "").lower()
if not group:
return True
prefix = context.prefix or ""
content = context.message.content.strip().lower()
return content.startswith(f"{prefix}{group} ")
@idevice_group.command(name="errorcodes")
async def idevice_group_errorcodes(self, context: Context):
await self._invoke_hybrid(context, "errorcodes")
async def idevice_group_errorcodes(self, context: Context, *, error_code: str = None):
await self._invoke_hybrid(context, "errorcodes", error_code=error_code)
@idevice_group.command(name="developermode")
async def idevice_group_developermode(self, context: Context):
@@ -76,6 +46,23 @@ class Idevice(commands.GroupCog, name="idevice"):
async def idevice_group_mountddi(self, context: Context):
await self._invoke_hybrid(context, "mountddi")
async def _invoke_hybrid(self, context: Context, name: str, **kwargs):
command = self.bot.get_command(name)
if command is not None:
await context.invoke(command, **kwargs)
else:
await context.send(f"Unknown idevice command: {name}")
def _require_group_prefix(context: Context) -> bool:
if getattr(context, "interaction", None):
return True
group = getattr(getattr(context, "cog", None), "qualified_name", "").lower()
if not group:
return True
prefix = context.prefix or ""
content = context.message.content.strip().lower()
return content.startswith(f"{prefix}{group} ")
@app_commands.command(name="help", description="idevice troubleshooting help")
async def help(self, interaction: discord.Interaction):
embed = discord.Embed(
@@ -94,7 +81,7 @@ class Idevice(commands.GroupCog, name="idevice"):
name="errorcodes", description="Look up error codes and their meanings."
)
async def errorcodes(self, context, *, error_code: str = None):
return await errorcodes_command()(self, context, error_code=error_code)
return await errorcodes_command()(self, context, name=error_code)
@commands.check(_require_group_prefix)
@commands.hybrid_command(