Skip to content

Commit

Permalink
feat: Backport sending message flags (#7560)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Mar 2, 2022
1 parent 1d97dcf commit 29d42ed
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/structures/MessagePayload.js
Expand Up @@ -148,11 +148,17 @@ class MessagePayload {
}

let flags;
if ((this.isMessage && typeof this.options.reply === 'undefined') || this.isMessageManager) {
if (
typeof this.options.flags !== 'undefined' ||
(this.isMessage && typeof this.options.reply === 'undefined') ||
this.isMessageManager
) {
// eslint-disable-next-line eqeqeq
flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags?.bitfield;
} else if (isInteraction && this.options.ephemeral) {
flags = MessageFlags.FLAGS.EPHEMERAL;
}

if (isInteraction && this.options.ephemeral) {
flags |= MessageFlags.FLAGS.EPHEMERAL;
}

let allowedMentions =
Expand Down
1 change: 1 addition & 0 deletions src/structures/Webhook.js
Expand Up @@ -116,6 +116,7 @@ class Webhook {
* @property {string} [avatarURL] Avatar URL override for the message
* @property {Snowflake} [threadId] The id of the thread in the channel to send to.
* <info>For interaction webhooks, this property is ignored</info>
* @property {MessageFlags} [flags] Which flags to set for the message. Only `SUPPRESS_EMBEDS` can be set.
*/

/**
Expand Down
2 changes: 2 additions & 0 deletions src/structures/interfaces/InteractionResponses.js
Expand Up @@ -28,6 +28,8 @@ class InteractionResponses {
* @typedef {BaseMessageOptions} InteractionReplyOptions
* @property {boolean} [ephemeral] Whether the reply should be ephemeral
* @property {boolean} [fetchReply] Whether to fetch the reply
* @property {MessageFlags} [flags] Which flags to set for the message.
* Only `SUPPRESS_EMBEDS` and `EPHEMERAL` can be set.
*/

/**
Expand Down
1 change: 1 addition & 0 deletions src/structures/interfaces/TextBasedChannel.js
Expand Up @@ -73,6 +73,7 @@ class TextBasedChannel {
* @typedef {BaseMessageOptions} MessageOptions
* @property {ReplyOptions} [reply] The options for replying to a message
* @property {StickerResolvable[]} [stickers=[]] Stickers to send in the message
* @property {MessageFlags} [flags] Which flags to set for the message. Only `SUPPRESS_EMBEDS` can be set.
*/

/**
Expand Down
6 changes: 4 additions & 2 deletions typings/index.d.ts
Expand Up @@ -3348,7 +3348,7 @@ export interface PartialWebhookFields {
/** @deprecated */
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | APIMessage>;
/* tslint:enable:unified-signatures */
send(options: string | MessagePayload | WebhookMessageOptions): Promise<Message | APIMessage>;
send(options: string | MessagePayload | Omit<WebhookMessageOptions, 'flags'>): Promise<Message | APIMessage>;
}

export interface WebhookFields extends PartialWebhookFields {
Expand Down Expand Up @@ -4911,9 +4911,10 @@ export interface InteractionDeferReplyOptions {

export type InteractionDeferUpdateOptions = Omit<InteractionDeferReplyOptions, 'ephemeral'>;

export interface InteractionReplyOptions extends Omit<WebhookMessageOptions, 'username' | 'avatarURL'> {
export interface InteractionReplyOptions extends Omit<WebhookMessageOptions, 'username' | 'avatarURL' | 'flags'> {
ephemeral?: boolean;
fetchReply?: boolean;
flags?: BitFieldResolvable<'SUPPRESS_EMBEDS' | 'EPHEMERAL', number>;
}

export type InteractionResponseType = keyof typeof InteractionResponseTypes;
Expand Down Expand Up @@ -5180,6 +5181,7 @@ export interface MessageOptions {
reply?: ReplyOptions;
stickers?: StickerResolvable[];
attachments?: MessageAttachment[];
flags?: BitFieldResolvable<'SUPPRESS_EMBEDS', number>;
}

export type MessageReactionResolvable =
Expand Down

0 comments on commit 29d42ed

Please sign in to comment.