feat: Backport sending message flags (#7560)

This commit is contained in:
Jiralite
2022-03-02 09:32:36 +00:00
committed by GitHub
parent 1d97dcff08
commit 29d42ed319
5 changed files with 17 additions and 5 deletions

View File

@@ -148,11 +148,17 @@ class MessagePayload {
} }
let flags; 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 // eslint-disable-next-line eqeqeq
flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags?.bitfield; 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 = let allowedMentions =

View File

@@ -116,6 +116,7 @@ class Webhook {
* @property {string} [avatarURL] Avatar URL override for the message * @property {string} [avatarURL] Avatar URL override for the message
* @property {Snowflake} [threadId] The id of the thread in the channel to send to. * @property {Snowflake} [threadId] The id of the thread in the channel to send to.
* <info>For interaction webhooks, this property is ignored</info> * <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.
*/ */
/** /**

View File

@@ -28,6 +28,8 @@ class InteractionResponses {
* @typedef {BaseMessageOptions} InteractionReplyOptions * @typedef {BaseMessageOptions} InteractionReplyOptions
* @property {boolean} [ephemeral] Whether the reply should be ephemeral * @property {boolean} [ephemeral] Whether the reply should be ephemeral
* @property {boolean} [fetchReply] Whether to fetch the reply * @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.
*/ */
/** /**

View File

@@ -73,6 +73,7 @@ class TextBasedChannel {
* @typedef {BaseMessageOptions} MessageOptions * @typedef {BaseMessageOptions} MessageOptions
* @property {ReplyOptions} [reply] The options for replying to a message * @property {ReplyOptions} [reply] The options for replying to a message
* @property {StickerResolvable[]} [stickers=[]] Stickers to send in the 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.
*/ */
/** /**

6
typings/index.d.ts vendored
View File

@@ -3348,7 +3348,7 @@ export interface PartialWebhookFields {
/** @deprecated */ /** @deprecated */
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | APIMessage>; fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | APIMessage>;
/* tslint:enable:unified-signatures */ /* 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 { export interface WebhookFields extends PartialWebhookFields {
@@ -4911,9 +4911,10 @@ export interface InteractionDeferReplyOptions {
export type InteractionDeferUpdateOptions = Omit<InteractionDeferReplyOptions, 'ephemeral'>; 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; ephemeral?: boolean;
fetchReply?: boolean; fetchReply?: boolean;
flags?: BitFieldResolvable<'SUPPRESS_EMBEDS' | 'EPHEMERAL', number>;
} }
export type InteractionResponseType = keyof typeof InteractionResponseTypes; export type InteractionResponseType = keyof typeof InteractionResponseTypes;
@@ -5180,6 +5181,7 @@ export interface MessageOptions {
reply?: ReplyOptions; reply?: ReplyOptions;
stickers?: StickerResolvable[]; stickers?: StickerResolvable[];
attachments?: MessageAttachment[]; attachments?: MessageAttachment[];
flags?: BitFieldResolvable<'SUPPRESS_EMBEDS', number>;
} }
export type MessageReactionResolvable = export type MessageReactionResolvable =