4141 Sequence ,
4242 TypeVar ,
4343 Union ,
44+ cast ,
4445)
4546
4647from discord .app .event_emitter import EventEmitter
@@ -263,9 +264,9 @@ def __init__(
263264
264265 self .cache : Cache = self .cache
265266
266- def clear (self , * , views : bool = True ) -> None :
267+ async def clear (self , * , views : bool = True ) -> None :
267268 self .user : ClientUser | None = None
268- self .cache .clear ()
269+ await self .cache .clear ()
269270 self ._voice_clients : dict [int , VoiceClient ] = {}
270271
271272 async def process_chunk_requests (
@@ -340,7 +341,7 @@ def deref_user_no_intents(self, user_id: int) -> None:
340341 return
341342
342343 async def get_user (self , id : int | None ) -> User | None :
343- return await self .cache .get_user (id )
344+ return await self .cache .get_user (cast ( int , id ) )
344345
345346 async def store_emoji (self , guild : Guild , data : EmojiPayload ) -> GuildEmoji :
346347 return await self .cache .store_guild_emoji (guild , data )
@@ -360,8 +361,8 @@ async def store_sticker(self, guild: Guild, data: GuildStickerPayload) -> GuildS
360361 async def store_view (self , view : View , message_id : int | None = None ) -> None :
361362 await self .cache .store_view (view , message_id )
362363
363- async def store_modal (self , modal : Modal ) -> None :
364- await self .cache .store_modal (modal )
364+ async def store_modal (self , modal : Modal , user_id : int ) -> None :
365+ await self .cache .store_modal (modal , user_id )
365366
366367 async def prevent_view_updates_for (self , message_id : int ) -> View | None :
367368 return await self .cache .delete_view_on (message_id )
@@ -379,7 +380,7 @@ async def get_guilds(self) -> list[Guild]:
379380 return await self .cache .get_all_guilds ()
380381
381382 async def _get_guild (self , guild_id : int | None ) -> Guild | None :
382- return await self .cache .get_guild (guild_id )
383+ return await self .cache .get_guild (cast ( int , guild_id ) )
383384
384385 async def _add_guild (self , guild : Guild ) -> None :
385386 await self .cache .add_guild (guild )
@@ -408,18 +409,11 @@ async def _remove_emoji(self, emoji: GuildEmoji | AppEmoji) -> None:
408409 await self .cache .delete_emoji (emoji )
409410
410411 async def get_sticker (self , sticker_id : int | None ) -> GuildSticker | None :
411- return await self .cache .get_sticker (sticker_id )
412+ return await self .cache .get_sticker (cast ( int , sticker_id ) )
412413
413414 async def get_polls (self ) -> list [Poll ]:
414415 return await self .cache .get_all_polls ()
415416
416- def create_poll (self , poll : PollPayload , raw ) -> Poll :
417- channel = self .get_channel (raw .channel_id ) or PartialMessageable (
418- state = self , id = raw .channel_id
419- )
420- message = channel .get_partial_message (raw .message_id )
421- return Poll .from_dict (poll , message )
422-
423417 async def store_poll (self , poll : Poll , message_id : int ):
424418 await self .cache .store_poll (poll , message_id )
425419
@@ -430,10 +424,10 @@ async def get_private_channels(self) -> list[PrivateChannel]:
430424 return await self .cache .get_private_channels ()
431425
432426 async def _get_private_channel (self , channel_id : int | None ) -> PrivateChannel | None :
433- return await self .cache .get_private_channel (channel_id )
427+ return await self .cache .get_private_channel (cast ( int , channel_id ) )
434428
435429 async def _get_private_channel_by_user (self , user_id : int | None ) -> DMChannel | None :
436- return await self .cache .get_private_channel_by_user (user_id )
430+ return cast ( DMChannel | None , await self .cache .get_private_channel_by_user (cast ( int , user_id )) )
437431
438432 async def _add_private_channel (self , channel : PrivateChannel ) -> None :
439433 await self .cache .store_private_channel (channel )
@@ -446,7 +440,7 @@ async def add_dm_channel(self, data: DMChannelPayload) -> DMChannel:
446440 return channel
447441
448442 async def _get_message (self , msg_id : int | None ) -> Message | None :
449- return await self .cache .get_message (msg_id )
443+ return await self .cache .get_message (cast ( int , msg_id ) )
450444
451445 def _guild_needs_chunking (self , guild : Guild ) -> bool :
452446 # If presences are enabled then we get back the old guild.large behaviour
@@ -461,7 +455,8 @@ async def _get_guild_channel(
461455 ) -> tuple [Channel | Thread , Guild | None ]:
462456 channel_id = int (data ["channel_id" ])
463457 try :
464- guild = await self ._get_guild (int (guild_id or data ["guild_id" ]))
458+ # guild_id is in data
459+ guild = await self ._get_guild (int (guild_id or data ["guild_id" ])) # type: ignore
465460 except KeyError :
466461 channel = DMChannel ._from_message (self , channel_id )
467462 guild = None
0 commit comments