Skip to content

feat: add fail_if_not_exists for PrefixedContext.reply #1608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy