From 0621b38b1127c4e6215656dd4d088b048557ac99 Mon Sep 17 00:00:00 2001 From: DA-344 <108473820+DA-344@users.noreply.github.com> Date: Tue, 29 Apr 2025 21:13:57 +0200 Subject: [PATCH] chore: Update overloads typings --- discord/channel.py | 46 +++++++++++++++++++-------------------- discord/webhook/async_.py | 17 +++++++++------ discord/webhook/sync.py | 37 ++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/discord/channel.py b/discord/channel.py index 314c46fae..168eee1f4 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -2846,15 +2846,15 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): self, *, name: str, - auto_archive_duration: ThreadArchiveDuration = MISSING, - slowmode_delay: Optional[int] = None, - file: File = MISSING, - files: Sequence[File] = MISSING, - allowed_mentions: AllowedMentions = MISSING, - mention_author: bool = MISSING, + auto_archive_duration: ThreadArchiveDuration = ..., + slowmode_delay: Optional[int] = ..., + file: File = ..., + files: Sequence[File] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., view: LayoutView, - suppress_embeds: bool = False, - reason: Optional[str] = None, + suppress_embeds: bool = ..., + reason: Optional[str] = ..., ) -> ThreadWithMessage: ... @@ -2863,21 +2863,21 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): self, *, name: str, - auto_archive_duration: ThreadArchiveDuration = MISSING, - slowmode_delay: Optional[int] = None, - content: Optional[str] = None, - tts: bool = False, - embed: Embed = MISSING, - embeds: Sequence[Embed] = MISSING, - file: File = MISSING, - files: Sequence[File] = MISSING, - stickers: Sequence[Union[GuildSticker, StickerItem]] = MISSING, - allowed_mentions: AllowedMentions = MISSING, - mention_author: bool = MISSING, - applied_tags: Sequence[ForumTag] = MISSING, - view: View = MISSING, - suppress_embeds: bool = False, - reason: Optional[str] = None, + auto_archive_duration: ThreadArchiveDuration = ..., + slowmode_delay: Optional[int] = ..., + content: Optional[str] = ..., + tts: bool = ..., + embed: Embed = ..., + embeds: Sequence[Embed] = ..., + file: File = ..., + files: Sequence[File] = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + applied_tags: Sequence[ForumTag] = ..., + view: View = ..., + suppress_embeds: bool = ..., + reason: Optional[str] = ..., ) -> ThreadWithMessage: ... diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 897ddadd3..df6055d9c 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1983,7 +1983,10 @@ class Webhook(BaseWebhook): self, message_id: int, *, + attachments: Sequence[Union[Attachment, File]] = ..., view: LayoutView, + allowed_mentions: Optional[AllowedMentions] = ..., + thread: Snowflake = ..., ) -> WebhookMessage: ... @@ -1992,13 +1995,13 @@ class Webhook(BaseWebhook): self, message_id: int, *, - content: Optional[str] = MISSING, - embeds: Sequence[Embed] = MISSING, - embed: Optional[Embed] = MISSING, - attachments: Sequence[Union[Attachment, File]] = MISSING, - view: Optional[View] = MISSING, - allowed_mentions: Optional[AllowedMentions] = None, - thread: Snowflake = MISSING, + content: Optional[str] = ..., + embeds: Sequence[Embed] = ..., + embed: Optional[Embed] = ..., + attachments: Sequence[Union[Attachment, File]] = ..., + view: Optional[View] = ..., + allowed_mentions: Optional[AllowedMentions] = ..., + thread: Snowflake = ..., ) -> WebhookMessage: ... diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py index 9c211898d..d5295c1fc 100644 --- a/discord/webhook/sync.py +++ b/discord/webhook/sync.py @@ -1035,7 +1035,7 @@ class SyncWebhook(BaseWebhook): .. versionadded:: 2.4 view: Union[:class:`~discord.ui.View`, :class:`~discord.ui.LayoutView`] - The view to send with the message. This can only have URL buttons, which donnot + The view to send with the message. This can only have non-interactible items, which donnot require a state to be attached to it. If you want to send a view with any component attached to it, check :meth:`Webhook.send`. @@ -1185,6 +1185,33 @@ class SyncWebhook(BaseWebhook): ) return self._create_message(data, thread=thread) + @overload + def edit_message( + self, + message_id: int, + *, + attachments: Sequence[Union[Attachment, File]] = ..., + view: LayoutView, + allowed_mentions: Optional[AllowedMentions] = ..., + thread: Snowflake = ..., + ) -> SyncWebhookMessage: + ... + + @overload + def edit_message( + self, + message_id: int, + *, + content: Optional[str] = ..., + embeds: Sequence[Embed] = ..., + embed: Optional[Embed] = ..., + attachments: Sequence[Union[Attachment, File]] = ..., + view: Optional[View] = ..., + allowed_mentions: Optional[AllowedMentions] = ..., + thread: Snowflake = ..., + ) -> SyncWebhookMessage: + ... + def edit_message( self, message_id: int, @@ -1193,6 +1220,7 @@ class SyncWebhook(BaseWebhook): embeds: Sequence[Embed] = MISSING, embed: Optional[Embed] = MISSING, attachments: Sequence[Union[Attachment, File]] = MISSING, + view: Optional[BaseView] = MISSING, allowed_mentions: Optional[AllowedMentions] = None, thread: Snowflake = MISSING, ) -> SyncWebhookMessage: @@ -1219,6 +1247,13 @@ class SyncWebhook(BaseWebhook): then all attachments are removed. .. versionadded:: 2.0 + view: Optional[Union[:class:`~discord.ui.View`, :class:`~discord.ui.LayoutView`]] + The updated view to update this message with. This can only have non-interactible items, which donnot + require a state to be attached to it. If ``None`` is passed then the view is removed. + + If you want to edit a webhook message with any component attached to it, check :meth:`WebhookMessage.edit`. + + .. versionadded:: 2.6 allowed_mentions: :class:`AllowedMentions` Controls the mentions being processed in this message. See :meth:`.abc.Messageable.send` for more information.