mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2024-12-23 02:05:36 +00:00
Restructure some logic
This commit is contained in:
parent
758583ff33
commit
a66fcd14b7
95
cogs/err.py
95
cogs/err.py
|
@ -29,6 +29,25 @@ class Err:
|
|||
# Send message, crazy
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
elif err.startswith("0x"): # These are not similar to the other errors apperently ... ?
|
||||
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
|
||||
if mod in dds_modules and summ in dds_summaries and desc in dds_descriptions and level in dds_levels:
|
||||
# ^ Lets just make extra sure that everything is right :P
|
||||
embed = discord.Embed(title="0x{:X}".format(rc))
|
||||
embed.add_field(name="Module", value=dds_modules[mod], inline=False)
|
||||
embed.add_field(name="Description", value=dds_descriptions[desc], inline=False)
|
||||
embed.add_field(name="Summary", value=dds_summaries[summ], inline=False)
|
||||
embed.add_field(name="Level", value=dds_levels[level], inline=False)
|
||||
embed.set_footer(text="Console: 3DS")
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
return
|
||||
|
||||
elif self.wiiu_re.match(err): # Wii U
|
||||
module = err[2:3] # Is that even true, idk just guessing
|
||||
|
@ -47,30 +66,14 @@ class Err:
|
|||
# Send message, crazy
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
# Removing any chance of hex having to go to the awful guessing game we wil have to do soon
|
||||
elif err in switch_known_errcodes:
|
||||
err_description = switch_known_errcodes[err]
|
||||
serr = err[2:]
|
||||
errcode = int(serr, 16)
|
||||
if self.switch_re.match(err) or err.startswith("0x"): # Switch
|
||||
|
||||
if err.startswith("0x"):
|
||||
err = err[2:]
|
||||
errcode = int(err, 16)
|
||||
module = errcode & 0x1FF
|
||||
desc = (errcode >> 9) & 0x3FFF
|
||||
|
||||
if module in switch_modules:
|
||||
err_module = switch_modules[module]
|
||||
else:
|
||||
err_module = "Unknown"
|
||||
|
||||
# Make a nice Embed out of it
|
||||
embed = discord.Embed(title="{} / {}".format(errcode, err), url="https://www.youtube.com/watch?v=x3yXlomPCmU", description=err_description)
|
||||
embed.set_footer(text="Console: Switch")
|
||||
embed.add_field(name="Module", value="{} ({})".format(err_module, module), inline=True)
|
||||
embed.add_field(name="Description", value=desc, inline=True)
|
||||
|
||||
# Send message, crazy
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
elif self.switch_re.match(err): # Switch
|
||||
# Transforming into Hex
|
||||
module = int(err[0:4]) - 2000
|
||||
desc = int(err[5:9])
|
||||
errcode = (desc << 9) + module
|
||||
|
@ -111,57 +114,9 @@ class Err:
|
|||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
# The Guessing Game of Hex (Could be both 3DS or Switch so we have to constantly assume :P)
|
||||
elif err.startswith("0x"):
|
||||
err = err[2:] # Both work without the 0x
|
||||
# Most Switch Hex error should be detected by now so the chance that it's 3DS is much higher
|
||||
derr = err.strip()
|
||||
rc = int(derr, 16)
|
||||
desc = rc & 0x3FF
|
||||
mod = (rc >> 10) & 0xFF
|
||||
summ = (rc >> 21) & 0x3F
|
||||
level = (rc >> 27) & 0x1F
|
||||
if mod in dds_modules and summ in dds_summaries and desc in dds_descriptions and level in dds_levels:
|
||||
# ^ Lets just make extra sure that everything is right :P
|
||||
embed = discord.Embed(title="0x{:X}".format(rc))
|
||||
embed.add_field(name="Module", value=dds_modules[mod], inline=False)
|
||||
embed.add_field(name="Description", value=dds_descriptions[desc], inline=False)
|
||||
embed.add_field(name="Summary", value=dds_summaries[summ], inline=False)
|
||||
embed.add_field(name="Level", value=dds_levels[level], inline=False)
|
||||
embed.set_footer(text="Console: 3DS")
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
return
|
||||
|
||||
# Now lets just search for the last remaining switch errors to make sure
|
||||
errcode = int(err, 16)
|
||||
module = errcode & 0x1FF
|
||||
desc = (errcode >> 9) & 0x3FFF
|
||||
errcode = '{:04}-{:04}'.format(module + 2000, desc)
|
||||
|
||||
# Searching for error codes related to the Switch (Doesn't include Special Cases)
|
||||
if 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]
|
||||
else:
|
||||
err_description = "AAAAA It seems like your error code is unknown. You should report relevant details to <@141532589725974528> so it can be added to the bot."
|
||||
|
||||
if module in switch_modules:
|
||||
err_module = switch_modules[module]
|
||||
else:
|
||||
err_module = "Unknown"
|
||||
|
||||
# Make a nice Embed out of it
|
||||
embed = discord.Embed(title="{} / {}".format(errcode, err), url="https://www.youtube.com/watch?v=x3yXlomPCmU", description=err_description)
|
||||
embed.set_footer(text="Console: Switch")
|
||||
embed.add_field(name="Module", value="{} ({})".format(err_module, module), inline=True)
|
||||
embed.add_field(name="Description", value=desc, inline=True)
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
await ctx.send("Unknown Format - This is either no error code or you made some mistake!")
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Err(bot))
|
||||
|
|
Loading…
Reference in a new issue