From 53c5430783026ef41a39734f2e0aaa9dbdfc3c5b Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 30 Apr 2022 23:11:46 +0300 Subject: [PATCH] further guildOnly restrictions --- .../components/commands/administration/Commands.js | 3 ++- .../components/commands/administration/Settings.js | 13 ++++++------- .../components/commands/information/Guild.js | 1 + .../components/commands/information/Info.js | 5 ++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/structure/components/commands/administration/Commands.js b/src/structure/components/commands/administration/Commands.js index 1f38646..987b7f5 100644 --- a/src/structure/components/commands/administration/Commands.js +++ b/src/structure/components/commands/administration/Commands.js @@ -24,7 +24,8 @@ class Commands extends SlashCommand { description: ['List disabled commands'], options: [] }], - memberPermissions: ['MANAGE_GUILD'] + memberPermissions: ['MANAGE_GUILD'], + guildOnly: true }); } diff --git a/src/structure/components/commands/administration/Settings.js b/src/structure/components/commands/administration/Settings.js index 35fa841..2f4efad 100644 --- a/src/structure/components/commands/administration/Settings.js +++ b/src/structure/components/commands/administration/Settings.js @@ -20,15 +20,15 @@ class SettingsCommand extends SlashCommand { }); } - async execute(interaction) { + async execute(invoker) { - const subcmd = interaction.subcommand.name; + const subcmd = invoker.subcommand.name; - if (subcmd === 'list') return this._listSettings(interaction); + if (subcmd === 'list') return this._listSettings(invoker); } - async _listSettings(interaction) { + async _listSettings(invoker) { const { settings } = this.client.registry; const modules = settings.reduce((acc, setting) => { @@ -38,10 +38,9 @@ class SettingsCommand extends SlashCommand { return acc; }, {}); - const { guild } = interaction; const embed = { title: 'Settings', - description: guild.format('SETTINGS_LIST'), + description: invoker.format('SETTINGS_LIST'), fields: [] }; @@ -53,7 +52,7 @@ class SettingsCommand extends SlashCommand { inline: true }); - return interaction.reply({ embeds: [embed] }); + return invoker.reply({ embeds: [embed] }); } diff --git a/src/structure/components/commands/information/Guild.js b/src/structure/components/commands/information/Guild.js index f695a76..cd07cdc 100644 --- a/src/structure/components/commands/information/Guild.js +++ b/src/structure/components/commands/information/Guild.js @@ -11,6 +11,7 @@ class GuildCommand extends SlashCommand { super(client, { name: 'server', description: 'Display server related information', + guildOnly: true }); } diff --git a/src/structure/components/commands/information/Info.js b/src/structure/components/commands/information/Info.js index a5472e9..a265f38 100644 --- a/src/structure/components/commands/information/Info.js +++ b/src/structure/components/commands/information/Info.js @@ -46,7 +46,7 @@ class InformationCommand extends SlashCommand { async _user(interaction, user) { - const member = await interaction.guild.memberWrapper(user); //await interaction.guild.members.fetch(user.id).catch(() => null); + const member = await interaction.guild?.memberWrapper(user) || null; //await interaction.guild.members.fetch(user.id).catch(() => null); const activities = member?.presence?.activities || []; const flags = user.flags || await user.fetchFlags(); @@ -137,6 +137,8 @@ class InformationCommand extends SlashCommand { async _role(interaction, role) { const { guild } = interaction; + if (!guild) return { emoji: 'failure', index: 'COMMAND_INFO_GUILDONLY_ROLE' }; + const _members = await guild.members.fetch(); const members = _members.filter((member) => member.roles.cache.has(role.id)); const embed = { @@ -163,6 +165,7 @@ class InformationCommand extends SlashCommand { async _channel(interaction, channel) { + if (!interaction.guild) return { emoji: 'failure', index: 'COMMAND_INFO_GUILDONLY_CHANNEL' }; const perms = channel.permissionsFor(interaction.member); if (perms.missing('VIEW_CHANNEL').length) throw new CommandError(interaction, { index: 'ERR_MISSING_PERMISSIONS' });