Skip to content

Commit

Permalink
feat: add fail_if_not_exists for PrefixedContext.reply (#1608)
Browse files Browse the repository at this point in the history
* feat: add toggle for fail_if_not_exists for PrefixedContext.reply

* docs: parity with other fail_if_not_exists
  • Loading branch information
AstreaTSS authored Mar 14, 2024
1 parent b41c47e commit 5518474
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions interactions/ext/prefixed_commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from interactions.models.discord.channel import TYPE_MESSAGEABLE_CHANNEL
from interactions.models.discord.embed import Embed
from interactions.models.discord.file import UPLOADABLE_TYPE
from interactions.models.discord.message import Message
from interactions.models.discord.message import Message, MessageReference
from interactions.models.internal.context import BaseContext
from interactions.models.misc.context_manager import Typing

Expand Down Expand Up @@ -86,6 +86,7 @@ async def reply(
content: Optional[str] = None,
embeds: Optional[Union[Iterable[Union[Embed, dict]], Union[Embed, dict]]] = None,
embed: Optional[Union[Embed, dict]] = None,
fail_if_not_exists: bool = True,
**kwargs: Any,
) -> Message:
"""
Expand All @@ -95,10 +96,12 @@ async def reply(
content: Message text content.
embeds: Embedded rich content (up to 6000 characters).
embed: Embedded rich content (up to 6000 characters).
fail_if_not_exists: Whether to error if the command invocation doesn't exist instead of sending as a normal (non-reply) message.
**kwargs: Additional options to pass to `send`.
Returns:
New message object.
"""
return await self.send(content=content, reply_to=self.message, embeds=embeds or embed, **kwargs)
ref = MessageReference.for_message(self.message, fail_if_not_exists=fail_if_not_exists)
return await self.send(content=content, reply_to=ref, embeds=embeds or embed, **kwargs)

0 comments on commit 5518474

Please sign in to comment.