Skip to content

Commit 1874b80

Browse files
authored
Merge branch 'master' into soundboard
2 parents c01a39a + 8e97cb5 commit 1874b80

File tree

19 files changed

+93
-86
lines changed

19 files changed

+93
-86
lines changed

.github/workflows/docs-localization-download.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
working-directory: ./docs
4141
- name: "Crowdin"
4242
id: crowdin
43-
uses: crowdin/[email protected].0
43+
uses: crowdin/[email protected].1
4444
with:
4545
upload_sources: false
4646
upload_translations: false

.github/workflows/docs-localization-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
sphinx-intl update -p ./build/locales ${{ vars.SPHINX_LANGUAGES }}
4545
working-directory: ./docs
4646
- name: "Crowdin"
47-
uses: crowdin/[email protected].0
47+
uses: crowdin/[email protected].1
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.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.1
24+
rev: v3.20.0
2525
hooks:
2626
- id: pyupgrade
2727
exclude: \.(po|pot|yml|yaml)$

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ These changes are available on the `master` branch, but have not yet been releas
6262
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
6363
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
6464
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
65-
- Added the ability to pass a `datetime.time` object to `format_dt`
65+
- Added the ability to pass a `datetime.time` object to `format_dt`.
6666
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
67+
- Added `discord.Interaction.created_at`.
68+
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))
6769

6870
### Fixed
6971

@@ -114,12 +116,18 @@ These changes are available on the `master` branch, but have not yet been releas
114116
([#2739](https://github.com/Pycord-Development/pycord/pull/2739))
115117
- Fixed missing `None` type hints in `Select.__init__`.
116118
([#2746](https://github.com/Pycord-Development/pycord/pull/2746))
119+
- Fixed `TypeError` when using `Flag` with Python 3.11+.
120+
([#2759](https://github.com/Pycord-Development/pycord/pull/2759))
121+
- Fixed `TypeError` when specifying `thread_name` in `Webhook.send`.
122+
([#2761](https://github.com/Pycord-Development/pycord/pull/2761))
117123
- Updated `valid_locales` to support `in` and `es-419`.
118124
([#2767](https://github.com/Pycord-Development/pycord/pull/2767))
119125
- Fixed `Webhook.edit` not working with `attachments=[]`.
120126
([#2779](https://github.com/Pycord-Development/pycord/pull/2779))
121127
- Fixed GIF-based `Sticker` returning the wrong `url`.
122128
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
129+
- Fixed `VoiceClient` crashing randomly while receiving audio
130+
([#2800](https://github.com/Pycord-Development/pycord/pull/2800))
123131

124132
### Changed
125133

@@ -137,6 +145,8 @@ These changes are available on the `master` branch, but have not yet been releas
137145
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
138146
- `Entitlement.ends_at` can now be `None`.
139147
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
148+
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
149+
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
140150

141151
### Deprecated
142152

@@ -147,6 +157,11 @@ These changes are available on the `master` branch, but have not yet been releas
147157
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
148158
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
149159

160+
### Removed
161+
162+
- Removed deprecated support for `Option` in `BridgeCommand`. Use `BridgeOption`
163+
instead. ([#2731])(https://github.com/Pycord-Development/pycord/pull/2731))
164+
150165
## [2.6.1] - 2024-09-15
151166

152167
### Fixed

discord/bot.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,17 @@ def _check_command(cmd: ApplicationCommand, match: Mapping[str, Any]) -> bool:
328328
]:
329329
# We have a difference
330330
return True
331-
elif getattr(cmd, check, None) != match.get(check):
332-
# We have a difference
333-
if (
331+
elif (attr := getattr(cmd, check, None)) != (
332+
found := match.get(check)
333+
):
334+
# We might have a difference
335+
if "localizations" in check and bool(attr) == bool(found):
336+
# unlike other attrs, localizations are MISSING by default
337+
continue
338+
elif (
334339
check == "default_permission"
335-
and getattr(cmd, check) is True
336-
and match.get(check) is None
340+
and attr is True
341+
and found is None
337342
):
338343
# This is a special case
339344
# TODO: Remove for perms v2

discord/commands/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def __init__(self, func: Callable, **kwargs) -> None:
233233
"__default_member_permissions__",
234234
kwargs.get("default_member_permissions", None),
235235
)
236-
self.nsfw: bool | None = getattr(func, "__nsfw__", kwargs.get("nsfw", None))
236+
self.nsfw: bool | None = getattr(func, "__nsfw__", kwargs.get("nsfw", False))
237237

238238
integration_types = getattr(
239239
func, "__integration_types__", kwargs.get("integration_types", None)
@@ -1255,7 +1255,7 @@ def __init__(
12551255
self.default_member_permissions: Permissions | None = kwargs.get(
12561256
"default_member_permissions", None
12571257
)
1258-
self.nsfw: bool | None = kwargs.get("nsfw", None)
1258+
self.nsfw: bool | None = kwargs.get("nsfw", False)
12591259

12601260
integration_types = kwargs.get("integration_types", None)
12611261
contexts = kwargs.get("contexts", None)

discord/ext/bridge/core.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,12 @@ class BridgeExtCommand(Command):
9898
def __init__(self, func, **kwargs):
9999
super().__init__(func, **kwargs)
100100

101-
# TODO: v2.7: Remove backwards support for Option in bridge commands.
102-
for name, option in self.params.items():
101+
for option in self.params.values():
103102
if isinstance(option.annotation, Option) and not isinstance(
104103
option.annotation, BridgeOption
105104
):
106-
# Warn not to do this
107-
warn_deprecated(
108-
"Using Option for bridge commands",
109-
"BridgeOption",
110-
"2.5",
111-
"2.7",
112-
reference="https://github.com/Pycord-Development/pycord/pull/2417",
113-
stacklevel=6,
114-
)
115-
# Override the convert method of the parameter's annotated Option.
116-
# We can use the convert method from BridgeOption, and bind "self"
117-
# using a manual invocation of the descriptor protocol.
118-
# Definitely not a good approach, but gets the job done until removal.
119-
self.params[name].annotation.convert = BridgeOption.convert.__get__(
120-
self.params[name].annotation
105+
raise TypeError(
106+
f"{option.annotation.__class__.__name__} is not supported in bridge commands. Use BridgeOption instead."
121107
)
122108

123109
async def dispatch_error(self, ctx: BridgeExtContext, error: Exception) -> None:

discord/ext/commands/flags.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
from dataclasses import dataclass, field
3232
from typing import TYPE_CHECKING, Any, Iterator, Literal, Pattern, TypeVar, Union
3333

34-
from discord.utils import MISSING, MissingField, maybe_coroutine, resolve_annotation
35-
36-
if sys.version_info >= (3, 11):
37-
_MISSING = MissingField
38-
else:
39-
_MISSING = MISSING
34+
from discord.utils import (
35+
MISSING,
36+
maybe_coroutine,
37+
resolve_annotation,
38+
)
4039

4140
from .converter import run_converters
4241
from .errors import (
@@ -59,6 +58,10 @@
5958
from .context import Context
6059

6160

61+
def _missing_field_factory() -> field:
62+
return field(default_factory=lambda: MISSING)
63+
64+
6265
@dataclass
6366
class Flag:
6467
"""Represents a flag parameter for :class:`FlagConverter`.
@@ -86,13 +89,13 @@ class Flag:
8689
Whether multiple given values overrides the previous value.
8790
"""
8891

89-
name: str = _MISSING
92+
name: str = _missing_field_factory()
9093
aliases: list[str] = field(default_factory=list)
91-
attribute: str = _MISSING
92-
annotation: Any = _MISSING
93-
default: Any = _MISSING
94-
max_args: int = _MISSING
95-
override: bool = _MISSING
94+
attribute: str = _missing_field_factory()
95+
annotation: Any = _missing_field_factory()
96+
default: Any = _missing_field_factory()
97+
max_args: int = _missing_field_factory()
98+
override: bool = _missing_field_factory()
9699
cast_to_dict: bool = False
97100

98101
@property

discord/guild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
from .welcome_screen import WelcomeScreen, WelcomeScreenChannel
9090
from .widget import Widget
9191

92-
__all__ = ("Guild",)
92+
__all__ = ("BanEntry", "Guild")
9393

9494
MISSING = utils.MISSING
9595

discord/interactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import annotations
2727

2828
import asyncio
29+
import datetime
2930
from typing import TYPE_CHECKING, Any, Coroutine, Union
3031

3132
from . import utils
@@ -300,6 +301,11 @@ def guild(self) -> Guild | None:
300301
return self._guild
301302
return self._state and self._state._get_guild(self.guild_id)
302303

304+
@property
305+
def created_at(self) -> datetime.datetime:
306+
"""Returns the interaction's creation time in UTC."""
307+
return utils.snowflake_time(self.id)
308+
303309
def is_command(self) -> bool:
304310
"""Indicates whether the interaction is an application command."""
305311
return self.type == InteractionType.application_command

discord/role.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ async def edit(
458458
reason: str | None = MISSING,
459459
icon: bytes | None = MISSING,
460460
unicode_emoji: str | None = MISSING,
461-
) -> Role | None:
461+
) -> Role:
462462
"""|coro|
463463
464464
Edits the role.

0 commit comments

Comments
 (0)