mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
refactor(idevice): cog commands and add help group
Reworked the idevice cog to use a command group with subcommands for help, errorcodes, developermode, noapps, and mountddi. Added a dropdown view for help commands and improved logging for extension loading. Updated references to ideviceView and adjusted extension load conditions in bot.py.
This commit is contained in:
2
bot.py
2
bot.py
@@ -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 ["owner"]:
|
if folder in ["owner", "help"]:
|
||||||
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}"
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import discord
|
import discord
|
||||||
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
|
|
||||||
from .idevice import idevice_command
|
from .idevice import ideviceView
|
||||||
from .error_codes import errorcodes_command
|
from .error_codes import errorcodes_command
|
||||||
from .developermode import developermode_command
|
from .developermode import developermode_command
|
||||||
from .noapps import noapps_command
|
from .noapps import noapps_command
|
||||||
@@ -13,12 +14,64 @@ class Idevice(commands.GroupCog, name="idevice"):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
@commands.hybrid_command(
|
@commands.group(name="idevice", invoke_without_command=True)
|
||||||
name="idevice",
|
async def idevice_group(self, context: Context):
|
||||||
description="Get help with idevice commands and troubleshooting."
|
embed = discord.Embed(
|
||||||
|
title="idevice Commands",
|
||||||
|
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||||
|
color=0xfa8c4a
|
||||||
)
|
)
|
||||||
async def idevice(self, context):
|
embed.set_author(name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png")
|
||||||
return await idevice_command()(self, context)
|
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}")
|
||||||
|
|
||||||
|
@idevice_group.command(name="errorcodes")
|
||||||
|
async def idevice_group_errorcodes(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "errorcodes")
|
||||||
|
|
||||||
|
@idevice_group.command(name="developermode")
|
||||||
|
async def idevice_group_developermode(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "developermode")
|
||||||
|
|
||||||
|
@idevice_group.command(name="noapps")
|
||||||
|
async def idevice_group_noapps(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "noapps")
|
||||||
|
|
||||||
|
@idevice_group.command(name="mountddi")
|
||||||
|
async def idevice_group_mountddi(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "mountddi")
|
||||||
|
|
||||||
|
@app_commands.command(
|
||||||
|
name="help",
|
||||||
|
description="idevice troubleshooting help"
|
||||||
|
)
|
||||||
|
async def help(self, interaction: discord.Interaction):
|
||||||
|
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 interaction.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||||
|
|
||||||
@commands.hybrid_command(
|
@commands.hybrid_command(
|
||||||
name="errorcodes",
|
name="errorcodes",
|
||||||
@@ -52,7 +105,7 @@ async def setup(bot) -> None:
|
|||||||
cog = Idevice(bot)
|
cog = Idevice(bot)
|
||||||
await bot.add_cog(cog)
|
await bot.add_cog(cog)
|
||||||
|
|
||||||
bot.logger.info("Loaded extension 'idevice.idevice'")
|
bot.logger.info("Loaded extension 'idevice.help'")
|
||||||
bot.logger.info("Loaded extension 'idevice.errorcodes'")
|
bot.logger.info("Loaded extension 'idevice.errorcodes'")
|
||||||
bot.logger.info("Loaded extension 'idevice.developermode'")
|
bot.logger.info("Loaded extension 'idevice.developermode'")
|
||||||
bot.logger.info("Loaded extension 'idevice.noapps'")
|
bot.logger.info("Loaded extension 'idevice.noapps'")
|
||||||
|
|||||||
Reference in New Issue
Block a user