Skip to content

Commit 5518474

Browse files
authored
feat: add fail_if_not_exists for PrefixedContext.reply (#1608)
* feat: add toggle for fail_if_not_exists for PrefixedContext.reply * docs: parity with other fail_if_not_exists
1 parent b41c47e commit 5518474

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

interactions/ext/prefixed_commands/context.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from interactions.models.discord.channel import TYPE_MESSAGEABLE_CHANNEL
88
from interactions.models.discord.embed import Embed
99
from interactions.models.discord.file import UPLOADABLE_TYPE
10-
from interactions.models.discord.message import Message
10+
from interactions.models.discord.message import Message, MessageReference
1111
from interactions.models.internal.context import BaseContext
1212
from interactions.models.misc.context_manager import Typing
1313

@@ -86,6 +86,7 @@ async def reply(
8686
content: Optional[str] = None,
8787
embeds: Optional[Union[Iterable[Union[Embed, dict]], Union[Embed, dict]]] = None,
8888
embed: Optional[Union[Embed, dict]] = None,
89+
fail_if_not_exists: bool = True,
8990
**kwargs: Any,
9091
) -> Message:
9192
"""
@@ -95,10 +96,12 @@ async def reply(
9596
content: Message text content.
9697
embeds: Embedded rich content (up to 6000 characters).
9798
embed: Embedded rich content (up to 6000 characters).
99+
fail_if_not_exists: Whether to error if the command invocation doesn't exist instead of sending as a normal (non-reply) message.
98100
**kwargs: Additional options to pass to `send`.
99101
100102
Returns:
101103
New message object.
102104
103105
"""
104-
return await self.send(content=content, reply_to=self.message, embeds=embeds or embed, **kwargs)
106+
ref = MessageReference.for_message(self.message, fail_if_not_exists=fail_if_not_exists)
107+
return await self.send(content=content, reply_to=ref, embeds=embeds or embed, **kwargs)

0 commit comments

Comments
 (0)