11from __future__ import annotations
22
33from logging import getLogger
4- from typing import TYPE_CHECKING
54
65from nextcord import Embed , Guild , slash_command
76from nextcord .ext .application_checks import is_owner
1110from ..models import CogBase
1211from ..wraps import MyInter
1312
14- if TYPE_CHECKING :
15- from ..botbase import BotBase
16-
17-
1813_log = getLogger (__name__ )
1914
2015
@@ -35,24 +30,32 @@ async def add(
3530
3631 if guild :
3732 self .guilds .add (obj )
38- await BlacklistGuild .objects .create (id = obj , reason = reason )
33+ await BlacklistGuild (
34+ {BlacklistGuild .id : obj , BlacklistGuild .reason : reason }
35+ ).save ()
3936 else :
4037 self .users .add (obj )
41- await BlacklistUser .objects .create (id = obj , reason = reason )
38+ await BlacklistUser (
39+ {BlacklistUser .id : obj , BlacklistUser .reason : reason }
40+ ).save ()
4241
4342 async def remove (self , obj : int , guild : bool = False ) -> None :
4443 assert isinstance (obj , int )
4544
4645 if guild :
4746 self .guilds .discard (obj )
48- await BlacklistGuild .objects . delete (id = obj )
47+ await BlacklistGuild .delete (). where ( BlacklistGuild . id == obj )
4948 else :
5049 self .users .discard (obj )
51- await BlacklistUser .objects . delete (id = obj )
50+ await BlacklistUser .delete (). where ( BlacklistGuild . id == obj )
5251
5352 async def load (self ) -> None :
54- self .guilds = set (await BlacklistGuild .objects .values_list ("id" , flatten = True ))
55- self .users = set (await BlacklistUser .objects .values_list ("id" , flatten = True ))
53+ self .guilds = set (
54+ item ["id" ] for item in await BlacklistGuild .select (BlacklistGuild .id )
55+ )
56+ self .users = set (
57+ item ["id" ] for item in await BlacklistUser .select (BlacklistUser .id )
58+ )
5659
5760
5861class BlacklistCog (CogBase [BotBase ]):
@@ -62,7 +65,8 @@ def __init__(self, bot: BotBase) -> None:
6265 self .blacklist = Blacklist ()
6366 bot .loop .create_task (self .load_blacklist ())
6467 self .old_process_application_commands = bot .process_application_commands
65- bot .process_application_commands = self .check # type: ignore # MyInter + Interaction
68+ # MyInter + Interaction
69+ bot .process_application_commands = self .check # type: ignore
6670
6771 if bot .guild_ids :
6872 self .blacklist_ .guild_ids_to_rollout .update (bot .guild_ids )
0 commit comments