@@ -495,6 +495,53 @@ def __attrs_post_init__(self): # sourcery skip: last-if-guard
495495 ):
496496 member ._extras ["guild_id" ] = self .id
497497
498+ @property
499+ def voice_states (self ) -> List ["VoiceState" ]:
500+ """
501+ .. versionadded:: 4.4.0
502+
503+ Gets all voice states of the guild.
504+
505+ :rtype: List[VoiceState]
506+ """
507+
508+ if not self ._client :
509+ raise LibraryException (code = 13 )
510+
511+ from .gw import VoiceState
512+
513+ states : List [VoiceState ] = []
514+
515+ data = self ._client .cache [VoiceState ].values .values ()
516+ states .extend (state for state in data if state .guild_id == self .id )
517+ return states
518+
519+ @property
520+ def mapped_voice_states (self ) -> Dict [int , List ["VoiceState" ]]:
521+ """
522+ .. versionadded:: 4.4.0
523+
524+ Returns all the voice states mapped after their channel id.
525+
526+ :rtype: Dict[int, List[VoiceState]]
527+ """
528+ states = self .voice_states
529+ _states : Dict [int , List [VoiceState ]] = {int (state .channel_id ): [] for state in states }
530+
531+ for state in states :
532+ _states [int (state .channel_id )].append (state )
533+
534+ return _states
535+
536+ @property
537+ def created_at (self ) -> datetime :
538+ """
539+ .. versionadded:: 4.4.0
540+
541+ Returns when the guild was created.
542+ """
543+ return self .id .timestamp
544+
498545 async def ban (
499546 self ,
500547 member_id : Union [int , Member , Snowflake ],
@@ -550,44 +597,6 @@ async def ban(
550597 if int (member .id ) == _member_id :
551598 return self .members .remove (member )
552599
553- @property
554- def voice_states (self ) -> List ["VoiceState" ]:
555- """
556- .. versionadded:: 4.4.0
557-
558- Gets all voice states of the guild.
559-
560- :rtype: List[VoiceState]
561- """
562-
563- if not self ._client :
564- raise LibraryException (code = 13 )
565-
566- from .gw import VoiceState
567-
568- states : List [VoiceState ] = []
569-
570- data = self ._client .cache [VoiceState ].values .values ()
571- states .extend (state for state in data if state .guild_id == self .id )
572- return states
573-
574- @property
575- def mapped_voice_states (self ) -> Dict [int , List ["VoiceState" ]]:
576- """
577- .. versionadded:: 4.4.0
578-
579- Returns all the voice states mapped after their channel id.
580-
581- :rtype: Dict[int, List[VoiceState]]
582- """
583- states = self .voice_states
584- _states : Dict [int , List [VoiceState ]] = {int (state .channel_id ): [] for state in states }
585-
586- for state in states :
587- _states [int (state .channel_id )].append (state )
588-
589- return _states
590-
591600 async def remove_ban (
592601 self ,
593602 user_id : Union [int , Snowflake ], # only support ID since there's no member on the guild
0 commit comments