refactor(sidestore): commands into single GroupCog

Converted individual sidestore command cogs into functions and grouped them under a new Sidestore GroupCog in cogs/sidestore/__init__.py. Updated bot.py and help.py to recognize the new 'sidestore' category. This simplifies command registration and improves maintainability.
This commit is contained in:
neoarz
2025-09-28 23:28:53 -04:00
parent 5e2999e565
commit 3bc5ebe192
13 changed files with 137 additions and 74 deletions

2
bot.py
View File

@@ -90,7 +90,7 @@ class DiscordBot(commands.Bot):
if os.path.exists(init_file): if os.path.exists(init_file):
try: try:
await self.load_extension(f"cogs.{folder}") await self.load_extension(f"cogs.{folder}")
if folder not in ["fun", "general", "idevice", "miscellaneous", "moderation"]: if folder not in ["fun", "general", "idevice", "miscellaneous", "moderation", "owner", "sidestore"]:
self.logger.info(f"Loaded extension '{folder}'") self.logger.info(f"Loaded extension '{folder}'")
except Exception as e: except Exception as e:
exception = f"{type(e).__name__}: {e}" exception = f"{type(e).__name__}: {e}"

View File

@@ -166,7 +166,7 @@ class Help(commands.Cog, name="help"):
commands_in_category.append((app_command.name, description)) commands_in_category.append((app_command.name, description))
seen_names.add(app_command.name) seen_names.add(app_command.name)
if hasattr(app_command, 'commands') and category in ["fun", "general", "idevice", "miscellaneous", "moderation"]: if hasattr(app_command, 'commands') and category in ["fun", "general", "idevice", "miscellaneous", "moderation", "owner", "sidestore"]:
for subcommand in app_command.commands: for subcommand in app_command.commands:
if subcommand.name in seen_names: if subcommand.name in seen_names:
continue continue

104
cogs/sidestore/__init__.py Normal file
View File

@@ -0,0 +1,104 @@
import discord
from discord.ext import commands
from discord.ext.commands import Context
from .sidestore import sidestore_command
from .refresh import refresh_command
from .code import code_command
from .crash import crash_command
from .pairing import pairing_command
from .server import server_command
from .afc import afc_command
from .udid import udid_command
from .half import half_command
from .sparse import sparse_command
class Sidestore(commands.GroupCog, name="sidestore"):
def __init__(self, bot) -> None:
self.bot = bot
super().__init__()
@commands.hybrid_command(
name="sidestore",
description="SideStore troubleshooting help"
)
async def sidestore(self, context):
return await sidestore_command()(self, context)
@commands.hybrid_command(
name="refresh",
description="Help with refreshing or installing apps"
)
async def refresh(self, context):
return await refresh_command()(self, context)
@commands.hybrid_command(
name="code",
description="No code received when signing in with Apple ID"
)
async def code(self, context):
return await code_command()(self, context)
@commands.hybrid_command(
name="crash",
description="Help with SideStore crashing issues"
)
async def crash(self, context):
return await crash_command()(self, context)
@commands.hybrid_command(
name="pairing",
description="Help with pairing file issues"
)
async def pairing(self, context):
return await pairing_command()(self, context)
@commands.hybrid_command(
name="server",
description="Help with anisette server issues"
)
async def server(self, context):
return await server_command()(self, context)
@commands.hybrid_command(
name="afc",
description="Help with AFC Connection Failure issues"
)
async def afc(self, context):
return await afc_command()(self, context)
@commands.hybrid_command(
name="udid",
description="SideStore could not determine device UDID"
)
async def udid(self, context):
return await udid_command()(self, context)
@commands.hybrid_command(
name="half",
description="Help with half-installed apps"
)
async def half(self, context):
return await half_command()(self, context)
@commands.hybrid_command(
name="sparse",
description="Help with sparse bundle issues"
)
async def sparse(self, context):
return await sparse_command()(self, context)
async def setup(bot) -> None:
cog = Sidestore(bot)
await bot.add_cog(cog)
bot.logger.info("Loaded extension 'sidestore.sidestore'")
bot.logger.info("Loaded extension 'sidestore.refresh'")
bot.logger.info("Loaded extension 'sidestore.code'")
bot.logger.info("Loaded extension 'sidestore.crash'")
bot.logger.info("Loaded extension 'sidestore.pairing'")
bot.logger.info("Loaded extension 'sidestore.server'")
bot.logger.info("Loaded extension 'sidestore.afc'")
bot.logger.info("Loaded extension 'sidestore.udid'")
bot.logger.info("Loaded extension 'sidestore.half'")
bot.logger.info("Loaded extension 'sidestore.sparse'")

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Afc(commands.Cog, name="afc"): def afc_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="afc", description="Help with AFC Connection Failure issues" name="afc", description="Help with AFC Connection Failure issues"
) )
async def afc(self, context: Context) -> None: async def afc(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -45,5 +42,4 @@ class Afc(commands.Cog, name="afc"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return afc
await bot.add_cog(Afc(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Code(commands.Cog, name="code"): def code_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="code", description="No code received when signing in with Apple ID" name="code", description="No code received when signing in with Apple ID"
) )
async def code(self, context: Context) -> None: async def code(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -59,5 +56,4 @@ class Code(commands.Cog, name="code"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return code
await bot.add_cog(Code(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Crash(commands.Cog, name="crash"): def crash_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="crash", description="Help with SideStore crashing issues" name="crash", description="Help with SideStore crashing issues"
) )
async def crash(self, context: Context) -> None: async def crash(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -43,5 +40,4 @@ class Crash(commands.Cog, name="crash"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return crash
await bot.add_cog(Crash(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Half(commands.Cog, name="half"): def half_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="half", description="Help when apps get stuck installing" name="half", description="Help when apps get stuck installing"
) )
async def half(self, context: Context) -> None: async def half(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -52,5 +49,4 @@ class Half(commands.Cog, name="half"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return half
await bot.add_cog(Half(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Pairing(commands.Cog, name="pairing"): def pairing_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="pairing", description="Help with pairing file issues" name="pairing", description="Help with pairing file issues"
) )
async def pairing(self, context: Context) -> None: async def pairing(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -57,5 +54,4 @@ class Pairing(commands.Cog, name="pairing"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return pairing
await bot.add_cog(Pairing(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Refresh(commands.Cog, name="refresh"): def refresh_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="refresh", description="Help with refreshing or installing apps" name="refresh", description="Help with refreshing or installing apps"
) )
async def refresh(self, context: Context) -> None: async def refresh(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -47,5 +44,4 @@ class Refresh(commands.Cog, name="refresh"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return refresh
await bot.add_cog(Refresh(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Server(commands.Cog, name="server"): def server_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="server", description="Help with anisette server issues" name="server", description="Help with anisette server issues"
) )
async def server(self, context: Context) -> None: async def server(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -51,5 +48,4 @@ class Server(commands.Cog, name="server"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return server
await bot.add_cog(Server(bot))

View File

@@ -107,14 +107,11 @@ class SidestoreView(discord.ui.View):
self.add_item(SidestoreSelect(bot)) self.add_item(SidestoreSelect(bot))
class Sidestore(commands.Cog, name="sidestore"): def sidestore_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="sidestore", description="SideStore troubleshooting and help" name="sidestore", description="SideStore troubleshooting and help"
) )
async def sidestore(self, context: Context) -> None: async def sidestore(self, context):
embed = discord.Embed( embed = discord.Embed(
title="SideStore Commands", title="SideStore Commands",
description="Choose a command from the dropdown below to get help with specific issues:", description="Choose a command from the dropdown below to get help with specific issues:",
@@ -129,6 +126,4 @@ class Sidestore(commands.Cog, name="sidestore"):
else: else:
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
return sidestore
async def setup(bot) -> None:
await bot.add_cog(Sidestore(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Sparse(commands.Cog, name="sparse"): def sparse_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="sparse", description="Information about SparseRestore exploit" name="sparse", description="Information about SparseRestore exploit"
) )
async def sparse(self, context: Context) -> None: async def sparse(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -46,5 +43,4 @@ class Sparse(commands.Cog, name="sparse"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return sparse
await bot.add_cog(Sparse(bot))

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time import time
class Udid(commands.Cog, name="udid"): def udid_command():
def __init__(self, bot) -> None:
self.bot = bot
@commands.hybrid_command( @commands.hybrid_command(
name="udid", description="SideStore could not determine device UDID" name="udid", description="SideStore could not determine device UDID"
) )
async def udid(self, context: Context) -> None: async def udid(self, context):
embed = discord.Embed( embed = discord.Embed(
color=0x8e82f9, color=0x8e82f9,
description=( description=(
@@ -45,5 +42,4 @@ class Udid(commands.Cog, name="udid"):
await context.send(embed=embed, view=view) await context.send(embed=embed, view=view)
async def setup(bot) -> None: return udid
await bot.add_cog(Udid(bot))