From b372e59c9f4ba9b4e200ce461ee4c003017dd2d7 Mon Sep 17 00:00:00 2001 From: Monbrey Date: Fri, 4 Jun 2021 21:04:14 +1000 Subject: [PATCH 1/6] fix: replace resolveString with verifyString --- src/extensions/message.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index 077af915..3d9fcc98 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -1,4 +1,4 @@ -const { Structures, escapeMarkdown, splitMessage, resolveString } = require('discord.js'); +const { Structures, escapeMarkdown, splitMessage, verifyString } = require('discord.js'); const { oneLine } = require('common-tags'); const Command = require('../commands/base'); const FriendlyError = require('../errors/friendly'); @@ -283,7 +283,7 @@ module.exports = Structures.extend('Message', Message => { } } - content = resolveString(content); + content = verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false) switch(type) { case 'plain': From 152071cffe1de7b90a0fe398ee1438616a77dcf7 Mon Sep 17 00:00:00 2001 From: Monbrey Date: Fri, 4 Jun 2021 21:09:56 +1000 Subject: [PATCH 2/6] fix: linting --- src/extensions/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index 3d9fcc98..b555a98d 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -283,7 +283,7 @@ module.exports = Structures.extend('Message', Message => { } } - content = verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false) + content = verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false); switch(type) { case 'plain': From e18983d6d126d0c7bb94f84b7f7162cc64d0aea8 Mon Sep 17 00:00:00 2001 From: Monbrey Date: Fri, 4 Jun 2021 22:20:26 +1000 Subject: [PATCH 3/6] fix: straight swap, no extra features --- src/extensions/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index b555a98d..67a5b0c8 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -283,7 +283,7 @@ module.exports = Structures.extend('Message', Message => { } } - content = verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false); + content = verifyString(this.options.content); switch(type) { case 'plain': From ceea6c517181d8793a134f6e6a7da202e7798fc7 Mon Sep 17 00:00:00 2001 From: Monbrey Date: Sat, 5 Jun 2021 08:22:40 +1000 Subject: [PATCH 4/6] fix: dont copy paste things late at night --- src/extensions/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index 67a5b0c8..ba224b3f 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -283,7 +283,7 @@ module.exports = Structures.extend('Message', Message => { } } - content = verifyString(this.options.content); + content = verifyString(content); switch(type) { case 'plain': From 127cfb966d6acfb3680d48a9d37ce5c10d36b5a6 Mon Sep 17 00:00:00 2001 From: Monbrey Date: Thu, 10 Jun 2021 08:30:11 +1000 Subject: [PATCH 5/6] types: replace references to StringResolvable with string --- src/extensions/message.js | 12 ++++++------ src/index.js | 4 ---- typings/index.d.ts | 14 +++++++------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index ba224b3f..e5020b0a 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -363,7 +363,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with a plain message - * @param {StringResolvable} content - Content for the message + * @param {string} content - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ @@ -377,7 +377,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with a reply message - * @param {StringResolvable} content - Content for the message + * @param {string} content - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ @@ -391,7 +391,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with a direct message - * @param {StringResolvable} content - Content for the message + * @param {string} content - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ @@ -406,7 +406,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with a code message * @param {string} lang - Language for the code block - * @param {StringResolvable} content - Content for the message + * @param {string} content - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ @@ -423,7 +423,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with an embed * @param {RichEmbed|Object} embed - Embed to send - * @param {StringResolvable} [content] - Content for the message + * @param {string} [content] - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ @@ -436,7 +436,7 @@ module.exports = Structures.extend('Message', Message => { /** * Responds with a mention + embed * @param {RichEmbed|Object} embed - Embed to send - * @param {StringResolvable} [content] - Content for the message + * @param {string} [content] - Content for the message * @param {MessageOptions} [options] - Options for the message * @return {Promise} */ diff --git a/src/index.js b/src/index.js index 3f5c05a8..647185bb 100644 --- a/src/index.js +++ b/src/index.js @@ -85,10 +85,6 @@ module.exports = { * @external Role * @see {@link https://discord.js.org/#/docs/main/master/class/Role} */ -/** - * @external StringResolvable - * @see {@link https://discord.js.org/#/docs/main/master/typedef/StringResolvable} - */ /** * @external TextChannel * @see {@link https://discord.js.org/#/docs/main/master/class/TextChannel} diff --git a/typings/index.d.ts b/typings/index.d.ts index cf8092b3..255edcaa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,5 +1,5 @@ declare module 'discord.js-commando' { - import { Client, ClientEvents, ClientOptions, Collection, Guild, GuildResolvable, Message, MessageAttachment, MessageEditOptions, MessageEmbed, MessageOptions, MessageAdditions, MessageReaction, PermissionResolvable, PermissionString, StringResolvable, User, UserResolvable } from 'discord.js'; + import { Client, ClientEvents, ClientOptions, Collection, Guild, GuildResolvable, Message, MessageAttachment, MessageEditOptions, MessageEmbed, MessageOptions, MessageAdditions, MessageReaction, PermissionResolvable, PermissionString, User, UserResolvable } from 'discord.js'; export class Argument { private constructor(client: CommandoClient, info: ArgumentInfo); @@ -172,18 +172,18 @@ declare module 'discord.js-commando' { public anyUsage(argString?: string, prefix?: string, user?: User): string; public code: CommandoMessage['say']; public direct: CommandoMessage['say']; - public embed(embed: MessageEmbed, content?: StringResolvable, options?: (MessageOptions & { split?: false }) | MessageAdditions): Promise; - public embed(embed: MessageEmbed, content?: StringResolvable, options?: (MessageOptions & { split: true | Exclude }) | MessageAdditions): Promise; + public embed(embed: MessageEmbed, content?: string, options?: (MessageOptions & { split?: false }) | MessageAdditions): Promise; + public embed(embed: MessageEmbed, content?: string, options?: (MessageOptions & { split: true | Exclude }) | MessageAdditions): Promise; public initCommand(command?: Command, argString?: string[], patternMatches?: string[]): this; public parseArgs(): string | string[]; public replyEmbed: CommandoMessage['embed']; public run(): Promise; public say( - content: StringResolvable | (MessageOptions & { split?: false }) | MessageAdditions, + content: string | (MessageOptions & { split?: false }) | MessageAdditions, options?: (MessageOptions & { split?: false }) | MessageAdditions ): Promise; public say( - content: StringResolvable | (MessageOptions & { split: true | Exclude }) | MessageAdditions, + content: string | (MessageOptions & { split: true | Exclude }) | MessageAdditions, options?: (MessageOptions & { split: true | Exclude }) | MessageAdditions ): Promise; public usage(argString?: string, prefix?: string, user?: User): string; @@ -486,7 +486,7 @@ declare module 'discord.js-commando' { type ResponseType = 'reply' | 'plain' | 'direct' | 'code'; interface RespondOptions { - content: StringResolvable | MessageOptions; + content: string | MessageOptions; fromEdit?: boolean; options?: MessageOptions; lang?: string; @@ -494,7 +494,7 @@ declare module 'discord.js-commando' { } interface RespondEditOptions { - content: StringResolvable | MessageEditOptions | Exclude; + content: string | MessageEditOptions | Exclude; options?: MessageEditOptions | Exclude; type?: ResponseType; } From 937be2e125a117ec782404d2758b53a1faa9f92a Mon Sep 17 00:00:00 2001 From: Monbrey Date: Thu, 1 Jul 2021 07:32:08 +1000 Subject: [PATCH 6/6] fix: destructure from util --- src/extensions/message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/message.js b/src/extensions/message.js index e5020b0a..bdf5ac44 100644 --- a/src/extensions/message.js +++ b/src/extensions/message.js @@ -1,4 +1,4 @@ -const { Structures, escapeMarkdown, splitMessage, verifyString } = require('discord.js'); +const { Structures, Util: { escapeMarkdown, splitMessage, verifyString } } = require('discord.js'); const { oneLine } = require('common-tags'); const Command = require('../commands/base'); const FriendlyError = require('../errors/friendly');