From 393337fbbdd017c7d26821a44f867e44060b5672 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Thu, 21 Jul 2022 14:57:28 +0300 Subject: [PATCH] bugfixes --- src/localization/en_gb/commands/en_gb_utility.lang | 2 +- src/structure/client/wrappers/GuildWrapper.js | 2 +- src/structure/client/wrappers/InteractionWrapper.js | 11 ++++++----- src/structure/client/wrappers/InvokerWrapper.js | 2 +- src/structure/interfaces/commands/SettingsCommand.js | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/localization/en_gb/commands/en_gb_utility.lang b/src/localization/en_gb/commands/en_gb_utility.lang index 69d46fa..d4fb42f 100644 --- a/src/localization/en_gb/commands/en_gb_utility.lang +++ b/src/localization/en_gb/commands/en_gb_utility.lang @@ -87,7 +87,7 @@ else 'one option'; {emoji_loading} Starting poll... [COMMAND_POLL_DURATION] -Poll runs for {time}, ends in +Poll runs for {time}, ends [COMMAND_POLL_INFINITE] Poll has no end time. diff --git a/src/structure/client/wrappers/GuildWrapper.js b/src/structure/client/wrappers/GuildWrapper.js index d05d09d..1f55a0a 100644 --- a/src/structure/client/wrappers/GuildWrapper.js +++ b/src/structure/client/wrappers/GuildWrapper.js @@ -84,7 +84,7 @@ class GuildWrapper { result[emoji] = reaction.count - 1; } - const [embed] = msg.embeds; + const embed = msg.embeds[0].toJSON(); const results = Object.entries(result).map(([emoji, count]) => `${emoji} - ${count}`).join('\n'); embed.description = this.format('COMMAND_POLL_END', { results }); await msg.edit({ embeds: [embed] }); diff --git a/src/structure/client/wrappers/InteractionWrapper.js b/src/structure/client/wrappers/InteractionWrapper.js index debd3d8..5b0d859 100644 --- a/src/structure/client/wrappers/InteractionWrapper.js +++ b/src/structure/client/wrappers/InteractionWrapper.js @@ -1,4 +1,4 @@ -const { Guild, InteractionType } = require('discord.js'); +const { Guild, InteractionType, ApplicationCommandOptionType } = require('discord.js'); const GuildWrapper = require('./GuildWrapper.js'); class InteractionWrapper { @@ -168,15 +168,15 @@ class InteractionWrapper { get subcommand() { const [data] = this.options.data; if (!data) return null; - else if (data.type === 'SUB_COMMAND') return data; - else if (data.type === 'SUB_COMMAND_GROUP') return data.options[0]; + else if (data.type === ApplicationCommandOptionType.Subcommand) return data; + else if (data.type === ApplicationCommandOptionType.SubcommandGroup) return data.options[0]; return null; } get subcommandGroup() { const [data] = this.options.data; if (!data) return null; - else if (data.type === 'SUB_COMMAND_GROUP') return data; + else if (data.type === ApplicationCommandOptionType.SubcommandGroup) return data; return null; } @@ -187,7 +187,8 @@ class InteractionWrapper { */ _options(options) { if (!options?.length) return []; - if (['SUB_COMMAND_GROUP', 'SUB_COMMAND'].includes(options[0].type)) return this._options(options[0].options); + if ([ApplicationCommandOptionType.SubcommandGroup, ApplicationCommandOptionType.Subcommand].includes(options[0].type)) + return this._options(options[0].options); return options; } diff --git a/src/structure/client/wrappers/InvokerWrapper.js b/src/structure/client/wrappers/InvokerWrapper.js index 825bf77..3f3cc5a 100644 --- a/src/structure/client/wrappers/InvokerWrapper.js +++ b/src/structure/client/wrappers/InvokerWrapper.js @@ -147,7 +147,7 @@ class InvokerWrapper { if(options.embed) options.embeds = [options.embed]; if (options.embeds) options.embeds.forEach((embed) => { - if (!embed.color) embed.color = 619452; + if (!embed.data.color) embed.setColor(619452); }); if (options.dm) { diff --git a/src/structure/interfaces/commands/SettingsCommand.js b/src/structure/interfaces/commands/SettingsCommand.js index 7fdb207..a9aa091 100644 --- a/src/structure/interfaces/commands/SettingsCommand.js +++ b/src/structure/interfaces/commands/SettingsCommand.js @@ -175,7 +175,7 @@ class SettingsCommand extends SlashCommand { if(field.name.length > 1) field.name = guild.format(field.name); }); - embed.fields.push(...dataFields); + embed.addFields(dataFields); await invoker.reply({ embeds: [embed] }); // .catch((error) => { // this.client.logger.error(`${error.stack || error}\nError context: ${JSON.stringify(embed)}`);