Skip to content

Commit

Permalink
api: Add wfcerror
Browse files Browse the repository at this point in the history
This leverages Wiimmfi's extensive error code database API to provide
users a simple way to describe error codes.

It should be noted some of the responses may be Wii-specific, but
still helps us Nintendo Wi-Fi Connection users in the DS world.
  • Loading branch information
lifehackerhansol committed Aug 29, 2024
1 parent 2db1663 commit 05f3c39
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cogs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import aiohttp
import discord
from discord.ext import commands, tasks
from markdownify import markdownify
from pytz import timezone
from rapidfuzz import process
from re import findall
Expand Down Expand Up @@ -541,6 +542,26 @@ async def generatemkey(self, ctx, device: str, month: int, day: int, inquiry: st
else:
return await ctx.send(f'{ctx.author.mention} API returned error {r.status}. Please check your values and try again.')

@commands.command()
async def wfcerror(self, ctx, error: int):
# It seems error codes must be within 6 digits
if error > 999999:
return await ctx.send(f"{ctx.author.mention} This is an invalid error code. Please try again.")
apicall = f"https://wiimmfi.de/error?m=json&e={error}"
async with ctx.typing():
async with self.bot.session.get(apicall) as r:
if r.status == 200:
response = await r.json()
if response[0]["found"] == 0:
return await ctx.send(f"{ctx.author.mention} This error code does not exist.")
else:
embed = discord.Embed(title=f"WFC Error {error}")
for i in response[0]["infolist"]:
embed.add_field(name=i["type"], value=f'**{i["name"]}**: {markdownify(i["info"])}', inline=False)
return await ctx.send(embed=embed)
else:
return await ctx.send(f'{ctx.author.mention} API returned error {r.status}. Please check your values and try again.')


async def setup(bot: TWLHelper):
await bot.add_cog(API(bot))

0 comments on commit 05f3c39

Please sign in to comment.