Skip to content

Commit e126d12

Browse files
authored
Merge branch 'master' into channel
Signed-off-by: Lumouille <[email protected]>
2 parents 6074efa + dd7d5a6 commit e126d12

File tree

510 files changed

+51109
-12393
lines changed

Some content is hidden

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

510 files changed

+51109
-12393
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/github-action@v2.7.1
43+
uses: crowdin/github-action@v2.9.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/github-action@v2.7.1
47+
uses: crowdin/github-action@v2.9.1
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.github/workflows/todo-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: "Checkout Repository"
2424
uses: actions/checkout@v4
2525
- name: "Track TODO Action"
26-
uses: ribtoks/[email protected].14-beta
26+
uses: ribtoks/[email protected].15-beta
2727
with:
2828
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
REPO: ${{ github.repository }}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ These changes are available on the `master` branch, but have not yet been releas
5151
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
5252
- Added `Message.forward_to`, `Message.snapshots`, and other related attributes.
5353
([#2598](https://github.com/Pycord-Development/pycord/pull/2598))
54+
- Add missing `Guild` feature flags and `Guild.edit` parameters.
55+
([#2672](https://github.com/Pycord-Development/pycord/pull/2672))
5456
- Added the ability to change the API's base URL with `Route.API_BASE_URL`.
5557
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
5658
- Added the ability to pass a `datetime.time` object to `format_dt`.
5759
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
5860
- Added various missing channel parameters and allow `default_reaction_emoji` to be
5961
`None`. ([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
62+
- Added conversion to `Member` in `MentionableConverter`.
63+
([#2775](https://github.com/Pycord-Development/pycord/pull/2775))
6064
- Added `discord.Interaction.created_at`.
6165
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))
6266

@@ -121,6 +125,12 @@ These changes are available on the `master` branch, but have not yet been releas
121125
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
122126
- Fixed `VoiceClient` crashing randomly while receiving audio
123127
([#2800](https://github.com/Pycord-Development/pycord/pull/2800))
128+
- Fixed `VoiceClient.connect` failing to do initial connection.
129+
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
130+
- Fixed `AttributeError` when printing a File component's `__repr__`.
131+
([#2843](https://github.com/Pycord-Development/pycord/pull/2843))
132+
- Fixed `TypeError` when using `@option` with certain annotations and along with
133+
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
124134

125135
### Changed
126136

@@ -140,6 +150,8 @@ These changes are available on the `master` branch, but have not yet been releas
140150
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
141151
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
142152
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
153+
- Upgraded voice websocket version to v8.
154+
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
143155

144156
### Deprecated
145157

crowdin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ preserve_hierarchy: true
55

66
commit_message: "docs: Update translations"
77

8-
export_languages: ["de", "ja", "fr", "it", "hi", "ko", "pt-BR", "es-ES", "zh-CN"]
8+
export_languages: ["de", "ja", "fr", "it", "hi", "ko", "pt-BR", "es-ES", "zh-CN", "tr"]
99

1010
bundles:
1111
- 1

discord/asset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ class Asset(AssetMixin):
144144
145145
.. describe:: hash(x)
146146
147-
Returns the hash of the asset.
147+
Returns the asset's url's hash.
148+
149+
This is equivalent to hash(:attr:`url`).
148150
"""
149151

150152
__slots__: tuple[str, ...] = (

discord/commands/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ def __init__(
225225
self.description = description or "No description provided"
226226
self.channel_types: list[ChannelType] = kwargs.pop("channel_types", [])
227227

228-
if isinstance(input_type, SlashCommandOptionType):
228+
if self.channel_types:
229+
self.input_type = SlashCommandOptionType.channel
230+
elif isinstance(input_type, SlashCommandOptionType):
229231
self.input_type = input_type
230232
else:
231233
from ..ext.commands import Converter

discord/ext/bridge/core.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
Converter,
5252
Group,
5353
GuildChannelConverter,
54+
MemberConverter,
5455
RoleConverter,
5556
UserConverter,
5657
)
@@ -566,13 +567,21 @@ def predicate(func: Callable | ApplicationCommand):
566567

567568

568569
class MentionableConverter(Converter):
569-
"""A converter that can convert a mention to a user or a role."""
570+
"""A converter that can convert a mention to a member, a user or a role."""
570571

571572
async def convert(self, ctx, argument):
572573
try:
573574
return await RoleConverter().convert(ctx, argument)
574575
except BadArgument:
575-
return await UserConverter().convert(ctx, argument)
576+
pass
577+
578+
if ctx.guild:
579+
try:
580+
return await MemberConverter().convert(ctx, argument)
581+
except BadArgument:
582+
pass
583+
584+
return await UserConverter().convert(ctx, argument)
576585

577586

578587
class AttachmentConverter(Converter):
@@ -600,6 +609,7 @@ async def convert(self, ctx, arg: bool):
600609
SlashCommandOptionType.mentionable: MentionableConverter,
601610
SlashCommandOptionType.number: float,
602611
SlashCommandOptionType.attachment: AttachmentConverter,
612+
discord.Member: MemberConverter,
603613
}
604614

605615

@@ -608,16 +618,24 @@ class BridgeOption(Option, Converter):
608618
command option and a prefixed command argument for bridge commands.
609619
"""
610620

621+
def __init__(self, input_type, *args, **kwargs):
622+
self.converter = kwargs.pop("converter", None)
623+
super().__init__(input_type, *args, **kwargs)
624+
625+
self.converter = self.converter or BRIDGE_CONVERTER_MAPPING.get(input_type)
626+
611627
async def convert(self, ctx, argument: str) -> Any:
612628
try:
613629
if self.converter is not None:
614-
converted = await self.converter.convert(ctx, argument)
630+
converted = await self.converter().convert(ctx, argument)
615631
else:
616-
converter = BRIDGE_CONVERTER_MAPPING[self.input_type]
617-
if issubclass(converter, Converter):
632+
converter = BRIDGE_CONVERTER_MAPPING.get(self.input_type)
633+
if isinstance(converter, type) and issubclass(converter, Converter):
618634
converted = await converter().convert(ctx, argument) # type: ignore # protocol class
619-
else:
635+
elif callable(converter):
620636
converted = converter(argument)
637+
else:
638+
raise TypeError(f"Invalid converter: {converter}")
621639

622640
if self.choices:
623641
choices_names: list[str | int | float] = [

discord/gateway.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import traceback
3636
import zlib
3737
from collections import deque, namedtuple
38+
from typing import TYPE_CHECKING
3839

3940
import aiohttp
4041

@@ -208,6 +209,9 @@ def ack(self):
208209

209210

210211
class VoiceKeepAliveHandler(KeepAliveHandler):
212+
if TYPE_CHECKING:
213+
ws: DiscordVoiceWebSocket
214+
211215
def __init__(self, *args, **kwargs):
212216
super().__init__(*args, **kwargs)
213217
self.recent_ack_latencies = deque(maxlen=20)
@@ -216,7 +220,10 @@ def __init__(self, *args, **kwargs):
216220
self.behind_msg = "High socket latency, shard ID %s heartbeat is %.1fs behind"
217221

218222
def get_payload(self):
219-
return {"op": self.ws.HEARTBEAT, "d": int(time.time() * 1000)}
223+
return {
224+
"op": self.ws.HEARTBEAT,
225+
"d": {"t": int(time.time() * 1000), "seq_ack": self.ws.seq_ack},
226+
}
220227

221228
def ack(self):
222229
ack_time = time.perf_counter()
@@ -784,6 +791,7 @@ def __init__(self, socket, loop, *, hook=None):
784791
self._close_code = None
785792
self.secret_key = None
786793
self.ssrc_map = {}
794+
self.seq_ack: int = -1
787795
if hook:
788796
self._hook = hook
789797

@@ -804,6 +812,9 @@ async def resume(self):
804812
"token": state.token,
805813
"server_id": str(state.server_id),
806814
"session_id": state.session_id,
815+
# this seq_ack will allow for us to do buffered resume, which is, receive the
816+
# lost voice packets while trying to resume the reconnection
817+
"seq_ack": self.seq_ack,
807818
},
808819
}
809820
await self.send_as_json(payload)
@@ -824,7 +835,7 @@ async def identify(self):
824835
@classmethod
825836
async def from_client(cls, client, *, resume=False, hook=None):
826837
"""Creates a voice websocket for the :class:`VoiceClient`."""
827-
gateway = f"wss://{client.endpoint}/?v=4"
838+
gateway = f"wss://{client.endpoint}/?v=8"
828839
http = client._state.http
829840
socket = await http.ws_connect(gateway, compress=15)
830841
ws = cls(socket, loop=client.loop, hook=hook)
@@ -860,14 +871,21 @@ async def client_connect(self):
860871
await self.send_as_json(payload)
861872

862873
async def speak(self, state=SpeakingState.voice):
863-
payload = {"op": self.SPEAKING, "d": {"speaking": int(state), "delay": 0}}
874+
payload = {
875+
"op": self.SPEAKING,
876+
"d": {
877+
"speaking": int(state),
878+
"delay": 0,
879+
},
880+
}
864881

865882
await self.send_as_json(payload)
866883

867884
async def received_message(self, msg):
868885
_log.debug("Voice websocket frame received: %s", msg)
869886
op = msg["op"]
870887
data = msg.get("d")
888+
self.seq_ack = data.get("seq", self.seq_ack)
871889

872890
if op == self.READY:
873891
await self.initial_connection(data)

discord/guild.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,9 @@ async def edit(
17981798
public_updates_channel: TextChannel | None = MISSING,
17991799
premium_progress_bar_enabled: bool = MISSING,
18001800
disable_invites: bool = MISSING,
1801+
discoverable: bool = MISSING,
1802+
disable_raid_alerts: bool = MISSING,
1803+
enable_activity_feed: bool = MISSING,
18011804
) -> Guild:
18021805
r"""|coro|
18031806
@@ -1875,6 +1878,12 @@ async def edit(
18751878
Whether the guild should have premium progress bar enabled.
18761879
disable_invites: :class:`bool`
18771880
Whether the guild should have server invites enabled or disabled.
1881+
discoverable: :class:`bool`
1882+
Whether the guild should be discoverable in the discover tab.
1883+
disable_raid_alerts: :class:`bool`
1884+
Whether activity alerts for the guild should be disabled.
1885+
enable_activity_feed: class:`bool`
1886+
Whether the guild's user activity feed should be enabled.
18781887
reason: Optional[:class:`str`]
18791888
The reason for editing this guild. Shows up on the audit log.
18801889
@@ -1996,8 +2005,12 @@ async def edit(
19962005

19972006
fields["system_channel_flags"] = system_channel_flags.value
19982007

2008+
if premium_progress_bar_enabled is not MISSING:
2009+
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
2010+
2011+
features: list[GuildFeature] = self.features.copy()
2012+
19992013
if community is not MISSING:
2000-
features = self.features.copy()
20012014
if community:
20022015
if (
20032016
"rules_channel_id" in fields
@@ -2007,8 +2020,7 @@ async def edit(
20072020
features.append("COMMUNITY")
20082021
else:
20092022
raise InvalidArgument(
2010-
"community field requires both rules_channel and"
2011-
" public_updates_channel fields to be provided"
2023+
"community field requires both rules_channel and public_updates_channel fields to be provided"
20122024
)
20132025
else:
20142026
if "COMMUNITY" in features:
@@ -2018,20 +2030,43 @@ async def edit(
20182030
fields["public_updates_channel_id"] = None
20192031
features.remove("COMMUNITY")
20202032

2021-
fields["features"] = features
2022-
2023-
if premium_progress_bar_enabled is not MISSING:
2024-
fields["premium_progress_bar_enabled"] = premium_progress_bar_enabled
2025-
20262033
if disable_invites is not MISSING:
2027-
features = self.features.copy()
20282034
if disable_invites:
2029-
if not "INVITES_DISABLED" in features:
2035+
if "INVITES_DISABLED" not in features:
20302036
features.append("INVITES_DISABLED")
20312037
else:
20322038
if "INVITES_DISABLED" in features:
20332039
features.remove("INVITES_DISABLED")
20342040

2041+
if discoverable is not MISSING:
2042+
if discoverable:
2043+
if "DISCOVERABLE" not in features:
2044+
features.append("DISCOVERABLE")
2045+
else:
2046+
if "DISCOVERABLE" in features:
2047+
features.remove("DISCOVERABLE")
2048+
2049+
if disable_raid_alerts is not MISSING:
2050+
if disable_raid_alerts:
2051+
if "RAID_ALERTS_DISABLED" not in features:
2052+
features.append("RAID_ALERTS_DISABLED")
2053+
else:
2054+
if "RAID_ALERTS_DISABLED" in features:
2055+
features.remove("RAID_ALERTS_DISABLED")
2056+
2057+
if enable_activity_feed is not MISSING:
2058+
if enable_activity_feed:
2059+
if "ACTIVITY_FEED_ENABLED_BY_USER" not in features:
2060+
features.append("ACTIVITY_FEED_ENABLED_BY_USER")
2061+
if "ACTIVITY_FEED_DISABLED_BY_USER" in features:
2062+
features.remove("ACTIVITY_FEED_DISABLED_BY_USER")
2063+
else:
2064+
if "ACTIVITY_FEED_ENABLED_BY_USER" in features:
2065+
features.remove("ACTIVITY_FEED_ENABLED_BY_USER")
2066+
if "ACTIVITY_FEED_DISABLED_BY_USER" not in features:
2067+
features.append("ACTIVITY_FEED_DISABLED_BY_USER")
2068+
2069+
if self.features != features:
20352070
fields["features"] = features
20362071

20372072
data = await http.edit_guild(self.id, reason=reason, **fields)

0 commit comments

Comments
 (0)