diff --git a/cogs/general/help.py b/cogs/general/help.py index 018dd84..b476402 100644 --- a/cogs/general/help.py +++ b/cogs/general/help.py @@ -79,6 +79,7 @@ class Help(commands.Cog, name="help"): "noapps": "idevice", "errorcodes": "idevice", "developermode": "idevice", + "mountddi": "idevice", # Owner Commands "sync": "owner", diff --git a/cogs/idevice/error_codes.py b/cogs/idevice/error_codes.py index 9f00fb9..cc616f2 100644 --- a/cogs/idevice/error_codes.py +++ b/cogs/idevice/error_codes.py @@ -14,7 +14,7 @@ class ErrorCodes(commands.Cog, name="errorcodes"): self.code_to_key = {error['code']: error['name'] for error in self.errors} def load_errors(self): - json_path = os.path.join(os.path.dirname(__file__), 'errorcodes.json') + json_path = os.path.join(os.path.dirname(__file__), 'files/errorcodes.json') try: with open(json_path, 'r', encoding='utf-8') as f: return json.load(f) diff --git a/cogs/idevice/files/DDI.zip b/cogs/idevice/files/DDI.zip new file mode 100644 index 0000000..8108198 Binary files /dev/null and b/cogs/idevice/files/DDI.zip differ diff --git a/cogs/idevice/errorcodes.json b/cogs/idevice/files/errorcodes.json similarity index 100% rename from cogs/idevice/errorcodes.json rename to cogs/idevice/files/errorcodes.json diff --git a/cogs/idevice/idevice.py b/cogs/idevice/idevice.py index d9551b3..75c8390 100644 --- a/cogs/idevice/idevice.py +++ b/cogs/idevice/idevice.py @@ -9,7 +9,7 @@ import math def load_error_codes(): try: - json_path = os.path.join(os.path.dirname(__file__), 'errorcodes.json') + json_path = os.path.join(os.path.dirname(__file__), 'files/errorcodes.json') with open(json_path, 'r', encoding='utf-8') as f: return json.load(f) except FileNotFoundError: @@ -159,6 +159,11 @@ class ideviceSelect(discord.ui.Select): value="developermode", description="How to turn on developer mode", ), + discord.SelectOption( + label="Mount DDI", + value="mountddi", + description="How to manually mount DDI", + ), ] super().__init__(placeholder="Choose an idevice command...", options=options) diff --git a/cogs/idevice/mountddi.py b/cogs/idevice/mountddi.py new file mode 100644 index 0000000..57d7236 --- /dev/null +++ b/cogs/idevice/mountddi.py @@ -0,0 +1,68 @@ +import discord +from discord import app_commands +from discord.ext import commands +from discord.ext.commands import Context +import time +import os + + +class Mountddi(commands.Cog, name="mountddi"): + def __init__(self, bot) -> None: + self.bot = bot + + @commands.hybrid_command( + name="mountddi", description="How to manually mount DDI" + ) + async def mountddi(self, context: Context) -> None: + embed = discord.Embed( + color=0xfa8c4a, + description=( + '# How to Manually Mount DDI\n\n---\n\n' + + '1. **Download the DDI.zip file attached above:**\n' + + ' - Save it to your device and extract the contents\n\n' + + '2. **Replace the DDI folder in StikDebug:**\n' + + ' - Navigate to the StikDebug default directory on your iPhone/iPad\n' + + ' - Delete the existing DDI folder completely\n' + + ' - Replace it with the DDI folder from the downloaded zip\n' + + ' - Make sure it\'s in the StikDebug default directory\n\n' + + '3. **Restart and retry:**\n' + + ' - Completely restart StikDebug\n' + + ' - See if you get the same error again\n\n' + ) + ) + embed.set_author(name="idevice", icon_url="https://yes.nighty.works/raw/snLMuO.png") + embed.set_footer(text=f'Last Edited by neoarz') + embed.timestamp = discord.utils.utcnow() + + view = discord.ui.View() + view.add_item(discord.ui.Button( + label="Edit Command", + style=discord.ButtonStyle.secondary, + url="https://github.com/neoarz/Syntrel/blob/main/cogs/idevice/mountddi.py", + emoji="<:githubicon:1417717356846776340>" + )) + + ddi_file_path = os.path.join(os.path.dirname(__file__), 'files/DDI.zip') + + try: + if context.interaction: + if os.path.exists(ddi_file_path): + file = discord.File(ddi_file_path, filename='DDI.zip') + await context.interaction.response.send_message(embed=embed, view=view, file=file) + else: + await context.interaction.response.send_message(embed=embed, view=view) + else: + if os.path.exists(ddi_file_path): + file = discord.File(ddi_file_path, filename='DDI.zip') + await context.send(embed=embed, view=view, file=file) + else: + await context.send(embed=embed, view=view) + except discord.NotFound: + if context.interaction: + await context.interaction.followup.send(embed=embed, view=view) + else: + await context.send(embed=embed, view=view) + + +async def setup(bot) -> None: + await bot.add_cog(Mountddi(bot))