diff --git a/discord/ext/commands/context.py b/discord/ext/commands/context.py index e12b5b016..39f5a0930 100644 --- a/discord/ext/commands/context.py +++ b/discord/ext/commands/context.py @@ -24,12 +24,12 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations import re -from typing import TYPE_CHECKING, Any, AsyncIterator, Collection, Dict, Generic, List, Optional, TypeVar, Union +from typing import TYPE_CHECKING, Any, AsyncIterator, Collection, Dict, Generic, List, Optional, overload, Sequence, TypeVar, Union import discord.abc import discord.utils -from discord.utils import MISSING from discord.message import Message +from discord.utils import MISSING from ._types import BotT @@ -38,9 +38,12 @@ if TYPE_CHECKING: from discord.abc import MessageableChannel from discord.commands import MessageCommand + from discord.file import File from discord.guild import Guild from discord.member import Member + from discord.mentions import AllowedMentions from discord.state import ConnectionState + from discord.sticker import GuildSticker, StickerItem from discord.user import ClientUser, User from discord.voice_client import VoiceProtocol @@ -411,6 +414,78 @@ class Context(discord.abc.Messageable, Generic[BotT]): except CommandError as e: await cmd.on_help_command_error(self, e) + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + file: File = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + ephemeral: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + files: Sequence[File] = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + ephemeral: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + file: File = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + ephemeral: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + files: Sequence[File] = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + ephemeral: bool = ..., + silent: bool = ..., + ) -> Message: + ... + @discord.utils.copy_doc(Message.reply) async def reply(self, content: Optional[str] = None, **kwargs: Any) -> Message: return await self.message.reply(content, **kwargs) diff --git a/discord/message.py b/discord/message.py index 8a70d1e9f..4609c74b6 100644 --- a/discord/message.py +++ b/discord/message.py @@ -62,7 +62,7 @@ from .utils import escape_mentions, MISSING from .http import handle_message_parameters from .guild import Guild from .mixins import Hashable -from .sticker import StickerItem +from .sticker import StickerItem, GuildSticker from .threads import Thread from .channel import PartialMessageable from .interactions import Interaction @@ -1127,6 +1127,74 @@ class PartialMessage(Hashable): """ await self._state.http.ack_message(self.channel.id, self.id) + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + file: File = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + files: Sequence[File] = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + file: File = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + silent: bool = ..., + ) -> Message: + ... + + @overload + async def reply( + self, + content: Optional[str] = ..., + *, + tts: bool = ..., + files: Sequence[File] = ..., + stickers: Sequence[Union[GuildSticker, StickerItem]] = ..., + delete_after: float = ..., + nonce: Union[str, int] = ..., + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + suppress_embeds: bool = ..., + silent: bool = ..., + ) -> Message: + ... + async def reply(self, content: Optional[str] = None, **kwargs: Any) -> Message: """|coro| @@ -1157,6 +1225,23 @@ class PartialMessage(Hashable): """ return await self.channel.send(content, reference=self, **kwargs) + @overload + async def greet( + self, + sticker: Union[GuildSticker, StickerItem], + *, + allowed_mentions: AllowedMentions = ..., + mention_author: bool = ..., + ) -> Message: + ... + + @overload + async def greet( + self, + sticker: Union[GuildSticker, StickerItem] + ) -> Message: + ... + async def greet(self, sticker: Union[GuildSticker, StickerItem], **kwargs: Any) -> Message: """|coro|