Skip to content

Commit 2577ac6

Browse files
authored
Merge branch 'master' into fix-interaction-channel-perms
Signed-off-by: Paillat <[email protected]>
2 parents 398f131 + 9fa5cbe commit 2577ac6

File tree

7 files changed

+100
-17
lines changed

7 files changed

+100
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
# - --remove-duplicate-keys
2222
# - --remove-unused-variables
2323
- repo: https://github.com/asottile/pyupgrade
24-
rev: v3.19.0
24+
rev: v3.19.1
2525
hooks:
2626
- id: pyupgrade
2727
exclude: \.(po|pot|yml|yaml)$

CHANGELOG.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ These changes are available on the `master` branch, but have not yet been releas
3232
([#2590](https://github.com/Pycord-Development/pycord/pull/2590))
3333
- Added missing `with_counts` parameter to `fetch_guilds` method.
3434
([#2615](https://github.com/Pycord-Development/pycord/pull/2615))
35-
- Added missing permissions: `Permissions.use_soundboard`,
36-
`Permissions.use_external_sounds` and
35+
- Added the following missing permissions: `Permissions.use_soundboard`,
36+
`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

4042
### Fixed
4143

@@ -54,7 +56,7 @@ These changes are available on the `master` branch, but have not yet been releas
5456
([#2595](https://github.com/Pycord-Development/pycord/pull/2595))
5557
- Fixed `BucketType.category` cooldown commands not functioning correctly in private
5658
channels. ([#2603](https://github.com/Pycord-Development/pycord/pull/2603))
57-
- Fixed `SlashCommand`'s `ctx` parameter couldn't be `Union` type.
59+
- Fixed `ctx` parameter of a `SlashCommand` not being `Union` type.
5860
([#2611](https://github.com/Pycord-Development/pycord/pull/2611))
5961
- Fixed `TypeError` when passing `skus` parameter in `Client.entitlements()`.
6062
([#2627](https://github.com/Pycord-Development/pycord/issues/2627))
@@ -66,6 +68,9 @@ These changes are available on the `master` branch, but have not yet been releas
6668
([#2635](https://github.com/Pycord-Development/pycord/issues/2635))
6769
- Fixed malformed properties in `Interaction.channel`.
6870
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
71+
- Fixed an error when responding non-ephemerally with a `Paginator` to an ephemerally
72+
deferred interaction.
73+
([#2661](https://github.com/Pycord-Development/pycord/pull/2661))
6974

7075
### Changed
7176

@@ -79,6 +84,8 @@ These changes are available on the `master` branch, but have not yet been releas
7984
- Replaced audioop (deprecated module) implementation of `PCMVolumeTransformer.read`
8085
method with a pure Python equivalent.
8186
([#2176](https://github.com/Pycord-Development/pycord/pull/2176))
87+
- Updated `Guild.filesize_limit` to 10 MB instead of 25 MB following Discord's API
88+
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
8289

8390
### Deprecated
8491

@@ -392,7 +399,7 @@ These changes are available on the `master` branch, but have not yet been releas
392399
([#2075](https://github.com/Pycord-Development/pycord/pull/2075))
393400
- Fixed `before_invoke` not being run for `SlashCommandGroup`.
394401
([#2091](https://github.com/Pycord-Development/pycord/pull/2091))
395-
- Fixed `AttributeError` when accessing a `Select` object's values when it hasn't been
402+
- Fixed `AttributeError` when accessing a `Select` object's values when it has not been
396403
interacted with. ([#2104](https://github.com/Pycord-Development/pycord/pull/2104))
397404
- Fixed `before_invoke` being run twice for slash subcommands.
398405
([#2139](https://github.com/Pycord-Development/pycord/pull/2139))
@@ -423,7 +430,7 @@ These changes are available on the `master` branch, but have not yet been releas
423430
([#2196](https://github.com/Pycord-Development/pycord/pull/2196))
424431
- Fixed `AttributeError` when running permission checks without the `bot` scope.
425432
([#2113](https://github.com/Pycord-Development/pycord/issues/2113))
426-
- Fixed `Option` not working on bridge commands because `ext.commands.Command` doesn't
433+
- Fixed `Option` not working on bridge commands because `ext.commands.Command` does not
427434
recognize them. ([#2256](https://github.com/Pycord-Development/pycord/pull/2256))
428435
- Fixed offset-aware tasks causing `TypeError` when being prepared.
429436
([#2271](https://github.com/Pycord-Development/pycord/pull/2271))
@@ -523,7 +530,7 @@ These changes are available on the `master` branch, but have not yet been releas
523530
### Fixed
524531

525532
- Fixed bugs in `Page.update_files` where file objects stored in memory were causing an
526-
`AttributeError`, and `io.BytesIO` files didn't send properly more than once.
533+
`AttributeError`, and `io.BytesIO` files did not send properly more than once.
527534
([#1869](https://github.com/Pycord-Development/pycord/pull/1869) &
528535
[#1881](https://github.com/Pycord-Development/pycord/pull/1881))
529536
- Fixed bridge groups missing the `parent` attribute.
@@ -878,9 +885,9 @@ These changes are available on the `master` branch, but have not yet been releas
878885
([#1453](https://github.com/Pycord-Development/pycord/pull/1453))
879886
- Update `thread.members` on `thread.fetch_members`.
880887
([#1464](https://github.com/Pycord-Development/pycord/pull/1464))
881-
- Fix the error when Discord doesn't send the `app_permissions` data in `Interaction`.
888+
- Fix the error when Discord does not send the `app_permissions` data in `Interaction`.
882889
([#1467](https://github.com/Pycord-Development/pycord/pull/1467))
883-
- Fix AttributeError when voice client `play()` function isn't completed yet.
890+
- Fix AttributeError when voice client `play()` function is not completed yet.
884891
([#1360](https://github.com/Pycord-Development/pycord/pull/1360))
885892

886893
## [2.0.0-rc.1] - 2022-05-17

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/guild.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ class Guild(Hashable):
289289
)
290290

291291
_PREMIUM_GUILD_LIMITS: ClassVar[dict[int | None, _GuildLimit]] = {
292-
None: _GuildLimit(emoji=50, stickers=5, bitrate=96e3, filesize=26214400),
293-
0: _GuildLimit(emoji=50, stickers=5, bitrate=96e3, filesize=26214400),
294-
1: _GuildLimit(emoji=100, stickers=15, bitrate=128e3, filesize=26214400),
295-
2: _GuildLimit(emoji=150, stickers=30, bitrate=256e3, filesize=52428800),
296-
3: _GuildLimit(emoji=250, stickers=60, bitrate=384e3, filesize=104857600),
292+
None: _GuildLimit(emoji=50, stickers=5, bitrate=96e3, filesize=10_485_760),
293+
0: _GuildLimit(emoji=50, stickers=5, bitrate=96e3, filesize=10_485_760),
294+
1: _GuildLimit(emoji=100, stickers=15, bitrate=128e3, filesize=10_485_760),
295+
2: _GuildLimit(emoji=150, stickers=30, bitrate=256e3, filesize=52_428_800),
296+
3: _GuildLimit(emoji=250, stickers=60, bitrate=384e3, filesize=104_857_600),
297297
}
298298

299299
def __init__(self, *, data: GuildPayload, state: ConnectionState):

discord/interactions.py

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

370+
def is_guild_authorised(self) -> bool:
371+
""":class:`bool`: Checks if the interaction is guild authorised.
372+
373+
There is an alias for this called :meth:`.is_guild_authorized`.
374+
375+
.. versionadded:: 2.7
376+
"""
377+
if self.guild_id:
378+
return self.authorizing_integration_owners.guild_id == self.guild_id
379+
return False
380+
381+
def is_user_authorised(self) -> bool:
382+
""":class:`bool`: Checks if the interaction is user authorised.
383+
384+
There is an alias for this called :meth:`.is_user_authorized`.
385+
386+
.. versionadded:: 2.7
387+
"""
388+
if self.user:
389+
return self.authorizing_integration_owners.user_id == self.user.id
390+
391+
# This return should not be called but to make sure it returns the expected value
392+
return False
393+
394+
def is_guild_authorized(self) -> bool:
395+
""":class:`bool`: Checks if the interaction is guild authorized.
396+
397+
There is an alias for this called :meth:`.is_guild_authorised`.
398+
399+
.. versionadded:: 2.7
400+
"""
401+
return self.is_guild_authorised()
402+
403+
def is_user_authorized(self) -> bool:
404+
""":class:`bool`: Checks if the interaction is user authorized.
405+
406+
There is an alias for this called :meth:`.is_user_authorised`.
407+
408+
.. versionadded:: 2.7
409+
"""
410+
return self.is_user_authorised()
411+
370412
async def original_response(self) -> InteractionMessage:
371413
"""|coro|
372414

requirements/dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-r _.txt
2-
pylint~=3.3.2
2+
pylint~=3.3.3
33
pytest~=8.3.4
44
pytest-asyncio~=0.23.8
55
# pytest-order~=1.0.1
6-
mypy~=1.13.0
6+
mypy~=1.14.0
77
coverage~=7.6
88
pre-commit==4.0.1
99
codespell==2.3.0

0 commit comments

Comments
 (0)