Skip to content

Commit 1277ff0

Browse files
committed
Merge remote-tracking branch 'pycord/master' into fix/flags-3.11+
2 parents d9c39f0 + 2377245 commit 1277ff0

24 files changed

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

CHANGELOG.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ These changes are available on the `master` branch, but have not yet been releas
4949
([#2579](https://github.com/Pycord-Development/pycord/pull/2579))
5050
- Added new `Subscription` object and related methods/events.
5151
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
52+
- Added `Message.forward_to`, `Message.snapshots`, and other related attributes.
53+
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
5254
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
5355
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
54-
- Added the ability to pass a `datetime.time` object to `format_dt`
56+
- Added the ability to pass a `datetime.time` object to `format_dt`.
5557
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
58+
- Added `discord.Interaction.created_at`.
59+
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))
5660

5761
### Fixed
5862

@@ -99,14 +103,22 @@ These changes are available on the `master` branch, but have not yet been releas
99103
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
100104
- Fixed `Subscription.renewal_sku_ids` not accepting `None` from the received payload.
101105
([#2709](https://github.com/Pycord-Development/pycord/pull/2709))
102-
- Fixed `ForumChannel.edit` allowing `default_reaction_emoji` to be `None`
106+
- Fixed `ForumChannel.edit` allowing `default_reaction_emoji` to be `None`.
103107
([#2739](https://github.com/Pycord-Development/pycord/pull/2739))
104108
- Fixed missing `None` type hints in `Select.__init__`.
105109
([#2746])(https://github.com/Pycord-Development/pycord/pull/2746)
106-
- Updated `valid_locales` to support `in` and `es-419`.
107-
([#2767])(https://github.com/Pycord-Development/pycord/pull/2767)
108110
- Fixed `TypeError` when using `Flag` with Python 3.11+.
109111
([#2759])(https://github.com/Pycord-Development/pycord/pull/2759)
112+
- Fixed `TypeError` when specifying `thread_name` in `Webhook.send`.
113+
([#2761])(https://github.com/Pycord-Development/pycord/pull/2761)
114+
- Updated `valid_locales` to support `in` and `es-419`.
115+
([#2767](https://github.com/Pycord-Development/pycord/pull/2767))
116+
- Fixed `Webhook.edit` not working with `attachments=[]`.
117+
([#2779](https://github.com/Pycord-Development/pycord/pull/2779))
118+
- Fixed GIF-based `Sticker` returning the wrong `url`.
119+
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
120+
- Fixed `VoiceClient` crashing randomly while receiving audio
121+
([#2800](https://github.com/Pycord-Development/pycord/pull/2800))
110122

111123
### Changed
112124

@@ -124,6 +136,8 @@ These changes are available on the `master` branch, but have not yet been releas
124136
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
125137
- `Entitlement.ends_at` can now be `None`.
126138
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
139+
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
140+
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
127141

128142
### Deprecated
129143

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

151+
### Removed
152+
153+
- Removed deprecated support for `Option` in `BridgeCommand`. Use `BridgeOption`
154+
instead. ([#2731])(https://github.com/Pycord-Development/pycord/pull/2731))
155+
137156
## [2.6.1] - 2024-09-15
138157

139158
### Fixed

discord/abc.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,9 @@ async def send(
14971497
.. versionadded:: 1.4
14981498
14991499
reference: Union[:class:`~discord.Message`, :class:`~discord.MessageReference`, :class:`~discord.PartialMessage`]
1500-
A reference to the :class:`~discord.Message` to which you are replying, this can be created using
1501-
:meth:`~discord.Message.to_reference` or passed directly as a :class:`~discord.Message`. You can control
1502-
whether this mentions the author of the referenced message using the
1500+
A reference to the :class:`~discord.Message` being replied to or forwarded. This can be created using
1501+
:meth:`~discord.Message.to_reference`.
1502+
When replying, you can control whether this mentions the author of the referenced message using the
15031503
:attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions`` or by
15041504
setting ``mention_author``.
15051505
@@ -1589,9 +1589,19 @@ async def send(
15891589
allowed_mentions = allowed_mentions or AllowedMentions().to_dict()
15901590
allowed_mentions["replied_user"] = bool(mention_author)
15911591

1592+
_reference = None
15921593
if reference is not None:
15931594
try:
1594-
reference = reference.to_message_reference_dict()
1595+
_reference = reference.to_message_reference_dict()
1596+
from .message import MessageReference
1597+
1598+
if not isinstance(reference, MessageReference):
1599+
utils.warn_deprecated(
1600+
f"Passing {type(reference).__name__} to reference",
1601+
"MessageReference",
1602+
"2.7",
1603+
"3.0",
1604+
)
15951605
except AttributeError:
15961606
raise InvalidArgument(
15971607
"reference parameter must be Message, MessageReference, or"
@@ -1641,7 +1651,7 @@ async def send(
16411651
nonce=nonce,
16421652
enforce_nonce=enforce_nonce,
16431653
allowed_mentions=allowed_mentions,
1644-
message_reference=reference,
1654+
message_reference=_reference,
16451655
stickers=stickers,
16461656
components=components,
16471657
flags=flags.value,
@@ -1660,7 +1670,7 @@ async def send(
16601670
nonce=nonce,
16611671
enforce_nonce=enforce_nonce,
16621672
allowed_mentions=allowed_mentions,
1663-
message_reference=reference,
1673+
message_reference=_reference,
16641674
stickers=stickers,
16651675
components=components,
16661676
flags=flags.value,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,9 @@ def get_partial_message(self, message_id: int, /) -> PartialMessage:
34123412

34133413
return PartialMessage(channel=self, id=message_id)
34143414

3415+
def __repr__(self) -> str:
3416+
return f"<PartialMessageable id={self.id} type={self.type!r}>"
3417+
34153418

34163419
def _guild_channel_factory(channel_type: int):
34173420
value = try_enum(ChannelType, channel_type)

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
"EntitlementOwnerType",
7777
"IntegrationType",
7878
"InteractionContextType",
79+
"PollLayoutType",
80+
"MessageReferenceType",
7981
)
8082

8183

@@ -266,6 +268,12 @@ class MessageType(Enum):
266268
stage_raise_hand = 30
267269
stage_topic = 31
268270
guild_application_premium_subscription = 32
271+
guild_incident_alert_mode_enabled = 36
272+
guild_incident_alert_mode_disabled = 37
273+
guild_incident_report_raid = 38
274+
guild_incident_report_false_alarm = 39
275+
purchase_notification = 44
276+
poll_result = 46
269277

270278

271279
class VoiceRegion(Enum):
@@ -1055,6 +1063,13 @@ class PollLayoutType(Enum):
10551063
default = 1
10561064

10571065

1066+
class MessageReferenceType(Enum):
1067+
"""The type of the message reference object"""
1068+
1069+
default = 0
1070+
forward = 1
1071+
1072+
10581073
class SubscriptionStatus(Enum):
10591074
"""The status of a subscription."""
10601075

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,9 @@ async def send_help(self, *args: Any) -> Any:
403403
@discord.utils.copy_doc(Message.reply)
404404
async def reply(self, content: str | None = None, **kwargs: Any) -> Message:
405405
return await self.message.reply(content, **kwargs)
406+
407+
@discord.utils.copy_doc(Message.forward_to)
408+
async def forward_to(
409+
self, channel: discord.abc.Messageable, **kwargs: Any
410+
) -> Message:
411+
return await self.message.forward_to(channel, **kwargs)

discord/flags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,14 @@ def is_voice_message(self):
411411
"""
412412
return 8192
413413

414+
@flag_value
415+
def has_snapshot(self):
416+
""":class:`bool`: Returns ``True`` if this message has a snapshot from message forwarding.
417+
418+
.. versionadded:: 2.7
419+
"""
420+
return 1 << 14
421+
414422

415423
@fill_with_flags()
416424
class PublicUserFlags(BaseFlags):

discord/guild.py

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

91-
__all__ = ("Guild",)
91+
__all__ = ("BanEntry", "Guild")
9292

9393
MISSING = utils.MISSING
9494

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

0 commit comments

Comments
 (0)