6161
6262__all__ = (
6363 "GuildBan" ,
64+ "BulkBanResponse" ,
6465 "BaseGuild" ,
6566 "GuildWelcome" ,
6667 "GuildPreview" ,
@@ -85,6 +86,34 @@ class GuildBan:
8586 """The banned user"""
8687
8788
89+ @attrs .define (eq = False , order = False , hash = False , kw_only = True )
90+ class BulkBanResponse (ClientObject ):
91+ _banned_users : list [Snowflake_Type ] = attrs .field (repr = False , converter = to_snowflake_list )
92+ """List of user IDs that were successfully banned."""
93+ _failed_users : list [Snowflake_Type ] = attrs .field (repr = False , converter = to_snowflake_list )
94+ """List of user IDs that were not banned."""
95+
96+ @property
97+ def banned_users (self ) -> List ["models.User | None" ]:
98+ """List of users that were successfully banned."""
99+ return [self .client .cache .get_user (u_id ) for u_id in self ._banned_users ]
100+
101+ @property
102+ def failed_users (self ) -> List ["models.User | None" ]:
103+ """List of users that were not banned."""
104+ return [self .client .cache .get_user (u_id ) for u_id in self ._failed_users ]
105+
106+ @property
107+ def failed_user_ids (self ) -> List [Snowflake_Type ]:
108+ """List of user IDs that were not banned."""
109+ return self ._failed_users
110+
111+ @property
112+ def banned_user_ids (self ) -> List [Snowflake_Type ]:
113+ """List of user IDs that were successfully banned."""
114+ return self ._banned_users
115+
116+
88117@attrs .define (eq = False , order = False , hash = False , kw_only = True )
89118class BaseGuild (DiscordObject ):
90119 name : str = attrs .field (repr = True )
@@ -1748,6 +1777,29 @@ async def ban(
17481777 delete_message_seconds = delete_message_days * 3600
17491778 await self ._client .http .create_guild_ban (self .id , to_snowflake (user ), delete_message_seconds , reason = reason )
17501779
1780+ async def bulk_ban (
1781+ self ,
1782+ users : List [Union ["models.User" , "models.Member" , Snowflake_Type ]],
1783+ delete_message_seconds : int = 0 ,
1784+ reason : Optional [str ] = None ,
1785+ ) -> BulkBanResponse :
1786+ """
1787+ Bans a list of users from the guild.
1788+
1789+ !!! note
1790+ You must have the `ban members` permission
1791+
1792+ Args:
1793+ user: The users to ban
1794+ delete_message_seconds: How many seconds worth of messages to remove
1795+ reason: The reason for the ban
1796+
1797+ """
1798+ result = await self .client .http .bulk_guild_ban (
1799+ self .id , [to_snowflake (user ) for user in users ], delete_message_seconds , reason = reason
1800+ )
1801+ return BulkBanResponse .from_dict (result , self .client )
1802+
17511803 async def fetch_ban (self , user : Union ["models.User" , "models.Member" , Snowflake_Type ]) -> Optional [GuildBan ]:
17521804 """
17531805 Fetches the ban information for the specified user in the guild. You must have the `ban members` permission.
0 commit comments