diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-22 08:11:17 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-08-22 08:11:17 -0400 |
commit | 6aeb28497825975484e495d8bd3bc7b2fefa3e87 (patch) | |
tree | e45b0d8d74b5f6eeaaeb92ec830b3116d6afc6d8 /src/commands | |
parent | 5ff0c8397a71f3c6b50ee3ce79227fefa4a2d5dd (diff) | |
download | tanzanite-6aeb28497825975484e495d8bd3bc7b2fefa3e87.tar.gz tanzanite-6aeb28497825975484e495d8bd3bc7b2fefa3e87.tar.bz2 tanzanite-6aeb28497825975484e495d8bd3bc7b2fefa3e87.zip |
show hidden features to bot devs
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/config/features.ts | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 625086a..0036349 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -40,9 +40,11 @@ export default class FeaturesCommand extends BushCommand { const featureEmbed = new EmbedBuilder().setTitle(`${message.guild.name}'s Features`).setColor(colors.default); + const hideHidden = !message.author.isOwner(); + const enabledFeatures = await message.guild.getSetting('enabledFeatures'); - this.generateDescription(guildFeaturesArr, enabledFeatures, featureEmbed); - const components = this.generateComponents(guildFeaturesArr, false); + this.generateDescription(guildFeaturesArr, enabledFeatures, featureEmbed, hideHidden); + const components = this.generateComponents(guildFeaturesArr, false, hideHidden); const msg = (await message.util.reply({ embeds: [featureEmbed], components: [components] })) as Message; const collector = msg.createMessageComponentCollector({ componentType: ComponentType.SelectMenu, @@ -60,7 +62,7 @@ export default class FeaturesCommand extends BushCommand { const newEnabledFeatures = await message.guild.toggleFeature(selected, message.member!); - this.generateDescription(guildFeaturesArr, newEnabledFeatures, featureEmbed); + this.generateDescription(guildFeaturesArr, newEnabledFeatures, featureEmbed, hideHidden); await interaction.update({ embeds: [featureEmbed] }).catch(() => undefined); return; @@ -71,13 +73,21 @@ export default class FeaturesCommand extends BushCommand { }); collector.on('end', async () => { - await msg.edit({ components: [this.generateComponents(guildFeaturesArr, false)] }).catch(() => undefined); + await msg + .edit({ components: [this.generateComponents(guildFeaturesArr, false, !message.author.isOwner())] }) + .catch(() => undefined); }); } - public generateDescription(allFeatures: GuildFeatures[], currentFeatures: GuildFeatures[], embed: EmbedBuilder): void { + public generateDescription( + allFeatures: GuildFeatures[], + currentFeatures: GuildFeatures[], + embed: EmbedBuilder, + hide: boolean + ): void { embed.setDescription( allFeatures + .filter((f) => !guildFeaturesObj[f].hidden || !hide) .map( (feature) => `${currentFeatures.includes(feature) ? emojis.check : emojis.cross} **${guildFeaturesObj[feature].name}**` ) @@ -85,7 +95,7 @@ export default class FeaturesCommand extends BushCommand { ); } - public generateComponents(guildFeatures: GuildFeatures[], disable: boolean) { + public generateComponents(guildFeatures: GuildFeatures[], disable: boolean, hide: boolean) { return new ActionRowBuilder<SelectMenuBuilder>().addComponents( new SelectMenuBuilder({ customId: 'command_selectFeature', @@ -93,7 +103,7 @@ export default class FeaturesCommand extends BushCommand { maxValues: 1, minValues: 1, options: guildFeatures - .filter((f) => !guildFeaturesObj[f].hidden) + .filter((f) => !guildFeaturesObj[f].hidden || !hide) .map((f) => ({ label: guildFeaturesObj[f].name, value: f, |