Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hybrid commands #113

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cogs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def search_name(self, arg, compatlist):
matchlist.append(game)
return matchlist

@commands.command(aliases=["nbcompat", "ndscompat"], usage="[title id|game name]")
@commands.hybrid_command(aliases=["nbcompat", "ndscompat"], usage="[title id|game name]")
@gspreadkey_exists()
async def ndsbcompat(self, ctx, *, title: Optional[str]):
"""
Expand Down Expand Up @@ -275,7 +275,7 @@ async def update_netinfo(self):

self.netinfo_embed = embed

@commands.command()
@commands.hybrid_command()
async def netinfo(self, ctx):
"""Shows the Nintendo Network status information"""
if await self.bot.is_owner(ctx.author):
Expand Down Expand Up @@ -320,7 +320,7 @@ async def udb(self, ctx, *, application=None):
menu = UDBMenu(source, ctx)
await menu.start()

@commands.group(invoke_without_command=True, case_insensitive=True)
@commands.hybrid_group(invoke_without_command=True, case_insensitive=True)
async def skins(self, ctx):
"""Displays an embed with a link to a database of TWiLight Menu++ skins and Unlaunch backgrounds\n
To show a random skin: `skins [console] -r`
Expand Down Expand Up @@ -512,7 +512,7 @@ async def gbatek(self, ctx, *, page):
menu = GbatekMenu(links, ctx)
await menu.start()

@commands.command(aliases=['mkey'])
@commands.hybrid_command(aliases=['mkey'])
async def generatemkey(self, ctx, device: str, month: int, day: int, inquiry: str, deviceid: Optional[str] = None):
"""
Generate an mkey for given device.
Expand Down
48 changes: 24 additions & 24 deletions cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ async def guide(self, ctx, guide: Literal("3ds", "wiiu", "vwii", "switch", "wii"
embed.description = "The complete guide to modding your Nintendo DSi"
await ctx.send(embed=embed)

@commands.group(invoke_without_command=True, case_insensitive=True)
@commands.hybrid_group(invoke_without_command=True, case_insensitive=True)
async def install(self, ctx):
"""Links and/or information on installing apps"""
await ctx.send_help(ctx.command)
Expand Down Expand Up @@ -242,7 +242,7 @@ async def unlaunch_install(self, ctx):
embed.description = "How to install Unlaunch on the DSi"
await ctx.send(embed=embed)

@commands.group(invoke_without_command=True, case_insensitive=True)
@commands.hybrid_group(invoke_without_command=True, case_insensitive=True)
async def uninstall(self, ctx):
"""Links and/or information on uninstalling apps"""
await ctx.send_help(ctx.command)
Expand Down Expand Up @@ -279,15 +279,15 @@ async def hiyacfw_uninstall(self, ctx):
embed.description = "How to uninstall hiyaCFW on the DSi"
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def twlfix(self, ctx):
"""Information on how to fix a broken TWL Partition"""
await self.simple_embed(ctx, """
Follow [TWLFix-CFW](https://github.com/MechanicalDragon0687/TWLFix-CFW/releases/).
These instructions require that you **perform a system update** after running the app.
""", title="Fix broken TWL")

@commands.command()
@commands.hybrid_command()
async def twlmanual(self, ctx):
"""How to access TWiLight Menu++ Instruction Manual"""
embed = discord.Embed(title="How to access TWiLight Menu++ Instruction Manual")
Expand All @@ -299,7 +299,7 @@ async def twlmanual(self, ctx):
embed.add_field(name="Online", value=cleandoc("""The TWiLight Menu++ manual is also available online at https://manual.ds-homebrew.com."""), inline=False)
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def twlsettings(self, ctx):
"""How to access TWiLight Menu++ Settings"""
title = "How to access TWiLight Menu++ Settings"
Expand All @@ -313,7 +313,7 @@ async def twlsettings(self, ctx):
view = TWLMThemeMenu(ctx, title, initDescription, themeSteps)
await view.start()

@commands.command()
@commands.hybrid_command()
async def slot1launch(self, ctx):
"""How to launch the Slot-1 Game Card from TWiLight Menu++"""
title = "How to launch the Slot-1 Game Card from TWiLight Menu++"
Expand All @@ -327,7 +327,7 @@ async def slot1launch(self, ctx):
view = TWLMThemeMenu(ctx, title, initDescription, themeSteps)
await view.start()

@commands.command(aliases=["dsimenulaunch"])
@commands.hybrid_command(aliases=["dsimenulaunch"])
async def homemenulaunch(self, ctx):
"""How to launch the DSi Menu / 3DS HOME Menu from TWiLight Menu++"""
title = "How to launch the DSi Menu / 3DS HOME Menu from TWiLight Menu++"
Expand All @@ -341,7 +341,7 @@ async def homemenulaunch(self, ctx):
view = TWLMThemeMenu(ctx, title, initDescription, themeSteps)
await view.start()

@commands.command(aliases=["sd-card-setup", "sdformat"])
@commands.hybrid_command(aliases=["sd-card-setup", "sdformat"])
async def formatsd(self, ctx):
"""Displays an embed with a link that tells you how to properly format your SD card"""
embed = discord.Embed(title="SD Card Setup")
Expand All @@ -351,7 +351,7 @@ async def formatsd(self, ctx):
embed.description = "How to properly format your SD card"
await ctx.send(embed=embed)

@commands.command(aliases=["nanddump", "nandbackup"])
@commands.hybrid_command(aliases=["nanddump", "nandbackup"])
async def nand(self, ctx):
"""Links to the NAND dumping guide"""
embed = discord.Embed(title="Dumping NAND")
Expand All @@ -361,7 +361,7 @@ async def nand(self, ctx):
embed.description = "How to dump your DSi's NAND"
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def vc(self, ctx):
"""Links to the 3DS Virtual Console Inject guide"""
embed = discord.Embed(title="Virtual Console Injects for 3DS")
Expand All @@ -371,7 +371,7 @@ async def vc(self, ctx):
embed.description = "The recommended way to play old classics on your 3DS"
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def dump(self, ctx):
"""How to dump games and data for CFW consoles"""
await self.simple_embed(ctx, text="""
Expand All @@ -380,7 +380,7 @@ async def dump(self, ctx):
[Dumping DSiWare](https://dsi.cfw.guide/dsiware-backups.html)
""", title="Dumping Games to ROM files")

@commands.group(invoke_without_command=True, case_insensitive=True)
@commands.hybrid_group(invoke_without_command=True, case_insensitive=True)
async def nightly(self, ctx):
"""Instructions on installing nightly builds"""
await ctx.send_help(ctx.command)
Expand All @@ -399,7 +399,7 @@ async def ndsbootstrap_nightly(self, ctx):
On the 3DS, this can be installed from Universal Updater. Select nds-bootstrap, then install the [nightly] build."
await self.simple_embed(ctx, description, title="nds-bootstrap nightly")

@commands.command(aliases=["crowdin"])
@commands.hybrid_command(aliases=["crowdin"])
async def translate(self, ctx):
"""Links to Crowdin projects"""
crowdin_baseurl = "https://crowdin.com/project"
Expand All @@ -414,7 +414,7 @@ async def translate(self, ctx):
view.add_item(discord.ui.Button(label="DSi Guide", url=f"{crowdin_baseurl}/dsi-guide"))
await ctx.send(embed=embed, view=view)

@commands.command(aliases=["colour"])
@commands.hybrid_command(aliases=["colour"])
async def color(self, ctx, *, color):
"""Displays conversions of a color from #RRGGBB, #RGB, RRR GGG BBB, and BGR15"""

Expand Down Expand Up @@ -445,14 +445,14 @@ async def color(self, ctx, *, color):
embed.add_field(name="BGR15", value=f"`0x{bgr15:04X}` `0x{bgr15 | 1 << 15:04X}`")
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def sdroot(self, ctx):
"""Displays an image that shows what a root is"""
embed = discord.Embed()
embed.set_image(url="https://media.discordapp.net/attachments/489307733074640926/756947922804932739/wherestheroot.png")
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def sdlock(self, ctx):
"""Tells you how to disable write protection on an SD Card"""
embed = discord.Embed(title="Disable write protection on an SD Card")
Expand All @@ -464,7 +464,7 @@ async def sdlock(self, ctx):
embed.set_image(url="https://i.imgur.com/RvKjWcz.png")
await ctx.send(embed=embed)

@commands.group(aliases=["flashcard", "flashcards", "flashcarts"], invoke_without_command=True, case_insensitive=True)
@commands.hybrid_group(aliases=["flashcard", "flashcards", "flashcarts"], invoke_without_command=True, case_insensitive=True)
async def flashcart(self, ctx):
"""Links the r/flashcarts quick start guide for a given console"""
await ctx.send_help(ctx.command)
Expand All @@ -489,7 +489,7 @@ async def gba(self, ctx):
embed.set_thumbnail(url="https://b.thumbs.redditmedia.com/lBsOPXDyCx0p1MSx1qCdAtglHB4nineg5w9-3KHzO2A.png")
await ctx.send(embed=embed)

@commands.command(aliases=["twlboot"])
@commands.hybrid_command(aliases=["twlboot"])
async def dsiboot(self, ctx):
"""Tells you how to automatically boot TWiLight Menu++ with Unlaunch"""
embed = discord.Embed(title="How to launch TWiLight Menu++ automatically with Unlaunch")
Expand All @@ -501,15 +501,15 @@ async def dsiboot(self, ctx):
""")
await ctx.send(embed=embed)

@commands.command(name="7-zip", aliases=["7zip", "7z"])
@commands.hybrid_command(name="7-zip", aliases=["7zip", "7z"])
async def sevenzip(self, ctx):
"""Links to the 7-Zip website"""
embed = discord.Embed(title="7-Zip")
embed.url = "https://www.7-zip.org/"
embed.description = "7-Zip is the recommended program for Windows users to use to extract .7z files, such as the one TWiLight Menu++ comes in.\nMost people should download the '64-bit x64' version."
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def ysmenu(self, ctx):
"""Links to RetroGameFan's YSMenu download page"""
embed = discord.Embed(title="RetroGameFan's YSMenu")
Expand All @@ -519,17 +519,17 @@ async def ysmenu(self, ctx):
embed.set_thumbnail(url="https://gbatemp.net/data/avatars/l/221/221134.jpg?1570890734")
await ctx.send(embed=embed)

@commands.command()
@commands.hybrid_command()
async def lazydsi(self, ctx):
"""Tells you to stop trying to use it (and/or the vguide)"""
embed = discord.Embed(title="Lazy DSi Downloader is deprecated")
embed.description = "This application is deprecated. Please read the [guide](https://dsi.cfw.guide)."
await ctx.send(embed=embed)

@commands.command()
async def cardflagcheck(self, ctx, inputFlags: str):
@commands.hybrid_command()
async def cardflagcheck(self, ctx, flags: str):
try:
card = NDSCardFlagCheck(int(inputFlags, 16))
card = NDSCardFlagCheck(int(flags, 16))
except ValueError:
return await ctx.send("Input is not a valid hex number. Please try again.")
await ctx.send(f"0x{card.inputFlags:08X} = {card.calculate()}")
Expand Down
2 changes: 1 addition & 1 deletion cogs/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Meta(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.command(aliases=["botinfo", "whoisthisbot"])
@commands.hybrid_command(aliases=["botinfo", "whoisthisbot"])
async def about(self, ctx):
"""About TWLHelper"""
embed = discord.Embed(title="About TWLHelper")
Expand Down
4 changes: 2 additions & 2 deletions cogs/nointro.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def cog_check(self, ctx):
raise commands.CheckFailure()
return True

@commands.command(usage="<title id|game name> <sha1 hash>")
@commands.hybrid_command(usage="<title id|game name> <sha1 hash>")
async def nicompare(self, ctx, gamecode: str, sha1hash: str):
"""
Compares input ROM and hash against No-Intro.
Expand Down Expand Up @@ -99,7 +99,7 @@ def search_name(self, arg):
matchlist.append(game)
return matchlist

@commands.command(usage="[title id|game name]")
@commands.hybrid_command(usage="[title id|game name]")
async def nilookup(self, ctx, *, title: Optional[str]):
"""
Shows a No-Intro database entry.
Expand Down
Loading