diff --git a/pincer/core/http.py b/pincer/core/http.py index ae82ca32..c8c831cb 100644 --- a/pincer/core/http.py +++ b/pincer/core/http.py @@ -179,7 +179,7 @@ async def __send( data=data, headers={ "Content-Type": content_type, - **(headers or {}) + **(remove_none(headers) or {}) }, params=remove_none(params) ) as res: diff --git a/pincer/objects/guild/channel.py b/pincer/objects/guild/channel.py index e19fcd28..c7ca6bf9 100644 --- a/pincer/objects/guild/channel.py +++ b/pincer/objects/guild/channel.py @@ -303,7 +303,7 @@ async def edit_permissions( """ await self._http.put( f"channels/{self.id}/permissions/{overwrite.id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, data={"allow": allow, "deny": deny, "type": type}, ) @@ -323,7 +323,7 @@ async def delete_permission( """ await self._http.delete( f"channels/{self.id}/permissions/{overwrite.id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def follow_news_channel( @@ -389,7 +389,7 @@ async def pin_message( """ await self._http.put( f"channels/{self.id}/pins/{message.id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def unpin_message( @@ -400,7 +400,7 @@ async def unpin_message( """ await self._http.delete( f"channels/{self.id}/pins/{message.id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def group_dm_add_recipient( @@ -459,7 +459,7 @@ async def bulk_delete_messages( """ await self._http.post( f"channels/{self.id}/messages/bulk_delete", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, data={"messages": messages}, ) @@ -484,7 +484,7 @@ async def delete( await self._http.delete( f"channels/{channel_id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def __post_send_handler(self, message: UserMessage): @@ -621,7 +621,7 @@ async def create_invite( self._client, await self._http.post( f"channels/{self.id}/invites", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, data={ "max_age": max_age, "max_uses": max_uses, @@ -955,7 +955,7 @@ async def start( self._client, await self._http.post( f"channels/{self.id}/threads", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, data={ "name": name, "auto_archive_duration": auto_archive_duration, @@ -1018,7 +1018,7 @@ async def start_with_message( self._client, await self._http.post( f"channels/{self.id}/messages/{message.id}/threads", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, data={ "name": name, "auto_archive_duration": auto_archive_duration, diff --git a/pincer/objects/guild/guild.py b/pincer/objects/guild/guild.py index b4e948bc..4e58f852 100644 --- a/pincer/objects/guild/guild.py +++ b/pincer/objects/guild/guild.py @@ -502,7 +502,7 @@ async def modify_member(self, _id: int, reason=None, **kwargs) -> GuildMember: data = await self._http.patch( f"guilds/{self.id}/members/{_id}", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) return GuildMember.from_dict(construct_client_dict(self._client, data)) @@ -568,7 +568,7 @@ async def create_channel( data = await self._http.post( f"guilds/{self.id}/channels", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) return Channel.from_dict(construct_client_dict(self._client, data)) @@ -594,7 +594,7 @@ async def modify_channel_positions( await self._http.patch( f"guilds/{self.id}/channels", data=channel, - headers=remove_none({"X-Audit-Log-Reason":reason}) + headers={"X-Audit-Log-Reason":reason} ) async def list_active_threads(self) -> Tuple[ @@ -738,7 +738,7 @@ async def add_guild_member( data = await self._http.put( f"guilds/{self.id}/members/{user_id}", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) return GuildMember.from_dict( @@ -767,7 +767,7 @@ async def modify_current_member( data = self._http.patch( f"guilds/{self.id}/members/@me", {"nick": nick}, - headers=remove_none({"X-Audit-Log-Reason":reason}) + headers={"X-Audit-Log-Reason":reason} ) return GuildMember.from_dict(construct_client_dict(self._client, data)) @@ -791,7 +791,7 @@ async def add_guild_member_role( """ data = await self._http.put( f"guilds/{self.id}/{user_id}/roles/{role_id}", - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) async def remove_guild_member_role( @@ -814,7 +814,7 @@ async def remove_guild_member_role( """ await self._http.delete( f"guilds/{self.id}/{user_id}/roles/{role_id}", - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) async def remove_guild_member( @@ -834,7 +834,7 @@ async def remove_guild_member( """ await self._http.delete( f"guilds/{self.id}/members/{user_id}", - headers=remove_none({"X-Audit-Log-Reason": reason}) + headers={"X-Audit-Log-Reason": reason} ) async def ban( @@ -955,7 +955,7 @@ async def create_role(self, reason: Optional[str] = None, **kwargs) -> Role: await self._http.post( f"guilds/{self.id}/roles", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ), ) ) @@ -986,7 +986,7 @@ async def edit_role_position( data = await self._http.patch( f"guilds/{self.id}/roles", data={"id": id, "position": position}, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) for role_data in data: yield Role.from_dict(construct_client_dict(self._client, role_data)) @@ -1050,7 +1050,7 @@ async def edit_role( await self._http.patch( f"guilds/{self.id}/roles/{id}", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ), ) ) @@ -1069,7 +1069,7 @@ async def delete_role(self, id: Snowflake, reason: Optional[str] = None): """ await self._http.delete( f"guilds/{self.id}/roles/{id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def get_bans(self) -> AsyncGenerator[Ban, None]: @@ -1119,7 +1119,7 @@ async def unban(self, id: Snowflake, reason: Optional[str] = None): """ await self._http.delete( f"guilds/{self.id}/bans/{id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) @overload @@ -1290,7 +1290,7 @@ async def prune( "compute_prune_days": compute_prune_days, "include_roles": include_roles, }, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, )["pruned"] async def get_voice_regions(self) -> AsyncGenerator[VoiceRegion, None]: @@ -1356,7 +1356,7 @@ async def delete_integration( """ await self._http.delete( f"guilds/{self.id}/integrations/{integration.id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def get_widget_settings(self) -> GuildWidget: @@ -1397,7 +1397,7 @@ async def modify_widget( data = await self._http.patch( f"guilds/{self.id}/widget", data=kwargs, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) return GuildWidget.from_dict(construct_client_dict(self._client, data)) @@ -1509,7 +1509,7 @@ async def modify_welcome_screen( "welcome_channels": welcome_channels, "description": description, }, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) return WelcomeScreen.from_dict( construct_client_dict(self._client, data) @@ -1672,7 +1672,7 @@ async def create_emoji( data = await self._http.post( f"guilds/{self.id}/emojis", data={"name": name, "image": image.uri, "roles": roles}, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) return Emoji.from_dict(construct_client_dict(self._client, data)) @@ -1707,7 +1707,7 @@ async def edit_emoji( data = await self._http.patch( f"guilds/{self.id}/emojis/{id}", data={"name": name, "roles": roles}, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) return Emoji.from_dict(construct_client_dict(self._client, data)) @@ -1727,7 +1727,7 @@ async def delete_emoji( """ await self._http.delete( f"guilds/{self.id}/emojis/{id}", - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) async def get_templates(self) -> AsyncIterator[GuildTemplate]: @@ -1931,7 +1931,7 @@ async def create_sticker( sticker = await self._http.post( f"guilds/{self.id}/stickers", data=payload, - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, content_type=payload.content_type ) diff --git a/pincer/objects/message/sticker.py b/pincer/objects/message/sticker.py index 56a3cf73..a0a907c4 100644 --- a/pincer/objects/message/sticker.py +++ b/pincer/objects/message/sticker.py @@ -147,7 +147,7 @@ async def modify( data=remove_none( {"name": name, "description": description, "tags": tags} ), - headers=remove_none({"X-Audit-Log-Reason": reason}), + headers={"X-Audit-Log-Reason": reason}, ) return Sticker.from_dict(sticker)