From b3854dfef3db16595310c6a8f137eedd1baab5a2 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Fri, 5 Feb 2021 17:15:48 +0530 Subject: [PATCH 1/2] feat(Message): add ReplyMessageOptions for #reply --- src/structures/Message.js | 18 ++++++++++++++++-- src/structures/interfaces/TextBasedChannel.js | 2 +- typings/index.d.ts | 14 ++++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index aec8e7ccdd61..1d63073f562e 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -606,11 +606,25 @@ class Message extends Base { return this; } + /** + * Options provided when sending a message as an inline reply. + * @typedef {Object} ReplyMessageOptions + * @property {boolean} [tts=false] Whether or not the message should be spoken aloud + * @property {string} [nonce=''] The nonce for the message + * @property {string} [content=''] The content for the message + * @property {MessageEmbed|Object} [embed] An embed for the message + * (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details) + * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content + * @property {FileOptions[]|BufferResolvable[]} [files] Files to send with the message + * @property {string|boolean} [code] Language for optional codeblock formatting to apply + * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if + * it exceeds the character limit. If an object is provided, these are the options for splitting the message + */ + /** * Send an inline reply to this message. * @param {StringResolvable|APIMessage} [content=''] The content for the message - * @param {MessageOptions|MessageAdditions} [options] The additional options to provide - * @param {MessageResolvable} [options.reply.messageReference=this] The message to reply to + * @param {ReplyMessageOptions|MessageAdditions} [options] The additional options to provide * @returns {Promise} */ reply(content, options) { diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index b53873c29e5c..37326f60c589 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -72,7 +72,7 @@ class TextBasedChannel { * @property {MessageMentionTypes[]} [parse] Types of mentions to be parsed * @property {Snowflake[]} [users] Snowflakes of Users to be parsed as mentions * @property {Snowflake[]} [roles] Snowflakes of Roles to be parsed as mentions - * @property {boolean} [repliedUser] Whether the author of the Message being replied to should be pinged + * @property {boolean} [repliedUser=true] Whether the author of the Message being replied to should be pinged */ /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 88be93f89d3a..a938f4b16361 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1148,19 +1148,19 @@ declare module 'discord.js' { public react(emoji: EmojiIdentifierResolvable): Promise; public removeAttachments(): Promise; public reply( - content: APIMessageContentResolvable | (MessageOptions & { split?: false }) | MessageAdditions, + content: APIMessageContentResolvable | (ReplyMessageOptions & { split?: false }) | MessageAdditions, ): Promise; - public reply(options: MessageOptions & { split: true | SplitOptions }): Promise; - public reply(options: MessageOptions | APIMessage): Promise; + public reply(options: ReplyMessageOptions & { split: true | SplitOptions }): Promise; + public reply(options: ReplyMessageOptions | APIMessage): Promise; public reply( content: StringResolvable, - options: (MessageOptions & { split?: false }) | MessageAdditions, + options: (ReplyMessageOptions & { split?: false }) | MessageAdditions, ): Promise; public reply( content: StringResolvable, - options: MessageOptions & { split: true | SplitOptions }, + options: ReplyMessageOptions & { split: true | SplitOptions }, ): Promise; - public reply(content: StringResolvable, options: MessageOptions): Promise; + public reply(content: StringResolvable, options: ReplyMessageOptions): Promise; public suppressEmbeds(suppress?: boolean): Promise; public toJSON(): object; public toString(): string; @@ -3481,6 +3481,8 @@ declare module 'discord.js' { failIfNotExists?: boolean; } + interface ReplyMessageOptions extends Omit {} + interface ResolvedOverwriteOptions { allow: Permissions; deny: Permissions; From f96663ff9010e6a630cf6ffe3707138284a0d56e Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Fri, 12 Feb 2021 12:51:23 +0530 Subject: [PATCH 2/2] feat: keeping up with changes in #5298 --- src/structures/Message.js | 4 +++- typings/index.d.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 1d63073f562e..72f287411f84 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -619,6 +619,8 @@ class Message extends Base { * @property {string|boolean} [code] Language for optional codeblock formatting to apply * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if * it exceeds the character limit. If an object is provided, these are the options for splitting the message + * @property {boolean} [failIfNotExists=true] Whether to error if the referenced message + * does not exist (creates a standard message in this case when false) */ /** @@ -634,7 +636,7 @@ class Message extends Base { : APIMessage.transformOptions(content, options, { reply: { messageReference: this, - failIfNotExists: options?.reply?.failIfNotExists ?? content?.reply?.failIfNotExists ?? true, + failIfNotExists: options?.failIfNotExists ?? content?.failIfNotExists ?? true, }, }), ); diff --git a/typings/index.d.ts b/typings/index.d.ts index a938f4b16361..ad610a8f14e4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3481,7 +3481,9 @@ declare module 'discord.js' { failIfNotExists?: boolean; } - interface ReplyMessageOptions extends Omit {} + interface ReplyMessageOptions extends Omit { + failIfNotExists?: boolean; + } interface ResolvedOverwriteOptions { allow: Permissions;