2018-12-23 14:27:06 +00:00
|
|
|
import re
|
|
|
|
import discord
|
|
|
|
|
|
|
|
from discord.ext import commands
|
2018-12-26 11:36:55 +00:00
|
|
|
from helpers.errcodes import *
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-23 17:36:40 +00:00
|
|
|
|
2018-12-23 14:27:06 +00:00
|
|
|
class Err:
|
2018-12-26 11:36:55 +00:00
|
|
|
"""Everything related to Nintendo 3DS, Wii U and Switch error codes"""
|
2018-12-23 14:27:06 +00:00
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
2018-12-23 14:39:03 +00:00
|
|
|
self.dds_re = re.compile(r'0\d{2}\-\d{4}')
|
|
|
|
self.wiiu_re = re.compile(r'1\d{2}\-\d{4}')
|
|
|
|
self.switch_re = re.compile(r'2\d{3}\-\d{4}')
|
2018-12-24 08:09:35 +00:00
|
|
|
self.no_err_desc = "It seems like your error code is unknown. "\
|
|
|
|
"You should report relevant details to "\
|
|
|
|
"<@141532589725974528> (tomGER) "\
|
|
|
|
"so it can be added to the bot."
|
|
|
|
self.rickroll = "https://www.youtube.com/watch?v=x3yXlomPCmU"
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-24 00:40:06 +00:00
|
|
|
@commands.command(aliases=["nxerr", "serr", "nin_err", "ninerr"])
|
2018-12-23 14:27:06 +00:00
|
|
|
async def err(self, ctx, err: str):
|
2018-12-23 17:01:31 +00:00
|
|
|
"""Searches for Nintendo 3DS, Switch and Wii U error codes!
|
|
|
|
Usage: .serr/.nxerr/.nin_err/.err <Error Code>"""
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-23 17:36:40 +00:00
|
|
|
if self.dds_re.match(err): # 3DS - dds -> Drei DS -> Three DS
|
2018-12-23 16:16:56 +00:00
|
|
|
if err in dds_errcodes:
|
|
|
|
err_description = dds_errcodes[err]
|
|
|
|
else:
|
2018-12-24 08:09:35 +00:00
|
|
|
err_description = self.no_err_desc
|
2018-12-23 16:16:56 +00:00
|
|
|
# Make a nice Embed out of it
|
2018-12-23 17:36:40 +00:00
|
|
|
embed = discord.Embed(title=err,
|
2018-12-24 08:09:35 +00:00
|
|
|
url=self.rickroll,
|
2018-12-23 17:36:40 +00:00
|
|
|
description=err_description)
|
2018-12-23 16:16:56 +00:00
|
|
|
embed.set_footer(text="Console: 3DS")
|
|
|
|
|
|
|
|
# Send message, crazy
|
|
|
|
await ctx.send(embed=embed)
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-24 08:09:35 +00:00
|
|
|
# These are not similar to the other errors apparently ... ?
|
|
|
|
elif err.startswith("0x"):
|
2018-12-23 16:46:03 +00:00
|
|
|
derr = err[2:]
|
|
|
|
derr = derr.strip()
|
|
|
|
rc = int(derr, 16)
|
|
|
|
desc = rc & 0x3FF
|
|
|
|
mod = (rc >> 10) & 0xFF
|
|
|
|
summ = (rc >> 21) & 0x3F
|
|
|
|
level = (rc >> 27) & 0x1F
|
2018-12-24 08:09:35 +00:00
|
|
|
if (mod in dds_modules) and\
|
|
|
|
(summ in dds_summaries) and\
|
|
|
|
(desc in dds_descriptions) and\
|
|
|
|
(level in dds_levels):
|
2018-12-23 16:46:03 +00:00
|
|
|
# ^ Lets just make extra sure that everything is right :P
|
2018-12-23 17:42:01 +00:00
|
|
|
embed = discord.Embed(title=f"0x{rc:X}")
|
2018-12-24 08:09:35 +00:00
|
|
|
embed.add_field(name="Module", value=dds_modules[mod])
|
|
|
|
embed.add_field(name="Description",
|
|
|
|
value=dds_descriptions[desc])
|
|
|
|
embed.add_field(name="Summary", value=dds_summaries[summ])
|
|
|
|
embed.add_field(name="Level", value=dds_levels[level])
|
2018-12-23 16:46:03 +00:00
|
|
|
embed.set_footer(text="Console: 3DS")
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
return
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-23 17:36:40 +00:00
|
|
|
elif self.wiiu_re.match(err): # Wii U
|
|
|
|
module = err[2:3] # Is that even true, idk just guessing
|
2018-12-23 16:29:14 +00:00
|
|
|
desc = err[5:8]
|
2018-12-23 16:16:56 +00:00
|
|
|
if err in wii_u_errors:
|
|
|
|
err_description = wii_u_errors[err]
|
|
|
|
else:
|
2018-12-24 08:09:35 +00:00
|
|
|
err_description = self.no_err_desc
|
2018-12-23 16:16:56 +00:00
|
|
|
|
|
|
|
# Make a nice Embed out of it
|
2018-12-23 17:42:01 +00:00
|
|
|
embed = discord.Embed(title=err,
|
2018-12-24 08:09:35 +00:00
|
|
|
url=self.rickroll,
|
2018-12-23 17:42:01 +00:00
|
|
|
description=err_description)
|
2018-12-23 16:16:56 +00:00
|
|
|
embed.set_footer(text="Console: Wii U")
|
|
|
|
embed.add_field(name="Module", value=module, inline=True)
|
|
|
|
embed.add_field(name="Description", value=desc, inline=True)
|
|
|
|
|
|
|
|
# Send message, crazy
|
2018-12-23 17:36:40 +00:00
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
|
|
|
if self.switch_re.match(err) or err.startswith("0x"): # Switch
|
2018-12-23 16:16:56 +00:00
|
|
|
|
2018-12-23 16:46:03 +00:00
|
|
|
if err.startswith("0x"):
|
|
|
|
err = err[2:]
|
|
|
|
errcode = int(err, 16)
|
|
|
|
module = errcode & 0x1FF
|
|
|
|
desc = (errcode >> 9) & 0x3FFF
|
2018-12-23 16:29:14 +00:00
|
|
|
else:
|
2018-12-23 16:46:03 +00:00
|
|
|
module = int(err[0:4]) - 2000
|
|
|
|
desc = int(err[5:9])
|
|
|
|
errcode = (desc << 9) + module
|
2018-12-23 17:36:40 +00:00
|
|
|
|
2018-12-23 17:42:01 +00:00
|
|
|
str_errcode = f'{(module + 2000):04}-{desc:04}'
|
2018-12-23 16:48:38 +00:00
|
|
|
|
2018-12-23 16:16:56 +00:00
|
|
|
# Searching for Modules in list
|
2018-12-23 14:27:06 +00:00
|
|
|
if module in switch_modules:
|
|
|
|
err_module = switch_modules[module]
|
|
|
|
else:
|
|
|
|
err_module = "Unknown"
|
|
|
|
|
2018-12-28 01:59:37 +00:00
|
|
|
# Set initial value unconditionally
|
|
|
|
err_description = self.no_err_desc
|
|
|
|
|
2018-12-24 08:09:35 +00:00
|
|
|
# Searching for error codes related to the Switch
|
|
|
|
# (doesn't include special cases)
|
2018-12-23 14:27:06 +00:00
|
|
|
if errcode in switch_known_errcodes:
|
|
|
|
err_description = switch_known_errcodes[errcode]
|
|
|
|
elif errcode in switch_support_page:
|
|
|
|
err_description = switch_support_page[errcode]
|
|
|
|
elif module in switch_known_errcode_ranges:
|
|
|
|
for errcode_range in switch_known_errcode_ranges[module]:
|
|
|
|
if desc >= errcode_range[0] and desc <= errcode_range[1]:
|
|
|
|
err_description = errcode_range[2]
|
2018-12-23 14:55:45 +00:00
|
|
|
|
2018-12-23 16:16:56 +00:00
|
|
|
# Make a nice Embed out of it
|
2018-12-23 17:42:01 +00:00
|
|
|
embed = discord.Embed(title=f"{str_errcode} / {hex(errcode)}",
|
2018-12-24 08:09:35 +00:00
|
|
|
url=self.rickroll,
|
2018-12-23 17:42:01 +00:00
|
|
|
description=err_description)
|
2018-12-23 14:55:45 +00:00
|
|
|
embed.set_footer(text="Console: Switch")
|
2018-12-24 08:09:35 +00:00
|
|
|
embed.add_field(name="Module",
|
|
|
|
value=f"{err_module} ({module})",
|
|
|
|
inline=True)
|
2018-12-23 14:55:45 +00:00
|
|
|
embed.add_field(name="Description", value=desc, inline=True)
|
|
|
|
|
2018-12-23 16:16:56 +00:00
|
|
|
# Send message, crazy
|
2019-01-29 10:50:04 +00:00
|
|
|
if "ban" in err_description:
|
|
|
|
await ctx.send("F", embed=embed)
|
|
|
|
else:
|
|
|
|
await ctx.send(embed=embed)
|
2018-12-23 14:27:06 +00:00
|
|
|
|
2018-12-24 08:09:35 +00:00
|
|
|
# Special case handling because Nintendo feels like
|
|
|
|
# its required to break their format lol
|
|
|
|
elif err in switch_game_err:
|
2018-12-23 17:36:40 +00:00
|
|
|
game, desc = switch_game_err[err].split(":")
|
2018-12-23 14:55:45 +00:00
|
|
|
|
2018-12-24 08:09:35 +00:00
|
|
|
embed = discord.Embed(title=err,
|
|
|
|
url=self.rickroll,
|
|
|
|
description=desc)
|
2018-12-23 14:55:45 +00:00
|
|
|
embed.set_footer(text="Console: Switch")
|
|
|
|
embed.add_field(name="Game", value=game, inline=True)
|
|
|
|
|
|
|
|
await ctx.send(embed=embed)
|
2018-12-23 14:27:06 +00:00
|
|
|
|
|
|
|
else:
|
2018-12-24 08:09:35 +00:00
|
|
|
await ctx.send("Unknown Format - This is either "
|
|
|
|
"no error code or you made some mistake!")
|
2018-12-23 14:32:22 +00:00
|
|
|
|
2018-12-23 17:01:31 +00:00
|
|
|
@commands.command(aliases=["e2h"])
|
|
|
|
async def err2hex(self, ctx, err: str):
|
|
|
|
"""Converts Nintendo Switch errors to hex
|
|
|
|
Usage: .err2hex <Error Code>"""
|
|
|
|
if self.switch_re.match(err):
|
|
|
|
module = int(err[0:4]) - 2000
|
|
|
|
desc = int(err[5:9])
|
|
|
|
errcode = (desc << 9) + module
|
|
|
|
await ctx.send(hex(errcode))
|
|
|
|
else:
|
2018-12-24 08:09:35 +00:00
|
|
|
await ctx.send("This doesn't follow the typical"
|
|
|
|
" Nintendo Switch 2XXX-XXXX format!")
|
2018-12-23 17:36:40 +00:00
|
|
|
|
2018-12-23 17:01:31 +00:00
|
|
|
@commands.command(aliases=["h2e"])
|
|
|
|
async def hex2err(self, ctx, err: str):
|
|
|
|
"""Converts Nintendo Switch errors to hex
|
|
|
|
Usage: .hex2err <Hex>"""
|
|
|
|
if err.startswith("0x"):
|
|
|
|
err = err[2:]
|
|
|
|
err = int(err, 16)
|
|
|
|
module = err & 0x1FF
|
|
|
|
desc = (err >> 9) & 0x3FFF
|
2018-12-23 17:42:01 +00:00
|
|
|
errcode = f'{(module + 2000):04}-{desc:04}'
|
2018-12-23 17:36:40 +00:00
|
|
|
await ctx.send(errcode)
|
2018-12-23 17:01:31 +00:00
|
|
|
else:
|
2018-12-23 17:36:40 +00:00
|
|
|
await ctx.send("This doesn't look like typical hex!")
|
2018-12-23 17:01:31 +00:00
|
|
|
|
2018-12-23 16:46:03 +00:00
|
|
|
|
2018-12-23 14:32:22 +00:00
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Err(bot))
|