From 20a9eb42fdf4365d2281e7b1dd5b50a01eadf0f0 Mon Sep 17 00:00:00 2001 From: GodOfWarOP Date: Sat, 12 Nov 2022 18:57:27 +0530 Subject: [PATCH] fix: fix `MessageEmbed#addField` deprecation warnings (#1065) --- .env_example | 2 +- src/commands/developers/EvalCommand.ts | 6 +-- src/commands/general/HelpCommand.ts | 53 +++++++++++++++-------- src/commands/moderation/BanCommand.ts | 5 ++- src/commands/moderation/KickCommand.ts | 2 +- src/commands/moderation/ModLogsCommand.ts | 30 +++++++------ src/commands/moderation/MuteCommand.ts | 7 ++- src/commands/moderation/UnMuteCommand.ts | 7 ++- src/commands/moderation/WarnCommand.ts | 7 ++- src/commands/music/DJCommand.ts | 28 +++++++----- src/utils/structures/ModerationLogs.ts | 30 ++++++++----- 11 files changed, 111 insertions(+), 66 deletions(-) diff --git a/.env_example b/.env_example index d9f1d088f..b9972f273 100644 --- a/.env_example +++ b/.env_example @@ -99,4 +99,4 @@ YES_EMOJI="" # OPTIONAL - What should be your bot's emoji for every failed sentence? # Example: NO_EMOJI="❌" # Default: ❌ -NO_EMOJI="" +NO_EMOJI="" \ No newline at end of file diff --git a/src/commands/developers/EvalCommand.ts b/src/commands/developers/EvalCommand.ts index 863273406..84443b917 100644 --- a/src/commands/developers/EvalCommand.ts +++ b/src/commands/developers/EvalCommand.ts @@ -23,7 +23,7 @@ export class EvalCommand extends BaseCommand { const code = ctx.args .join(" ") .replace(/^\s*\n?(```(?:[^\s]+\n)?(.*?)```|.*)$/s, (_, a: string, b) => (a.startsWith("```") ? b : a)); - const embed = createEmbed("info").addField("Input", `\`\`\`js\n${code}\`\`\``); + const embed = createEmbed("info").addFields([{ name: "Input", value: `\`\`\`js\n${code}\`\`\`` }]); try { if (!code) { @@ -45,7 +45,7 @@ export class EvalCommand extends BaseCommand { const cleaned = this.clean(evaled); const output = cleaned.length > 1024 ? `${await this.hastebin(cleaned)}.js` : `\`\`\`js\n${cleaned}\`\`\``; - embed.addField(i18n.__("commands.developers.eval.outputString"), output); + embed.addFields([{ name: i18n.__("commands.developers.eval.outputString"), value: output }]); ctx.send({ askDeletion: { reference: ctx.author.id @@ -57,7 +57,7 @@ export class EvalCommand extends BaseCommand { const isTooLong = cleaned.length > 1024; const error = isTooLong ? `${await this.hastebin(cleaned)}.js` : `\`\`\`js\n${cleaned}\`\`\``; - embed.setColor("RED").addField(i18n.__("commands.developers.eval.errorString"), error); + embed.setColor("RED").addFields([{ name: i18n.__("commands.developers.eval.errorString"), value: error }]); ctx.send({ askDeletion: { reference: ctx.author.id diff --git a/src/commands/general/HelpCommand.ts b/src/commands/general/HelpCommand.ts index 6d4bb513f..a4ce7e8c5 100644 --- a/src/commands/general/HelpCommand.ts +++ b/src/commands/general/HelpCommand.ts @@ -66,7 +66,12 @@ export class HelpCommand extends BaseCommand { const cmds = category.cmds.filter(c => (isDev ? true : !c.meta.devOnly)).map(c => `\`${c.meta.name}\``); if (cmds.length === 0) continue; if (category.hide && !isDev) continue; - embed.addField(`**${category.name}**`, cmds.join(", ")); + embed.addFields([ + { + name: `**${category.name}**`, + value: cmds.join(", ") + } + ]); } ctx.send({ embeds: [embed] }, "editReply").catch(e => this.client.logger.error("PROMISE_ERR:", e)); @@ -124,24 +129,34 @@ export class HelpCommand extends BaseCommand { }), iconURL: this.client.user?.displayAvatarURL()! }) - .addField(i18n.__("commands.general.help.nameString"), `**\`${command.meta.name}\`**`, false) - .addField( - i18n.__("commands.general.help.descriptionString"), - `${command.meta.description!}`, - true - ) - .addField( - i18n.__("commands.general.help.aliasesString"), - Number(command.meta.aliases?.length) > 0 - ? command.meta.aliases?.map(c => `**\`${c}\`**`).join(", ")! - : "None.", - false - ) - .addField( - i18n.__("commands.general.help.usageString"), - `**\`${command.meta.usage!.replace(/{prefix}/g, this.client.config.mainPrefix)}\`**`, - true - ) + .addFields([ + { + name: i18n.__("commands.general.help.nameString"), + value: `**\`${command.meta.name}\`**`, + inline: false + }, + { + name: i18n.__("commands.general.help.descriptionString"), + value: `${command.meta.description!}`, + inline: true + }, + { + name: i18n.__("commands.general.help.aliasesString"), + value: + Number(command.meta.aliases?.length) > 0 + ? command.meta.aliases?.map(c => `**\`${c}\`**`).join(", ")! + : "None.", + inline: false + }, + { + name: i18n.__("commands.general.help.usageString"), + value: `**\`${command.meta.usage!.replace( + /{prefix}/g, + this.client.config.mainPrefix + )}\`**`, + inline: true + } + ]) .setFooter({ text: i18n.__mf("commands.general.help.commandUsageFooter", { devOnly: command.meta.devOnly ? "(developer-only command)" : "" diff --git a/src/commands/moderation/BanCommand.ts b/src/commands/moderation/BanCommand.ts index c3e8d8a0f..37202617f 100644 --- a/src/commands/moderation/BanCommand.ts +++ b/src/commands/moderation/BanCommand.ts @@ -68,7 +68,10 @@ export class BanCommand extends BaseCommand { }) ) .setThumbnail(ctx.guild.iconURL({ dynamic: true, format: "png", size: 1024 })!) - .addField(i18n.__("commands.moderation.common.reasonString"), reason) + .addFields({ + name: i18n.__("commands.moderation.common.reasonString"), + value: reason + }) .setFooter({ text: i18n.__mf("commands.moderation.ban.bannedByString", { author: ctx.author.tag diff --git a/src/commands/moderation/KickCommand.ts b/src/commands/moderation/KickCommand.ts index c51765385..e3e4e56e2 100644 --- a/src/commands/moderation/KickCommand.ts +++ b/src/commands/moderation/KickCommand.ts @@ -63,7 +63,7 @@ export class KickCommand extends BaseCommand { i18n.__mf("commands.moderation.kick.userKicked", { guildName: ctx.guild.name }) ) .setThumbnail(ctx.guild.iconURL({ dynamic: true, format: "png", size: 1024 })!) - .addField(i18n.__("commands.moderation.common.reasonString"), reason) + .addFields([{ name: i18n.__("commands.moderation.common.reasonString"), value: reason }]) .setFooter({ text: i18n.__mf("commands.moderation.kick.kickedByString", { author: ctx.author.tag diff --git a/src/commands/moderation/ModLogsCommand.ts b/src/commands/moderation/ModLogsCommand.ts index df36c95fb..e76db57ef 100644 --- a/src/commands/moderation/ModLogsCommand.ts +++ b/src/commands/moderation/ModLogsCommand.ts @@ -106,20 +106,22 @@ export class ModLogsCommand extends BaseCommand { .setAuthor({ name: i18n.__("commands.moderation.modlogs.embedTitle") }) - .addField( - `${this.client.config.mainPrefix}modlogs enable`, - i18n.__("commands.moderation.modlogs.slashEnableDescription") - ) - .addField( - `${this.client.config.mainPrefix}modlogs disable`, - i18n.__("commands.moderation.modlogs.slashDisableDescription") - ) - .addField( - `${this.client.config.mainPrefix}modlogs channel [${i18n.__( - "commands.moderation.modlogs.newChannelText" - )}]`, - i18n.__("commands.moderation.modlogs.slashChannelDescription") - ) + .addFields([ + { + name: `${this.client.config.mainPrefix}modlogs enable`, + value: i18n.__("commands.moderation.modlogs.slashEnableDescription") + }, + { + name: `${this.client.config.mainPrefix}modlogs disable`, + value: i18n.__("commands.moderation.modlogs.slashDisableDescription") + }, + { + name: `${this.client.config.mainPrefix}modlogs channel [${i18n.__( + "commands.moderation.modlogs.newChannelText" + )}]`, + value: i18n.__("commands.moderation.modlogs.slashChannelDescription") + } + ]) ] }), disable: async ctx => { diff --git a/src/commands/moderation/MuteCommand.ts b/src/commands/moderation/MuteCommand.ts index f25dff52d..38c4012a2 100644 --- a/src/commands/moderation/MuteCommand.ts +++ b/src/commands/moderation/MuteCommand.ts @@ -98,7 +98,12 @@ export class MuteCommand extends BaseCommand { ) .setColor("LIGHT_GREY") .setThumbnail(ctx.guild.iconURL({ dynamic: true, format: "png", size: 1024 })!) - .addField(i18n.__("commands.moderation.common.reasonString"), reason) + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: reason + } + ]) .setFooter({ text: i18n.__mf("commands.moderation.mute.mutedByString", { author: ctx.author.tag diff --git a/src/commands/moderation/UnMuteCommand.ts b/src/commands/moderation/UnMuteCommand.ts index 9ecc41114..564a51d01 100644 --- a/src/commands/moderation/UnMuteCommand.ts +++ b/src/commands/moderation/UnMuteCommand.ts @@ -94,7 +94,12 @@ export class UnMuteCommand extends BaseCommand { }) ) .setThumbnail(ctx.guild.iconURL({ dynamic: true, format: "png", size: 1024 })!) - .addField(i18n.__("commands.moderation.common.reasonString"), reason) + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: reason + } + ]) .setFooter({ text: i18n.__mf("commands.moderation.unmute.unmutedByString", { author: ctx.author.tag }), iconURL: ctx.author.displayAvatarURL({ dynamic: true }) diff --git a/src/commands/moderation/WarnCommand.ts b/src/commands/moderation/WarnCommand.ts index c1839a5b8..48bfb28f5 100644 --- a/src/commands/moderation/WarnCommand.ts +++ b/src/commands/moderation/WarnCommand.ts @@ -57,7 +57,12 @@ export class WarnCommand extends BaseCommand { }) ) .setThumbnail(ctx.guild!.iconURL({ dynamic: true, format: "png", size: 1024 })!) - .addField(i18n.__("commands.moderation.common.reasonString"), displayReason) + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: displayReason + } + ]) .setFooter({ text: i18n.__mf("commands.moderation.warn.warnedByString", { author: ctx.author.tag }), iconURL: ctx.author.displayAvatarURL({ dynamic: true }) diff --git a/src/commands/music/DJCommand.ts b/src/commands/music/DJCommand.ts index 37f92c6d5..2ef24e106 100644 --- a/src/commands/music/DJCommand.ts +++ b/src/commands/music/DJCommand.ts @@ -46,18 +46,22 @@ export class DJCommand extends BaseCommand { .setAuthor({ name: i18n.__("commands.music.dj.embedTitle") }) - .addField( - `${this.client.config.mainPrefix}dj enable`, - i18n.__("commands.music.dj.slashEnableDescription") - ) - .addField( - `${this.client.config.mainPrefix}dj disable`, - i18n.__("commands.music.dj.slashDisableDescription") - ) - .addField( - `${this.client.config.mainPrefix}dj role [${i18n.__("commands.music.dj.newRoleText")}]`, - i18n.__("commands.music.dj.slashRoleDescription") - ) + .addFields([ + { + name: `${this.client.config.mainPrefix}dj enable`, + value: i18n.__("commands.music.dj.slashEnableDescription") + }, + { + name: `${this.client.config.mainPrefix}dj disable`, + value: i18n.__("commands.music.dj.slashDisableDescription") + }, + { + name: `${this.client.config.mainPrefix}dj role [${i18n.__( + "commands.music.dj.newRoleText" + )}]`, + value: i18n.__("commands.music.dj.slashRoleDescription") + } + ]) ] }), disable: async ctx => { diff --git a/src/utils/structures/ModerationLogs.ts b/src/utils/structures/ModerationLogs.ts index 014348684..18730e0c4 100644 --- a/src/utils/structures/ModerationLogs.ts +++ b/src/utils/structures/ModerationLogs.ts @@ -12,10 +12,12 @@ export class ModerationLogs { const embed = createEmbed("warn", i18n.__mf("commands.moderation.warn.warnSuccess", { user: options.user.tag })) .setThumbnail(options.user.displayAvatarURL({ dynamic: true, size: 1024 })) - .addField( - i18n.__("commands.moderation.common.reasonString"), - options.reason ?? i18n.__("commands.moderation.common.noReasonString") - ) + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: options.reason ?? i18n.__("commands.moderation.common.noReasonString") + } + ]) .setFooter({ text: i18n.__mf("commands.moderation.warn.warnedByString", { author: options.author.tag }), iconURL: options.author.displayAvatarURL({ dynamic: true }) @@ -33,10 +35,12 @@ export class ModerationLogs { const embed = createEmbed("error", i18n.__mf("commands.moderation.ban.banSuccess", { user: fetched.user.tag })) .setThumbnail(fetched.user.displayAvatarURL({ dynamic: true, size: 1024 })) - .addField( - i18n.__("commands.moderation.common.reasonString"), - fetched.reason ?? i18n.__("commands.moderation.common.noReasonString") - ); + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: fetched.reason ?? i18n.__("commands.moderation.common.noReasonString") + } + ]); if (options.author) { embed.setFooter({ @@ -62,10 +66,12 @@ export class ModerationLogs { i18n.__mf("commands.moderation.unban.unbanSuccess", { user: fetched.user.tag }) ) .setThumbnail(fetched.user.displayAvatarURL({ dynamic: true, size: 1024 })) - .addField( - i18n.__("commands.moderation.common.reasonString"), - fetched.reason ?? i18n.__("commands.moderation.common.noReasonString") - ); + .addFields([ + { + name: i18n.__("commands.moderation.common.reasonString"), + value: fetched.reason ?? i18n.__("commands.moderation.common.noReasonString") + } + ]); if (options.author) { embed.setFooter({