Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
fix: fix MessageEmbed#addField deprecation warnings (#1065)
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikd-g authored Nov 12, 2022
1 parent 076308e commit 20a9eb4
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
6 changes: 3 additions & 3 deletions src/commands/developers/EvalCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand Down
53 changes: 34 additions & 19 deletions src/commands/general/HelpCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)" : ""
Expand Down
5 changes: 4 additions & 1 deletion src/commands/moderation/BanCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/commands/moderation/KickCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions src/commands/moderation/ModLogsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
7 changes: 6 additions & 1 deletion src/commands/moderation/MuteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/commands/moderation/UnMuteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
7 changes: 6 additions & 1 deletion src/commands/moderation/WarnCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
28 changes: 16 additions & 12 deletions src/commands/music/DJCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
30 changes: 18 additions & 12 deletions src/utils/structures/ModerationLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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({
Expand All @@ -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({
Expand Down

0 comments on commit 20a9eb4

Please sign in to comment.