Skip to content

Commit

Permalink
feat(context): Allow flags in follow up messages
Browse files Browse the repository at this point in the history
closes #83
  • Loading branch information
Snazzah committed Jul 22, 2021
1 parent 8b1bb02 commit 10ba62d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/structures/interfaces/messageInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ export interface MessageFile {
name: string;
}

/** The options for {@link MessageInteractionContext#sendFollowUp}. */
/**
* The options for {@link MessageInteractionContext#sendFollowUp}.
* @deprecated Use {@link MessageOptions} instead.
*/
export interface FollowUpMessageOptions extends EditMessageOptions {
/** Whether to use TTS for the content. */
tts?: boolean;
/** The flags to use in the message. */
flags?: number;
}

/** The options for {@link MessageInteractionContext#send}. */
export interface MessageOptions extends FollowUpMessageOptions {
/** The options for {@link MessageInteractionContext#send} and {@link MessageInteractionContext#sendFollowUp}. */
export interface MessageOptions extends EditMessageOptions {
/** Whether to use TTS for the content. */
tts?: boolean;
/** The flags to use in the message. */
flags?: number;
/**
* Whether or not the message should be ephemeral.
* Ignored if `flags` is defined.
Expand Down Expand Up @@ -169,7 +176,7 @@ class MessageInteractionContext {
* @param content The content of the message
* @param options The message options
*/
async sendFollowUp(content: string | FollowUpMessageOptions, options?: FollowUpMessageOptions): Promise<Message> {
async sendFollowUp(content: string | MessageOptions, options?: MessageOptions): Promise<Message> {
if (this.expired) throw new Error('This interaction has expired');

if (typeof content !== 'string') options = content;
Expand All @@ -181,6 +188,8 @@ class MessageInteractionContext {

if (!options.content && !options.embeds) throw new Error('Message content and embeds are both not given.');

if (options.ephemeral && !options.flags) options.flags = InteractionResponseFlags.EPHEMERAL;

const allowedMentions = options.allowedMentions
? formatAllowedMentions(options.allowedMentions, this.creator.allowedMentions as FormattedAllowedMentions)
: this.creator.allowedMentions;
Expand All @@ -194,7 +203,8 @@ class MessageInteractionContext {
content: options.content,
embeds: options.embeds,
allowed_mentions: allowedMentions,
components: options.components
components: options.components,
flags: options.flags
},
options.file
);
Expand Down

0 comments on commit 10ba62d

Please sign in to comment.