Skip to content

Commit 757d97c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into akiko
2 parents dea2f56 + c342db8 commit 757d97c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1466
-339
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Replace Black with Ruff, then format whole project.
2+
44a44e938fb2bd0bb085d8aa4577abeb01653ad3

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install dependencies
2828
id: install-deps
2929
run: |
30-
python -m pip install --upgrade pip setuptools wheel ruff==0.12 requests
30+
python -m pip install --upgrade pip setuptools wheel ruff==0.12 requests "typing_extensions>=4.3,<5"
3131
pip install -U -r requirements.txt
3232
3333
- name: Setup node.js

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ docs/crowdin.py
1616
*.mo
1717
/.coverage
1818
build/*
19+
uv.lock*
20+
pylock*.toml

discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
from .presences import *
7676
from .primary_guild import *
7777
from .onboarding import *
78+
from .collectible import *
7879

7980

8081
class VersionInfo(NamedTuple):

discord/abc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ async def _purge_helper(
195195
count = 0
196196
await asyncio.sleep(1)
197197

198+
if not message.type.is_deletable():
199+
continue
200+
198201
if not check(message):
199202
continue
200203

discord/app_commands/commands.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,10 +2523,7 @@ def inner(f: T) -> T:
25232523
allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
25242524
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment
25252525

2526-
# Ensure that only Guild context is allowed
2527-
allowed_contexts.guild = True # Enable guild context
2528-
allowed_contexts.private_channel = False # Disable private channel context
2529-
allowed_contexts.dm_channel = False # Disable DM context
2526+
allowed_contexts.guild = True
25302527

25312528
return f
25322529

@@ -2578,10 +2575,7 @@ def inner(f: T) -> T:
25782575
allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
25792576
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment
25802577

2581-
# Ensure that only Private Channel context is allowed
2582-
allowed_contexts.guild = False # Disable guild context
2583-
allowed_contexts.private_channel = True # Enable private channel context
2584-
allowed_contexts.dm_channel = False # Disable DM context
2578+
allowed_contexts.private_channel = True
25852579

25862580
return f
25872581

@@ -2631,11 +2625,7 @@ def inner(f: T) -> T:
26312625
allowed_contexts = getattr(f, '__discord_app_commands_contexts__', None) or AppCommandContext()
26322626
f.__discord_app_commands_contexts__ = allowed_contexts # type: ignore # Runtime attribute assignment
26332627

2634-
# Ensure that only DM context is allowed
2635-
allowed_contexts.guild = False # Disable guild context
2636-
allowed_contexts.private_channel = False # Disable private channel context
2637-
allowed_contexts.dm_channel = True # Enable DM context
2638-
2628+
allowed_contexts.dm_channel = True
26392629
return f
26402630

26412631
# Check if called with parentheses or not
@@ -2727,7 +2717,6 @@ def inner(f: T) -> T:
27272717
f.__discord_app_commands_installation_types__ = allowed_installs # type: ignore # Runtime attribute assignment
27282718

27292719
allowed_installs.guild = True
2730-
allowed_installs.user = False
27312720

27322721
return f
27332722

@@ -2776,7 +2765,6 @@ def inner(f: T) -> T:
27762765
f.__discord_app_commands_installation_types__ = allowed_installs # type: ignore # Runtime attribute assignment
27772766

27782767
allowed_installs.user = True
2779-
allowed_installs.guild = False
27802768

27812769
return f
27822770

discord/asset.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,16 @@ def _from_primary_guild(cls, state: _State, guild_id: int, icon_hash: str) -> Se
355355
animated=False,
356356
)
357357

358+
@classmethod
359+
def _from_user_collectible(cls, state: _State, asset: str, animated: bool = False) -> Self:
360+
name = 'static.png' if not animated else 'asset.webm'
361+
return cls(
362+
state,
363+
url=f'{cls.BASE}/assets/collectibles/{asset}{name}',
364+
key=asset,
365+
animated=animated,
366+
)
367+
358368
def __str__(self) -> str:
359369
return self._url
360370

discord/audit_logs.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,6 @@ class _AuditLogProxyAutoModAction(_AuditLogProxy):
630630
channel: Optional[Union[abc.GuildChannel, Thread]]
631631

632632

633-
class _AuditLogProxyAutoModActionQuarantineUser(_AuditLogProxy):
634-
automod_rule_name: str
635-
automod_rule_trigger_type: str
636-
637-
638633
class _AuditLogProxyMemberKickOrMemberRoleUpdate(_AuditLogProxy):
639634
integration_type: Optional[str]
640635

@@ -725,7 +720,6 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
725720
_AuditLogProxyStageInstanceAction,
726721
_AuditLogProxyMessageBulkDelete,
727722
_AuditLogProxyAutoModAction,
728-
_AuditLogProxyAutoModActionQuarantineUser,
729723
_AuditLogProxyMemberKickOrMemberRoleUpdate,
730724
Member, User, None, PartialIntegration,
731725
Role, Object
@@ -766,6 +760,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
766760
self.action is enums.AuditLogAction.automod_block_message
767761
or self.action is enums.AuditLogAction.automod_flag_message
768762
or self.action is enums.AuditLogAction.automod_timeout_member
763+
or self.action is enums.AuditLogAction.automod_quarantine_user
769764
):
770765
channel_id = utils._get_as_snowflake(extra, 'channel_id')
771766
channel = None
@@ -781,13 +776,6 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
781776
),
782777
channel=channel,
783778
)
784-
elif self.action is enums.AuditLogAction.automod_quarantine_user:
785-
self.extra = _AuditLogProxyAutoModActionQuarantineUser(
786-
automod_rule_name=extra['auto_moderation_rule_name'],
787-
automod_rule_trigger_type=enums.try_enum(
788-
enums.AutoModRuleTriggerType, int(extra['auto_moderation_rule_trigger_type'])
789-
),
790-
)
791779

792780
elif self.action.name.startswith('overwrite_'):
793781
# the overwrite_ actions have a dict with some information

discord/channel.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,7 @@ async def create_thread(
28792879
applied_tags: Sequence[ForumTag] = ...,
28802880
view: LayoutView,
28812881
suppress_embeds: bool = ...,
2882+
silent: bool = ...,
28822883
reason: Optional[str] = ...,
28832884
) -> ThreadWithMessage: ...
28842885

@@ -2901,6 +2902,7 @@ async def create_thread(
29012902
applied_tags: Sequence[ForumTag] = ...,
29022903
view: View = ...,
29032904
suppress_embeds: bool = ...,
2905+
silent: bool = ...,
29042906
reason: Optional[str] = ...,
29052907
) -> ThreadWithMessage: ...
29062908

@@ -2922,6 +2924,7 @@ async def create_thread(
29222924
applied_tags: Sequence[ForumTag] = MISSING,
29232925
view: BaseView = MISSING,
29242926
suppress_embeds: bool = False,
2927+
silent: bool = False,
29252928
reason: Optional[str] = None,
29262929
) -> ThreadWithMessage:
29272930
"""|coro|
@@ -2979,6 +2982,11 @@ async def create_thread(
29792982
A list of stickers to upload. Must be a maximum of 3.
29802983
suppress_embeds: :class:`bool`
29812984
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
2985+
silent: :class:`bool`
2986+
Whether to suppress push and desktop notifications for the message. This will increment the mention counter
2987+
in the UI, but will not actually send a notification.
2988+
2989+
.. versionadded:: 2.7
29822990
reason: :class:`str`
29832991
The reason for creating a new thread. Shows up on the audit log.
29842992
@@ -3011,8 +3019,10 @@ async def create_thread(
30113019
if view and not hasattr(view, '__discord_ui_view__'):
30123020
raise TypeError(f'view parameter must be View not {view.__class__.__name__}')
30133021

3014-
if suppress_embeds:
3015-
flags = MessageFlags._from_value(4)
3022+
if suppress_embeds or silent:
3023+
flags = MessageFlags._from_value(0)
3024+
flags.suppress_embeds = suppress_embeds
3025+
flags.suppress_notifications = silent
30163026
else:
30173027
flags = MISSING
30183028

discord/client.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,25 @@
124124
from .flags import MemberCacheFlags
125125

126126
class _ClientOptions(TypedDict, total=False):
127-
max_messages: int
128-
proxy: str
129-
proxy_auth: aiohttp.BasicAuth
130-
shard_id: int
131-
shard_count: int
127+
max_messages: Optional[int]
128+
proxy: Optional[str]
129+
proxy_auth: Optional[aiohttp.BasicAuth]
130+
shard_id: Optional[int]
131+
shard_count: Optional[int]
132132
application_id: int
133133
member_cache_flags: MemberCacheFlags
134134
chunk_guilds_at_startup: bool
135-
status: Status
136-
activity: BaseActivity
137-
allowed_mentions: AllowedMentions
135+
status: Optional[Status]
136+
activity: Optional[BaseActivity]
137+
allowed_mentions: Optional[AllowedMentions]
138138
heartbeat_timeout: float
139139
guild_ready_timeout: float
140140
assume_unsync_clock: bool
141141
enable_debug_events: bool
142142
enable_raw_presences: bool
143143
http_trace: aiohttp.TraceConfig
144-
max_ratelimit_timeout: float
145-
connector: aiohttp.BaseConnector
144+
max_ratelimit_timeout: Optional[float]
145+
connector: Optional[aiohttp.BaseConnector]
146146

147147

148148
# fmt: off
@@ -2511,7 +2511,7 @@ async def fetch_invite(
25112511
)
25122512
return Invite.from_incomplete(state=self._connection, data=data)
25132513

2514-
async def delete_invite(self, invite: Union[Invite, str], /) -> Invite:
2514+
async def delete_invite(self, invite: Union[Invite, str], /, *, reason: Optional[str] = None) -> Invite:
25152515
"""|coro|
25162516
25172517
Revokes an :class:`.Invite`, URL, or ID to an invite.
@@ -2527,6 +2527,8 @@ async def delete_invite(self, invite: Union[Invite, str], /) -> Invite:
25272527
----------
25282528
invite: Union[:class:`.Invite`, :class:`str`]
25292529
The invite to revoke.
2530+
reason: Optional[:class:`str`]
2531+
The reason for deleting the invite. Shows up on the audit log.
25302532
25312533
Raises
25322534
-------
@@ -2539,7 +2541,7 @@ async def delete_invite(self, invite: Union[Invite, str], /) -> Invite:
25392541
"""
25402542

25412543
resolved = utils.resolve_invite(invite)
2542-
data = await self.http.delete_invite(resolved.code)
2544+
data = await self.http.delete_invite(resolved.code, reason=reason)
25432545
return Invite.from_incomplete(state=self._connection, data=data)
25442546

25452547
# Miscellaneous stuff

0 commit comments

Comments
 (0)