From 6d82746b4c464a8d440901d8c3a1a855e063101f Mon Sep 17 00:00:00 2001 From: arl Date: Mon, 22 May 2023 10:49:10 -0400 Subject: [PATCH] feat(permissions): add `use_external_sounds` (#997) --- changelog/989.feature.rst | 1 + changelog/997.feature.rst | 5 +++++ disnake/abc.py | 1 + disnake/ext/commands/base_core.py | 1 + disnake/ext/commands/core.py | 4 ++++ disnake/permissions.py | 16 +++++++++++++++- 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 changelog/997.feature.rst diff --git a/changelog/989.feature.rst b/changelog/989.feature.rst index 707709d386..0edc0959cf 100644 --- a/changelog/989.feature.rst +++ b/changelog/989.feature.rst @@ -2,3 +2,4 @@ Add new permission fields. - :attr:`Permissions.manage_guild_expressions` (which :attr:`~Permissions.manage_emojis` and :attr:`~Permissions.manage_emojis_and_stickers` are now aliased to) - :attr:`Permissions.view_creator_monetization_analytics` - :attr:`Permissions.use_soundboard` +- :attr:`Permissions.use_external_sounds` diff --git a/changelog/997.feature.rst b/changelog/997.feature.rst new file mode 100644 index 0000000000..0edc0959cf --- /dev/null +++ b/changelog/997.feature.rst @@ -0,0 +1,5 @@ +Add new permission fields. +- :attr:`Permissions.manage_guild_expressions` (which :attr:`~Permissions.manage_emojis` and :attr:`~Permissions.manage_emojis_and_stickers` are now aliased to) +- :attr:`Permissions.view_creator_monetization_analytics` +- :attr:`Permissions.use_soundboard` +- :attr:`Permissions.use_external_sounds` diff --git a/disnake/abc.py b/disnake/abc.py index 567189e9b9..2d49f2052d 100644 --- a/disnake/abc.py +++ b/disnake/abc.py @@ -870,6 +870,7 @@ async def set_permissions( use_application_commands: Optional[bool] = ..., use_embedded_activities: Optional[bool] = ..., use_external_emojis: Optional[bool] = ..., + use_external_sounds: Optional[bool] = ..., use_external_stickers: Optional[bool] = ..., use_slash_commands: Optional[bool] = ..., use_soundboard: Optional[bool] = ..., diff --git a/disnake/ext/commands/base_core.py b/disnake/ext/commands/base_core.py index 22c5b2047c..4d9db3a9e4 100644 --- a/disnake/ext/commands/base_core.py +++ b/disnake/ext/commands/base_core.py @@ -674,6 +674,7 @@ def default_member_permissions( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., diff --git a/disnake/ext/commands/core.py b/disnake/ext/commands/core.py index 53d88a418e..2a23bfaa80 100644 --- a/disnake/ext/commands/core.py +++ b/disnake/ext/commands/core.py @@ -2050,6 +2050,7 @@ def has_permissions( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., @@ -2170,6 +2171,7 @@ def bot_has_permissions( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., @@ -2268,6 +2270,7 @@ def has_guild_permissions( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., @@ -2363,6 +2366,7 @@ def bot_has_guild_permissions( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., diff --git a/disnake/permissions.py b/disnake/permissions.py index 67842c1a59..9653843856 100644 --- a/disnake/permissions.py +++ b/disnake/permissions.py @@ -202,6 +202,7 @@ def __init__( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., @@ -420,7 +421,7 @@ def voice(cls) -> Self: Added :attr:`use_embedded_activities` permission. .. versionchanged:: 2.9 - Added :attr:`use_soundboard` permission. + Added :attr:`use_soundboard` and :attr:`use_external_sounds` permissions. """ return cls( connect=True, @@ -428,6 +429,7 @@ def voice(cls) -> Self: stream=True, use_embedded_activities=True, use_soundboard=True, + use_external_sounds=True, use_voice_activation=True, priority_speaker=True, mute_members=True, @@ -563,6 +565,7 @@ def update( use_application_commands: bool = ..., use_embedded_activities: bool = ..., use_external_emojis: bool = ..., + use_external_sounds: bool = ..., use_external_stickers: bool = ..., use_slash_commands: bool = ..., use_soundboard: bool = ..., @@ -969,6 +972,14 @@ def use_soundboard(self) -> int: """ return 1 << 42 + @flag_value + def use_external_sounds(self) -> int: + """:class:`bool`: Returns ``True`` if a user can use custom soundboard sounds from other guilds. + + .. versionadded:: 2.9 + """ + return 1 << 45 + def _augment_from_permissions(cls): cls.VALID_NAMES = set(Permissions.VALID_FLAGS) @@ -1079,6 +1090,7 @@ class PermissionOverwrite: use_application_commands: Optional[bool] use_embedded_activities: Optional[bool] use_external_emojis: Optional[bool] + use_external_sounds: Optional[bool] use_external_stickers: Optional[bool] use_slash_commands: Optional[bool] use_soundboard: Optional[bool] @@ -1141,6 +1153,7 @@ def __init__( use_application_commands: Optional[bool] = ..., use_embedded_activities: Optional[bool] = ..., use_external_emojis: Optional[bool] = ..., + use_external_sounds: Optional[bool] = ..., use_external_stickers: Optional[bool] = ..., use_slash_commands: Optional[bool] = ..., use_soundboard: Optional[bool] = ..., @@ -1270,6 +1283,7 @@ def update( use_application_commands: Optional[bool] = ..., use_embedded_activities: Optional[bool] = ..., use_external_emojis: Optional[bool] = ..., + use_external_sounds: Optional[bool] = ..., use_external_stickers: Optional[bool] = ..., use_slash_commands: Optional[bool] = ..., use_soundboard: Optional[bool] = ...,