Skip to content

Commit 0378f17

Browse files
authored
Merge branch 'master' into partial-autocomplete
Signed-off-by: Paillat <[email protected]>
2 parents 1165cb6 + 9fa5cbe commit 0378f17

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ These changes are available on the `master` branch, but have not yet been releas
3636
`Permissions.use_external_sounds`, and
3737
`Permissions.view_creator_monetization_analytics`.
3838
([#2620](https://github.com/Pycord-Development/pycord/pull/2620))
39+
- Added helper methods to determine the authorizing party of an `Interaction`.
40+
([#2659](https://github.com/Pycord-Development/pycord/pull/2659))
3941
- Added the ability to use functions with any number of optional arguments and functions
4042
returning an awaitable as `Option.autocomplete`.
4143
([#2669](https://github.com/Pycord-Development/pycord/pull/2669))
@@ -67,6 +69,9 @@ These changes are available on the `master` branch, but have not yet been releas
6769
apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650))
6870
- Fixed type annotations of cached properties.
6971
([#2635](https://github.com/Pycord-Development/pycord/issues/2635))
72+
- Fixed an error when responding non-ephemerally with a `Paginator` to an ephemerally
73+
deferred interaction.
74+
([#2661](https://github.com/Pycord-Development/pycord/pull/2661))
7075

7176
### Changed
7277

discord/commands/context.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,40 @@ def cog(self) -> Cog | None:
345345

346346
return self.command.cog
347347

348+
def is_guild_authorised(self) -> bool:
349+
""":class:`bool`: Checks if the invoked command is guild-installed.
350+
This is a shortcut for :meth:`Interaction.is_guild_authorised`.
351+
352+
There is an alias for this called :meth:`.is_guild_authorized`.
353+
354+
.. versionadded:: 2.7
355+
"""
356+
return self.interaction.is_guild_authorised()
357+
358+
def is_user_authorised(self) -> bool:
359+
""":class:`bool`: Checks if the invoked command is user-installed.
360+
This is a shortcut for :meth:`Interaction.is_user_authorised`.
361+
362+
There is an alias for this called :meth:`.is_user_authorized`.
363+
364+
.. versionadded:: 2.7
365+
"""
366+
return self.interaction.is_user_authorised()
367+
368+
def is_guild_authorized(self) -> bool:
369+
""":class:`bool`: An alias for :meth:`.is_guild_authorised`.
370+
371+
.. versionadded:: 2.7
372+
"""
373+
return self.is_guild_authorised()
374+
375+
def is_user_authorized(self) -> bool:
376+
""":class:`bool`: An alias for :meth:`.is_user_authorised`.
377+
378+
.. versionadded:: 2.7
379+
"""
380+
return self.is_user_authorised()
381+
348382

349383
class AutocompleteContext:
350384
"""Represents context for a slash command's option autocomplete.

discord/ext/pages/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ async def respond(
12021202
)
12031203
# convert from WebhookMessage to Message reference to bypass
12041204
# 15min webhook token timeout (non-ephemeral messages only)
1205-
if not ephemeral:
1205+
if not ephemeral and not msg.flags.ephemeral:
12061206
msg = await msg.channel.fetch_message(msg.id)
12071207
else:
12081208
msg = await interaction.response.send_message(

discord/interactions.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,48 @@ def followup(self) -> Webhook:
360360
}
361361
return Webhook.from_state(data=payload, state=self._state)
362362

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+
363405
async def original_response(self) -> InteractionMessage:
364406
"""|coro|
365407

0 commit comments

Comments
 (0)