Skip to content

Commit

Permalink
Use JSON decoder provided by msgspec (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 authored Oct 27, 2024
1 parent 035d1ac commit 30c640f
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 30c640f

Please sign in to comment.