Skip to content

Commit 66ef705

Browse files
authored
Merge branch 'Pycord-Development:master' into master
2 parents 7b11fba + 510a44b commit 66ef705

24 files changed

+237
-62
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
1414
with:
1515
python-version: "3.11"
1616
cache: "pip"
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@v4
29-
- uses: actions/setup-python@v4
29+
- uses: actions/setup-python@v5
3030
with:
3131
python-version: "3.11"
3232
cache: "pip"

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
# Initializes the CodeQL tools for scanning.
4747
- name: Initialize CodeQL
48-
uses: github/codeql-action/init@v2
48+
uses: github/codeql-action/init@v3
4949
with:
5050
languages: ${{ matrix.language }}
5151
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below)
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@v2
59+
uses: github/codeql-action/autobuild@v3
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 https://git.io/JvXDl
@@ -70,4 +70,4 @@ jobs:
7070
# make release
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@v2
73+
uses: github/codeql-action/analyze@v3

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v4
13+
- uses: actions/setup-python@v5
1414
with:
1515
python-version: "3.11"
1616
cache: "pip"
@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ubuntu-latest
3333
steps:
3434
- uses: actions/checkout@v4
35-
- uses: actions/setup-python@v4
35+
- uses: actions/setup-python@v5
3636
with:
3737
python-version: "3.11"
3838
cache: "pip"

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
PYTHON: ${{ matrix.python-version }}
2323
steps:
2424
- uses: actions/checkout@v4
25-
- uses: actions/setup-python@v4
25+
- uses: actions/setup-python@v5
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
cache: "pip"
@@ -50,7 +50,7 @@ jobs:
5050
steps:
5151
- uses: actions/checkout@v4
5252
- name: Set up Python ${{ matrix.python-version }}
53-
uses: actions/setup-python@v4
53+
uses: actions/setup-python@v5
5454
with:
5555
python-version: "3.8"
5656
cache: "pip"

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
7+
rev: v4.5.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
@@ -19,16 +19,16 @@ repos:
1919
# - --remove-duplicate-keys
2020
# - --remove-unused-variables
2121
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.13.0
22+
rev: v3.15.0
2323
hooks:
2424
- id: pyupgrade
2525
args: [--py38-plus]
2626
- repo: https://github.com/PyCQA/isort
27-
rev: 5.12.0
27+
rev: 5.13.0
2828
hooks:
2929
- id: isort
3030
- repo: https://github.com/psf/black
31-
rev: 23.9.1
31+
rev: 23.11.0
3232
hooks:
3333
- id: black
3434
args: [--safe, --quiet]
@@ -77,7 +77,7 @@ repos:
7777
# - id: mypy
7878

7979
- repo: https://github.com/pre-commit/mirrors-prettier
80-
rev: v3.0.3
80+
rev: v4.0.0-alpha.4
8181
hooks:
8282
- id: prettier
8383
args: [--prose-wrap=always, --print-width=88]

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ These changes are available on the `master` branch, but have not yet been releas
7575
([#2206](https://github.com/Pycord-Development/pycord/pull/2206))
7676
- Added function `Guild.delete_auto_moderation_rule`.
7777
([#2153](https://github.com/Pycord-Development/pycord/pull/2153))
78+
- Added `VoiceChannel.slowmode_delay`.
79+
([#2112](https://github.com/Pycord-Development/pycord/pull/2112))
80+
- Added `ForumChannel.default_reaction_emoji` attribute.
81+
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
82+
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel()` and
83+
`ForumChannel.edit()` methods.
84+
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
7885

7986
### Changed
8087

@@ -180,6 +187,20 @@ These changes are available on the `master` branch, but have not yet been releas
180187
([#2192](https://github.com/Pycord-Development/pycord/pull/2192))
181188
- Fixed `DMChannel.recipient` being `None` and consequently `User.dm_channel` also being
182189
`None`. ([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
190+
- Fixed ffmpeg being terminated prematurely when piping audio stream.
191+
([#2240](https://github.com/Pycord-Development/pycord/pull/2240))
192+
- Fixed tasks looping infinitely when `tzinfo` is neither `None` nor UTC.
193+
([#2196](https://github.com/Pycord-Development/pycord/pull/2196))
194+
- Fixed `AttributeError` when running permission checks without the `bot` scope.
195+
([#2113](https://github.com/Pycord-Development/pycord/issues/2113))
196+
- Fixed `Option` not working on bridge commands because `ext.commands.Command` doesn't
197+
recognize them. ([#2256](https://github.com/Pycord-Development/pycord/pull/2256))
198+
- Fixed offset-aware tasks causing `TypeError` when being prepared.
199+
([#2271](https://github.com/Pycord-Development/pycord/pull/2271))
200+
- Fixed `AttributeError` when serializing commands with `Annotated` type hints.
201+
([#2243](https://github.com/Pycord-Development/pycord/pull/2243))
202+
- Fixed `Intents.all()` returning the wrong value.
203+
([#2257](https://github.com/Pycord-Development/pycord/issues/2257))
183204

184205
## [2.4.1] - 2023-03-20
185206

discord/abc.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from .invite import Invite
5151
from .iterators import HistoryIterator
5252
from .mentions import AllowedMentions
53+
from .partial_emoji import PartialEmoji, _EmojiTag
5354
from .permissions import PermissionOverwrite, Permissions
5455
from .role import Role
5556
from .scheduled_events import ScheduledEvent
@@ -507,6 +508,28 @@ async def _edit(
507508
raise InvalidArgument("type field must be of type ChannelType")
508509
options["type"] = ch_type.value
509510

511+
try:
512+
default_reaction_emoji = options["default_reaction_emoji"]
513+
except KeyError:
514+
pass
515+
else:
516+
if isinstance(default_reaction_emoji, _EmojiTag): # Emoji, PartialEmoji
517+
default_reaction_emoji = default_reaction_emoji._to_partial()
518+
elif isinstance(default_reaction_emoji, int):
519+
default_reaction_emoji = PartialEmoji(
520+
name=None, id=default_reaction_emoji
521+
)
522+
elif isinstance(default_reaction_emoji, str):
523+
default_reaction_emoji = PartialEmoji.from_str(default_reaction_emoji)
524+
else:
525+
raise InvalidArgument(
526+
"default_reaction_emoji must be of type: Emoji | int | str"
527+
)
528+
529+
options[
530+
"default_reaction_emoji"
531+
] = default_reaction_emoji._to_forum_reaction_payload()
532+
510533
if options:
511534
return await self._state.http.edit_channel(
512535
self.id, reason=reason, **options
@@ -712,7 +735,7 @@ def permissions_for(self, obj: Member | Role, /) -> Permissions:
712735
return Permissions.all()
713736

714737
default = self.guild.default_role
715-
base = Permissions(default.permissions.value)
738+
base = Permissions(default.permissions.value if default else 0)
716739

717740
# Handle the role case first
718741
if isinstance(obj, Role):

discord/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ async def on_connect():
781781
lambda cmd: cmd.name == i["name"]
782782
and cmd.type == i.get("type")
783783
and cmd.guild_ids is not None
784-
# TODO: fix this type error (guild_id is not defined in ApplicationCommand Typed Dict)
785-
and int(i["guild_id"]) in cmd.guild_ids, # type: ignore
784+
and (guild_id := i.get("guild_id"))
785+
and guild_id in cmd.guild_ids,
786786
self.pending_application_commands,
787787
)
788788
if not cmd:

discord/channel.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
from . import utils
3434
from .asset import Asset
35+
from .emoji import Emoji
3536
from .enums import (
3637
ChannelType,
3738
EmbeddedActivity,
@@ -171,7 +172,7 @@ def to_dict(self) -> dict[str, Any]:
171172
payload: dict[str, Any] = {
172173
"name": self.name,
173174
"moderated": self.moderated,
174-
} | self.emoji._to_forum_tag_payload()
175+
} | self.emoji._to_forum_reaction_payload()
175176

176177
if self.id:
177178
payload["id"] = self.id
@@ -195,6 +196,7 @@ class _TextChannel(discord.abc.GuildChannel, Hashable):
195196
"last_message_id",
196197
"default_auto_archive_duration",
197198
"default_thread_slowmode_delay",
199+
"default_reaction_emoji",
198200
"default_sort_order",
199201
"available_tags",
200202
"flags",
@@ -228,7 +230,6 @@ def _update(
228230
self.name: str = data["name"]
229231
self.category_id: int | None = utils._get_as_snowflake(data, "parent_id")
230232
self._type: int = data["type"]
231-
232233
# This data may be missing depending on how this object is being created/updated
233234
if not data.pop("_invoke_flag", False):
234235
self.topic: str | None = data.get("topic")
@@ -1008,6 +1009,10 @@ class ForumChannel(_TextChannel):
10081009
The initial slowmode delay to set on newly created threads in this channel.
10091010
10101011
.. versionadded:: 2.3
1012+
default_reaction_emoji: Optional[:class:`str` | :class:`discord.Emoji`]
1013+
The default forum reaction emoji.
1014+
1015+
.. versionadded:: 2.5
10111016
"""
10121017

10131018
def __init__(
@@ -1022,6 +1027,15 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
10221027
for tag in (data.get("available_tags") or [])
10231028
]
10241029
self.default_sort_order: SortOrder | None = data.get("default_sort_order", None)
1030+
reaction_emoji_ctx: dict = data.get("default_reaction_emoji")
1031+
if reaction_emoji_ctx is not None:
1032+
emoji_name = reaction_emoji_ctx.get("emoji_name")
1033+
if emoji_name is not None:
1034+
self.default_reaction_emoji = reaction_emoji_ctx["emoji_name"]
1035+
else:
1036+
self.default_reaction_emoji = self._state.get_emoji(
1037+
utils._get_as_snowflake(reaction_emoji_ctx, "emoji_id")
1038+
)
10251039

10261040
@property
10271041
def guidelines(self) -> str | None:
@@ -1061,6 +1075,7 @@ async def edit(
10611075
default_auto_archive_duration: ThreadArchiveDuration = ...,
10621076
default_thread_slowmode_delay: int = ...,
10631077
default_sort_order: SortOrder = ...,
1078+
default_reaction_emoji: Emoji | int | str | None = ...,
10641079
available_tags: list[ForumTag] = ...,
10651080
require_tag: bool = ...,
10661081
overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ...,
@@ -1113,6 +1128,12 @@ async def edit(self, *, reason=None, **options):
11131128
The default sort order type to use to order posts in this channel.
11141129
11151130
.. versionadded:: 2.3
1131+
default_reaction_emoji: Optional[:class:`discord.Emoji` | :class:`int` | :class:`str`]
1132+
The default reaction emoji.
1133+
Can be a unicode emoji or a custom emoji in the forms:
1134+
:class:`Emoji`, snowflake ID, string representation (eg. '<a:emoji_name:emoji_id>').
1135+
1136+
.. versionadded:: 2.5
11161137
available_tags: List[:class:`ForumTag`]
11171138
The set of tags that can be used in this channel. Must be less than `20`.
11181139
@@ -1329,6 +1350,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha
13291350
"user_limit",
13301351
"_state",
13311352
"position",
1353+
"slowmode_delay",
13321354
"_overwrites",
13331355
"category_id",
13341356
"rtc_region",
@@ -1376,6 +1398,7 @@ def _update(
13761398
data, "last_message_id"
13771399
)
13781400
self.position: int = data.get("position")
1401+
self.slowmode_delay = data.get("rate_limit_per_user", 0)
13791402
self.bitrate: int = data.get("bitrate")
13801403
self.user_limit: int = data.get("user_limit")
13811404
self.flags: ChannelFlags = ChannelFlags._from_value(data.get("flags", 0))
@@ -1483,6 +1506,13 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
14831506
The ID of the last message sent to this channel. It may not always point to an existing or valid message.
14841507
14851508
.. versionadded:: 2.0
1509+
slowmode_delay: :class:`int`
1510+
The number of seconds a member must wait between sending messages
1511+
in this channel. A value of `0` denotes that it is disabled.
1512+
Bots and users with :attr:`~Permissions.manage_channels` or
1513+
:attr:`~Permissions.manage_messages` bypass slowmode.
1514+
1515+
.. versionadded:: 2.5
14861516
flags: :class:`ChannelFlags`
14871517
Extra features of the channel.
14881518
@@ -1791,6 +1821,7 @@ async def edit(
17911821
overwrites: Mapping[Role | Member, PermissionOverwrite] = ...,
17921822
rtc_region: VoiceRegion | None = ...,
17931823
video_quality_mode: VideoQualityMode = ...,
1824+
slowmode_delay: int = ...,
17941825
reason: str | None = ...,
17951826
) -> VoiceChannel | None:
17961827
...

discord/commands/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,12 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]:
746746
option = next(option_gen, Option())
747747
# Handle Optional
748748
if self._is_typing_optional(type_hint):
749-
option.input_type = get_args(type_hint)[0]
749+
option.input_type = SlashCommandOptionType.from_datatype(
750+
get_args(type_hint)[0]
751+
)
750752
option.default = None
751753
else:
752-
option.input_type = type_hint
754+
option.input_type = SlashCommandOptionType.from_datatype(type_hint)
753755

754756
if self._is_typing_union(option):
755757
if self._is_typing_optional(option):

0 commit comments

Comments
 (0)