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):
try:
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}'")
except Exception as 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))
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:
if subcommand.name in seen_names:
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
class Afc(commands.Cog, name="afc"):
def __init__(self, bot) -> None:
self.bot = bot
def afc_command():
@commands.hybrid_command(
name="afc", description="Help with AFC Connection Failure issues"
)
async def afc(self, context: Context) -> None:
async def afc(self, context):
embed = discord.Embed(
color=0x8e82f9,
description=(
@@ -45,5 +42,4 @@ class Afc(commands.Cog, name="afc"):
await context.send(embed=embed, view=view)
async def setup(bot) -> None:
await bot.add_cog(Afc(bot))
return afc

View File

@@ -5,14 +5,11 @@ from discord.ext.commands import Context
import time
class Code(commands.Cog, name="code"):
def __init__(self, bot) -> None:
self.bot = bot
def code_command():
@commands.hybrid_command(
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(
color=0x8e82f9,
description=(
@@ -59,5 +56,4 @@ class Code(commands.Cog, name="code"):
await context.send(embed=embed, view=view)
async def setup(bot) -> None:
await bot.add_cog(Code(bot))
return code

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -107,14 +107,11 @@ class SidestoreView(discord.ui.View):
self.add_item(SidestoreSelect(bot))
class Sidestore(commands.Cog, name="sidestore"):
def __init__(self, bot) -> None:
self.bot = bot
def sidestore_command():
@commands.hybrid_command(
name="sidestore", description="SideStore troubleshooting and help"
)
async def sidestore(self, context: Context) -> None:
async def sidestore(self, context):
embed = discord.Embed(
title="SideStore Commands",
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:
await context.send(embed=embed, view=view)
async def setup(bot) -> None:
await bot.add_cog(Sidestore(bot))
return sidestore

View File

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

View File

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