Skip to content

Commit def647e

Browse files
committed
Merge branch 'master' into soundboard
2 parents 0442b60 + 84a68e5 commit def647e

Some content is hidden

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

41 files changed

+2781
-185
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.0
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.0
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 }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ repos:
8787
args: [--prose-wrap=always, --print-width=88]
8888
exclude: \.(po|pot|yml|yaml)$
8989
- repo: https://github.com/DanielNoord/pydocstringformatter
90-
rev: v0.7.3
90+
rev: v0.7.5
9191
hooks:
9292
- id: pydocstringformatter
9393
exclude: \.(po|pot|yml|yaml)$

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ These changes are available on the `master` branch, but have not yet been releas
128128
([#2781](https://github.com/Pycord-Development/pycord/pull/2781))
129129
- Fixed `VoiceClient` crashing randomly while receiving audio
130130
([#2800](https://github.com/Pycord-Development/pycord/pull/2800))
131+
- Fixed `VoiceClient.connect` failing to do initial connection.
132+
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
131133

132134
### Changed
133135

@@ -147,6 +149,8 @@ These changes are available on the `master` branch, but have not yet been releas
147149
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
148150
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
149151
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
152+
- Upgraded voice websocket version to v8.
153+
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
150154

151155
### Deprecated
152156

@@ -159,8 +163,8 @@ These changes are available on the `master` branch, but have not yet been releas
159163

160164
### Removed
161165

162-
- Removed deprecated support for `Option` in `BridgeCommand`. Use `BridgeOption`
163-
instead. ([#2731])(https://github.com/Pycord-Development/pycord/pull/2731))
166+
- Removed deprecated support for `Option` in `BridgeCommand`, use `BridgeOption`
167+
instead. ([#2731](https://github.com/Pycord-Development/pycord/pull/2731))
164168

165169
## [2.6.1] - 2024-09-15
166170

discord/abc.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,12 @@ async def send(
16151615
)
16161616

16171617
components = view.to_components()
1618+
if view.is_components_v2():
1619+
if embeds or content:
1620+
raise TypeError(
1621+
"cannot send embeds or content with a view using v2 component logic"
1622+
)
1623+
flags.is_components_v2 = True
16181624
else:
16191625
components = None
16201626

@@ -1679,8 +1685,10 @@ async def send(
16791685

16801686
ret = state.create_message(channel=channel, data=data)
16811687
if view:
1682-
state.store_view(view, ret.id)
1688+
if view.is_dispatchable():
1689+
state.store_view(view, ret.id)
16831690
view.message = ret
1691+
view.refresh(ret.components)
16841692

16851693
if delete_after is not None:
16861694
await ret.delete(delay=delete_after)

discord/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,15 +884,15 @@ async def process_application_commands(
884884

885885
ctx = await self.get_application_context(interaction)
886886
if command:
887-
ctx.command = command
887+
interaction.command = command
888888
await self.invoke_application_command(ctx)
889889

890890
async def on_application_command_auto_complete(
891891
self, interaction: Interaction, command: ApplicationCommand
892892
) -> None:
893893
async def callback() -> None:
894894
ctx = await self.get_autocomplete_context(interaction)
895-
ctx.command = command
895+
interaction.command = command
896896
return await command.invoke_autocomplete_callback(ctx)
897897

898898
autocomplete_task = self._bot.loop.create_task(callback())

discord/channel.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
Iterable,
3434
Mapping,
3535
NamedTuple,
36+
Sequence,
3637
TypeVar,
3738
overload,
3839
)
@@ -55,7 +56,7 @@
5556
)
5657
from .errors import ClientException, InvalidArgument
5758
from .file import File
58-
from .flags import ChannelFlags
59+
from .flags import ChannelFlags, MessageFlags
5960
from .invite import Invite
6061
from .iterators import ArchivedThreadIterator
6162
from .mixins import Hashable
@@ -83,12 +84,15 @@
8384

8485
if TYPE_CHECKING:
8586
from .abc import Snowflake, SnowflakeTime
87+
from .embeds import Embed
8688
from .guild import Guild
8789
from .guild import GuildChannel as GuildChannelType
8890
from .member import Member, VoiceState
91+
from .mentions import AllowedMentions
8992
from .message import EmojiInputType, Message, PartialMessage
9093
from .role import Role
9194
from .state import ConnectionState
95+
from .sticker import GuildSticker, StickerItem
9296
from .types.channel import CategoryChannel as CategoryChannelPayload
9397
from .types.channel import DMChannel as DMChannelPayload
9498
from .types.channel import ForumChannel as ForumChannelPayload
@@ -100,6 +104,7 @@
100104
from .types.channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend
101105
from .types.snowflake import SnowflakeList
102106
from .types.threads import ThreadArchiveDuration
107+
from .ui.view import View
103108
from .user import BaseUser, ClientUser, User
104109
from .webhook import Webhook
105110

@@ -1194,18 +1199,20 @@ async def edit(self, *, reason=None, **options):
11941199
async def create_thread(
11951200
self,
11961201
name: str,
1197-
content=None,
1202+
content: str | None = None,
11981203
*,
1199-
embed=None,
1200-
embeds=None,
1201-
file=None,
1202-
files=None,
1203-
stickers=None,
1204-
delete_message_after=None,
1205-
nonce=None,
1206-
allowed_mentions=None,
1207-
view=None,
1208-
applied_tags=None,
1204+
embed: Embed | None = None,
1205+
embeds: list[Embed] | None = None,
1206+
file: File | None = None,
1207+
files: list[File] | None = None,
1208+
stickers: Sequence[GuildSticker | StickerItem] | None = None,
1209+
delete_message_after: float | None = None,
1210+
nonce: int | str | None = None,
1211+
allowed_mentions: AllowedMentions | None = None,
1212+
view: View | None = None,
1213+
applied_tags: list[ForumTag] | None = None,
1214+
suppress: bool = False,
1215+
silent: bool = False,
12091216
auto_archive_duration: ThreadArchiveDuration = MISSING,
12101217
slowmode_delay: int = MISSING,
12111218
reason: str | None = None,
@@ -1305,13 +1312,24 @@ async def create_thread(
13051312
else:
13061313
allowed_mentions = allowed_mentions.to_dict()
13071314

1315+
flags = MessageFlags(
1316+
suppress_embeds=bool(suppress),
1317+
suppress_notifications=bool(silent),
1318+
)
1319+
13081320
if view:
13091321
if not hasattr(view, "__discord_ui_view__"):
13101322
raise InvalidArgument(
13111323
f"view parameter must be View not {view.__class__!r}"
13121324
)
13131325

13141326
components = view.to_components()
1327+
if view.is_components_v2():
1328+
if embeds or content:
1329+
raise TypeError(
1330+
"cannot send embeds or content with a view using v2 component logic"
1331+
)
1332+
flags.is_components_v2 = True
13151333
else:
13161334
components = None
13171335

@@ -1350,6 +1368,7 @@ async def create_thread(
13501368
or self.default_auto_archive_duration,
13511369
rate_limit_per_user=slowmode_delay or self.slowmode_delay,
13521370
applied_tags=applied_tags,
1371+
flags=flags.value,
13531372
reason=reason,
13541373
)
13551374
finally:
@@ -1359,7 +1378,7 @@ async def create_thread(
13591378

13601379
ret = Thread(guild=self.guild, state=self._state, data=data)
13611380
msg = ret.get_partial_message(int(data["last_message_id"]))
1362-
if view:
1381+
if view and view.is_dispatchable():
13631382
state.store_view(view, msg.id)
13641383

13651384
if delete_message_after is not None:

discord/client.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@
6969
if TYPE_CHECKING:
7070
from .abc import GuildChannel, PrivateChannel, Snowflake, SnowflakeTime
7171
from .channel import DMChannel
72+
from .interaction import Interaction
7273
from .member import Member
7374
from .message import Message
7475
from .poll import Poll
7576
from .soundboard import SoundboardSound
77+
from .ui.item import Item
7678
from .voice_client import VoiceProtocol
7779

7880
__all__ = ("Client",)
@@ -543,6 +545,38 @@ async def on_error(self, event_method: str, *args: Any, **kwargs: Any) -> None:
543545
print(f"Ignoring exception in {event_method}", file=sys.stderr)
544546
traceback.print_exc()
545547

548+
async def on_view_error(
549+
self, error: Exception, item: Item, interaction: Interaction
550+
) -> None:
551+
"""|coro|
552+
553+
The default view error handler provided by the client.
554+
555+
This only fires for a view if you did not define its :func:`~discord.ui.View.on_error`.
556+
"""
557+
558+
print(
559+
f"Ignoring exception in view {interaction.view} for item {item}:",
560+
file=sys.stderr,
561+
)
562+
traceback.print_exception(
563+
error.__class__, error, error.__traceback__, file=sys.stderr
564+
)
565+
566+
async def on_modal_error(self, error: Exception, interaction: Interaction) -> None:
567+
"""|coro|
568+
569+
The default modal error handler provided by the client.
570+
The default implementation prints the traceback to stderr.
571+
572+
This only fires for a modal if you did not define its :func:`~discord.ui.Modal.on_error`.
573+
"""
574+
575+
print(f"Ignoring exception in modal {interaction.modal}:", file=sys.stderr)
576+
traceback.print_exception(
577+
error.__class__, error, error.__traceback__, file=sys.stderr
578+
)
579+
546580
# hooks
547581

548582
async def _call_before_identify_hook(

discord/commands/context.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,13 @@ class ApplicationContext(discord.abc.Messageable):
8080
The bot that the command belongs to.
8181
interaction: :class:`.Interaction`
8282
The interaction object that invoked the command.
83-
command: :class:`.ApplicationCommand`
84-
The command that this context belongs to.
8583
"""
8684

8785
def __init__(self, bot: Bot, interaction: Interaction):
8886
self.bot = bot
8987
self.interaction = interaction
9088

9189
# below attributes will be set after initialization
92-
self.command: ApplicationCommand = None # type: ignore
9390
self.focused: Option = None # type: ignore
9491
self.value: str = None # type: ignore
9592
self.options: dict = None # type: ignore
@@ -136,6 +133,15 @@ async def invoke(
136133
"""
137134
return await command(self, *args, **kwargs)
138135

136+
@property
137+
def command(self) -> ApplicationCommand | None:
138+
"""The command that this context belongs to."""
139+
return self.interaction.command
140+
141+
@command.setter
142+
def command(self, value: ApplicationCommand | None) -> None:
143+
self.interaction.command = value
144+
139145
@cached_property
140146
def channel(self) -> InteractionChannel | None:
141147
"""Union[:class:`abc.GuildChannel`, :class:`PartialMessageable`, :class:`Thread`]:
@@ -393,8 +399,6 @@ class AutocompleteContext:
393399
The bot that the command belongs to.
394400
interaction: :class:`.Interaction`
395401
The interaction object that invoked the autocomplete.
396-
command: :class:`.ApplicationCommand`
397-
The command that this context belongs to.
398402
focused: :class:`.Option`
399403
The option the user is currently typing.
400404
value: :class:`.str`
@@ -403,13 +407,12 @@ class AutocompleteContext:
403407
A name to value mapping of the options that the user has selected before this option.
404408
"""
405409

406-
__slots__ = ("bot", "interaction", "command", "focused", "value", "options")
410+
__slots__ = ("bot", "interaction", "focused", "value", "options")
407411

408412
def __init__(self, bot: Bot, interaction: Interaction):
409413
self.bot = bot
410414
self.interaction = interaction
411415

412-
self.command: ApplicationCommand = None # type: ignore
413416
self.focused: Option = None # type: ignore
414417
self.value: str = None # type: ignore
415418
self.options: dict = None # type: ignore
@@ -423,3 +426,12 @@ def cog(self) -> Cog | None:
423426
return None
424427

425428
return self.command.cog
429+
430+
@property
431+
def command(self) -> ApplicationCommand | None:
432+
"""The command that this context belongs to."""
433+
return self.interaction.command
434+
435+
@command.setter
436+
def command(self, value: ApplicationCommand | None) -> None:
437+
self.interaction.command = value

0 commit comments

Comments
 (0)