Skip to content
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

feat: Backport sending message flags #7560

Merged
merged 1 commit into from Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -3338,7 +3338,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 @@ -4900,9 +4900,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 @@ -5169,6 +5170,7 @@ export interface MessageOptions {
reply?: ReplyOptions;
stickers?: StickerResolvable[];
attachments?: MessageAttachment[];
flags?: BitFieldResolvable<'SUPPRESS_EMBEDS', number>;
}

export type MessageReactionResolvable =
Expand Down