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

Use JSON decoder provided by msgspec #222

Merged
merged 1 commit into from
Oct 27, 2024
Merged
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
6 changes: 3 additions & 3 deletions bot/cogs/pronouns.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import discord
import msgspec
import orjson
from discord import app_commands
from discord.ext import commands, menus
from libs.utils.embeds import Embed, FullErrorEmbed
Expand Down Expand Up @@ -487,6 +486,7 @@ class Pronouns(commands.GroupCog, name="pronouns"):

def __init__(self, bot: Catherine) -> None:
self.bot = bot
self.decoder = msgspec.json.Decoder()
self.session = self.bot.session
self.pool = self.bot.pool
super().__init__()
Expand Down Expand Up @@ -621,7 +621,7 @@ async def db(self, interaction: discord.Interaction, member: discord.Member) ->

params = {"platform": "discord", "ids": member.id}
async with self.session.get("https://pronoundb.org/api/v2/lookup", params=params) as r:
data = await r.json(loads=orjson.loads)
data = await r.json(loads=self.decoder.decode)
if len(data) == 0:
await interaction.response.send_message("No pronouns found for these user(s).")
return
Expand All @@ -645,7 +645,7 @@ async def profile(self, interaction: discord.Interaction, username: str) -> None
url = URL("https://en.pronouns.page/api/profile/get/") / username
params = {"version": 2}
async with self.session.get(url, params=params) as r:
data = await r.json(loads=orjson.loads)
data = await r.json(loads=self.decoder.decode)
if len(data["profiles"]) == 0:
await interaction.followup.send("The profile was not found")
return
Expand Down