mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
feat(melonx): cog with transfer command and help integration
Introduces a new 'melonx' cog with a dropdown help menu and a 'transfer' command for save file migration instructions. Updates help command categories and README to include MeloNX. Implements UI components for command selection and embeds for user guidance.
This commit is contained in:
73
cogs/melonx/__init__.py
Normal file
73
cogs/melonx/__init__.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from .melonx import MelonxView
|
||||
from .transfer import transfer_command
|
||||
|
||||
class Melonx(commands.GroupCog, name="melonx"):
|
||||
def __init__(self, bot) -> None:
|
||||
self.bot = bot
|
||||
super().__init__()
|
||||
|
||||
@commands.group(name="melonx", invoke_without_command=True)
|
||||
async def melonx_group(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="MeloNX Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
view = MelonxView(self.bot)
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
@melonx_group.command(name="help")
|
||||
async def melonx_group_help(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="MeloNX Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
view = MelonxView(self.bot)
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
@melonx_group.command(name="transfer")
|
||||
async def melonx_group_transfer(self, context: Context):
|
||||
await self._invoke_hybrid(context, "transfer")
|
||||
|
||||
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 MeloNX command: {name}")
|
||||
|
||||
@app_commands.command(
|
||||
name="help",
|
||||
description="MeloNX troubleshooting help"
|
||||
)
|
||||
async def help(self, interaction: discord.Interaction):
|
||||
embed = discord.Embed(
|
||||
title="MeloNX Commands",
|
||||
description="Choose a command from the dropdown below to get help with specific issues:",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
view = MelonxView(self.bot)
|
||||
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="transfer",
|
||||
description="How to transfer save files from other emulators or platforms"
|
||||
)
|
||||
async def transfer(self, context):
|
||||
return await transfer_command()(self, context)
|
||||
|
||||
async def setup(bot) -> None:
|
||||
cog = Melonx(bot)
|
||||
await bot.add_cog(cog)
|
||||
|
||||
bot.logger.info("Loaded extension 'melonx.help'")
|
||||
bot.logger.info("Loaded extension 'melonx.transfer'")
|
||||
66
cogs/melonx/melonx.py
Normal file
66
cogs/melonx/melonx.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
|
||||
class MelonxSelect(discord.ui.Select):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
options = [
|
||||
discord.SelectOption(
|
||||
label="Transfer",
|
||||
value="transfer",
|
||||
description="How to transfer save files from other emulators or platforms",
|
||||
),
|
||||
]
|
||||
super().__init__(placeholder="Choose a MeloNX command...", options=options)
|
||||
|
||||
async def callback(self, interaction: discord.Interaction):
|
||||
command_name = self.values[0]
|
||||
command = self.bot.get_command(command_name)
|
||||
|
||||
if command:
|
||||
try:
|
||||
ctx = await self.bot.get_context(interaction.message)
|
||||
if ctx:
|
||||
await ctx.invoke(command)
|
||||
embed = discord.Embed(
|
||||
title="Command Executed",
|
||||
description=f"Successfully executed `/{command_name}`",
|
||||
color=0x00FF00
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
except discord.Forbidden:
|
||||
self.bot.logger.warning(f"Bot missing permissions in server {interaction.guild.name} (ID: {interaction.guild.id}) - cannot execute {command_name} command")
|
||||
embed = discord.Embed(
|
||||
title="Permission Error",
|
||||
description="The bot doesn't have the required permissions in this server to execute this command. Use the slash command `/{command_name}` instead.",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
except Exception as e:
|
||||
self.bot.logger.error(f"Error executing {command_name} command: {e}")
|
||||
embed = discord.Embed(
|
||||
title="Error",
|
||||
description="An error occurred while executing the command.",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Error",
|
||||
description="Command not found!",
|
||||
color=0x963155
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.png")
|
||||
await interaction.response.edit_message(embed=embed, view=None)
|
||||
|
||||
|
||||
class MelonxView(discord.ui.View):
|
||||
def __init__(self, bot):
|
||||
super().__init__()
|
||||
self.add_item(MelonxSelect(bot))
|
||||
52
cogs/melonx/transfer.py
Normal file
52
cogs/melonx/transfer.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import discord
|
||||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
import time
|
||||
|
||||
|
||||
def transfer_command():
|
||||
@commands.hybrid_command(
|
||||
name="transfer", description="How to transfer save files from other emulators or platforms"
|
||||
)
|
||||
async def transfer(self, context):
|
||||
embed = discord.Embed(
|
||||
color=0x963155,
|
||||
description=(
|
||||
'# How do I transfer my save files from another emulator, my pc, or other platform?\n\n---\n\n' +
|
||||
'### **Ryujinx Based**: \n' +
|
||||
'1. Go too Ryujinx\'s main directory -> copy and and transfer the **"bis"** folder to your iDevice.\n' +
|
||||
'2. Replace the **"bis"** folder in MeloNX with the one you transferred over.\n\n' +
|
||||
'### **Yuzu Based**:\n' +
|
||||
'1. Go to Yuzu\'s main directory and locate "**nand**" then go to -> users -> save\n' +
|
||||
'2. Get the **title ID** of the game you want to transfer to by locating the game on MeloNX, hold down on it and press "Game Info" \n' +
|
||||
'3. Then search the title ID within the **save** folder\n' +
|
||||
'4. Open that folder labeled your title ID and copy of all of the contents to your iDevice\n' +
|
||||
'5. Boot the game once in MeloNX so the save directories appear and is the latest created\n' +
|
||||
'6. On your iDevice, go into files-> MeloNX -> bis -> user -> save\n' +
|
||||
'7. In the save folder, there will be many folders named 0000001, 0000002, etc\n' +
|
||||
'8. Sort by last modified or open each one too see the modified date/time of the files\n' +
|
||||
'9. Once you\'ve found the newest one, inside will be two folders named 1 and 0, one will have a brand new save file inside.\n' +
|
||||
'10. drop the contents copied from the title ID folder in Yuzu into that directory and press "replace" when prompted.\n' +
|
||||
'11. Launch the game again in MeloNX to verify the transfer.'
|
||||
)
|
||||
)
|
||||
embed.set_author(name="MeloNX", icon_url="https://yes.nighty.works/raw/TLGaVa.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/melonx/transfer.py",
|
||||
emoji="<:githubicon:1417717356846776340>"
|
||||
))
|
||||
|
||||
if context.interaction:
|
||||
await context.interaction.response.send_message(embed=embed, view=view)
|
||||
else:
|
||||
await context.send(embed=embed, view=view)
|
||||
|
||||
|
||||
return transfer
|
||||
Reference in New Issue
Block a user