|
37 | 37 | try_enum, |
38 | 38 | ) |
39 | 39 | from .errors import ClientException, InteractionResponded, InvalidArgument |
40 | | -from .file import File |
| 40 | +from .file import File, VoiceMessage |
41 | 41 | from .flags import MessageFlags |
42 | 42 | from .guild import Guild |
43 | 43 | from .member import Member |
@@ -360,6 +360,48 @@ def followup(self) -> Webhook: |
360 | 360 | } |
361 | 361 | return Webhook.from_state(data=payload, state=self._state) |
362 | 362 |
|
| 363 | + def is_guild_authorised(self) -> bool: |
| 364 | + """:class:`bool`: Checks if the interaction is guild authorised. |
| 365 | +
|
| 366 | + There is an alias for this called :meth:`.is_guild_authorized`. |
| 367 | +
|
| 368 | + .. versionadded:: 2.7 |
| 369 | + """ |
| 370 | + if self.guild_id: |
| 371 | + return self.authorizing_integration_owners.guild_id == self.guild_id |
| 372 | + return False |
| 373 | + |
| 374 | + def is_user_authorised(self) -> bool: |
| 375 | + """:class:`bool`: Checks if the interaction is user authorised. |
| 376 | +
|
| 377 | + There is an alias for this called :meth:`.is_user_authorized`. |
| 378 | +
|
| 379 | + .. versionadded:: 2.7 |
| 380 | + """ |
| 381 | + if self.user: |
| 382 | + return self.authorizing_integration_owners.user_id == self.user.id |
| 383 | + |
| 384 | + # This return should not be called but to make sure it returns the expected value |
| 385 | + return False |
| 386 | + |
| 387 | + def is_guild_authorized(self) -> bool: |
| 388 | + """:class:`bool`: Checks if the interaction is guild authorized. |
| 389 | +
|
| 390 | + There is an alias for this called :meth:`.is_guild_authorised`. |
| 391 | +
|
| 392 | + .. versionadded:: 2.7 |
| 393 | + """ |
| 394 | + return self.is_guild_authorised() |
| 395 | + |
| 396 | + def is_user_authorized(self) -> bool: |
| 397 | + """:class:`bool`: Checks if the interaction is user authorized. |
| 398 | +
|
| 399 | + There is an alias for this called :meth:`.is_user_authorised`. |
| 400 | +
|
| 401 | + .. versionadded:: 2.7 |
| 402 | + """ |
| 403 | + return self.is_user_authorised() |
| 404 | + |
363 | 405 | async def original_response(self) -> InteractionMessage: |
364 | 406 | """|coro| |
365 | 407 |
|
@@ -915,8 +957,7 @@ async def send_message( |
915 | 957 | if content is not None: |
916 | 958 | payload["content"] = str(content) |
917 | 959 |
|
918 | | - if ephemeral: |
919 | | - payload["flags"] = 64 |
| 960 | + flags = MessageFlags(ephemeral=ephemeral) |
920 | 961 |
|
921 | 962 | if view is not None: |
922 | 963 | payload["components"] = view.to_components() |
@@ -954,6 +995,11 @@ async def send_message( |
954 | 995 | elif not all(isinstance(file, File) for file in files): |
955 | 996 | raise InvalidArgument("files parameter must be a list of File") |
956 | 997 |
|
| 998 | + if any(isinstance(file, VoiceMessage) for file in files): |
| 999 | + flags = flags + MessageFlags(is_voice_message=True) |
| 1000 | + |
| 1001 | + payload["flags"] = flags.value |
| 1002 | + |
957 | 1003 | parent = self._parent |
958 | 1004 | adapter = async_context.get() |
959 | 1005 | http = parent._state.http |
|
0 commit comments