aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 21:42:06 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-02-27 21:42:06 -0500
commitb5ada8dca12013bfc730a50f4e8808d61bce23ba (patch)
tree721f5c0f3068a7f98b30e257b3d58b2713f2f9bf /src/commands
parent973bbebfd0a47b0b36d19fccf6a882e971beaaa5 (diff)
downloadtanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.tar.gz
tanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.tar.bz2
tanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.zip
fix(FeaturesCommand): properly hide disabled features
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/config/config.ts2
-rw-r--r--src/commands/config/features.ts29
-rw-r--r--src/commands/dev/test.ts18
-rw-r--r--src/commands/info/help.ts6
-rw-r--r--src/commands/info/links.ts6
5 files changed, 29 insertions, 32 deletions
diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts
index f860b30..6cb493d 100644
--- a/src/commands/config/config.ts
+++ b/src/commands/config/config.ts
@@ -358,7 +358,7 @@ export default class ConfigCommand extends BushCommand {
};
const components = new ActionRow().addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('command_settingsBack').setLabel('Back')
+ new ButtonComponent({ style: ButtonStyle.Primary, customId: 'command_settingsBack', label: 'Back' })
);
settingsEmbed.setDescription(
`${Formatters.italic(guildSettingsObj[setting].description)}\n\n**Type:** ${guildSettingsObj[setting].type}`
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts
index c9aebd3..c022a3a 100644
--- a/src/commands/config/features.ts
+++ b/src/commands/config/features.ts
@@ -13,7 +13,6 @@ import {
Embed,
PermissionFlagsBits,
SelectMenuComponent,
- SelectMenuOption,
type Message,
type SelectMenuInteraction
} from 'discord.js';
@@ -85,21 +84,19 @@ export default class FeaturesCommand extends BushCommand {
public generateComponents(guildFeatures: GuildFeatures[], disable: boolean) {
return new ActionRow().addComponents(
- new SelectMenuComponent()
- .setCustomId('command_selectFeature')
- .setDisabled(disable)
- .setMaxValues(1)
- .setMinValues(1)
- .setOptions(
- ...guildFeatures
- .filter((f) => guildFeaturesObj[f].notConfigurable !== false)
- .map((f) =>
- new SelectMenuOption()
- .setLabel(guildFeaturesObj[f].name)
- .setValue(f)
- .setDescription(guildFeaturesObj[f].description)
- )
- )
+ new SelectMenuComponent({
+ customId: 'command_selectFeature',
+ disabled: disable,
+ maxValues: 1,
+ minValues: 1,
+ options: guildFeatures
+ .filter((f) => !guildFeaturesObj[f].hidden)
+ .map((f) => ({
+ label: guildFeaturesObj[f].name,
+ value: f,
+ description: guildFeaturesObj[f].description
+ }))
+ })
);
}
}
diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts
index 7bab0a1..8c76ded 100644
--- a/src/commands/dev/test.ts
+++ b/src/commands/dev/test.ts
@@ -54,11 +54,11 @@ export default class TestCommand extends BushCommand {
if (['button', 'buttons'].includes(args?.feature?.toLowerCase())) {
const ButtonRow = new ActionRow().addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId('primaryButton').setLabel('Primary'),
- new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId('secondaryButton').setLabel('Secondary'),
- new ButtonComponent().setStyle(ButtonStyle.Success).setCustomId('successButton').setLabel('Success'),
- new ButtonComponent().setStyle(ButtonStyle.Danger).setCustomId('dangerButton').setLabel('Danger'),
- new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
+ new ButtonComponent({ style: ButtonStyle.Primary, customId: 'primaryButton', label: 'Primary' }),
+ new ButtonComponent({ style: ButtonStyle.Secondary, customId: 'secondaryButton', label: 'Secondary' }),
+ new ButtonComponent({ style: ButtonStyle.Success, customId: 'successButton', label: 'Success' }),
+ new ButtonComponent({ style: ButtonStyle.Danger, customId: 'dangerButton', label: 'Danger' }),
+ new ButtonComponent({ style: ButtonStyle.Link, label: 'Link', url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' })
);
return await message.util.reply({ content: 'buttons', components: [ButtonRow] });
} else if (['embed', 'button embed'].includes(args?.feature?.toLowerCase())) {
@@ -77,7 +77,7 @@ export default class TestCommand extends BushCommand {
.setTitle('Title');
const buttonRow = new ActionRow().addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Link').setURL('https://google.com/')
+ new ButtonComponent({ style: ButtonStyle.Link, label: 'Link', url: 'https://google.com/' })
);
return await message.util.reply({ content: 'Test', embeds: [embed], components: [buttonRow] });
} else if (['lots of buttons'].includes(args?.feature?.toLowerCase())) {
@@ -86,7 +86,7 @@ export default class TestCommand extends BushCommand {
const row = new ActionRow();
for (let b = 1; b <= 5; b++) {
const id = (a + 5 * (b - 1)).toString();
- const button = new ButtonComponent().setStyle(ButtonStyle.Primary).setCustomId(id).setLabel(id);
+ const button = new ButtonComponent({ style: ButtonStyle.Primary, customId: id, label: id });
row.addComponents(button);
}
ButtonRows.push(row);
@@ -118,7 +118,7 @@ export default class TestCommand extends BushCommand {
const row = new ActionRow();
for (let b = 1; b <= 5; b++) {
const id = (a + 5 * (b - 1)).toString();
- const button = new ButtonComponent().setStyle(ButtonStyle.Secondary).setCustomId(id).setLabel(id);
+ const button = new ButtonComponent({ style: ButtonStyle.Secondary, customId: id, label: id });
row.addComponents(button);
}
ButtonRows.push(row);
@@ -151,7 +151,7 @@ export default class TestCommand extends BushCommand {
content: 'Click for modal',
components: [
new ActionRow().addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Primary).setLabel('Modal').setCustomId('test;modal')
+ new ButtonComponent({ style: ButtonStyle.Primary, label: 'Modal', customId: 'test;modal' })
)
]
});
diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts
index 2383566..15c447a 100644
--- a/src/commands/info/help.ts
+++ b/src/commands/info/help.ts
@@ -143,15 +143,15 @@ export default class HelpCommand extends BushCommand {
const row = new ActionRow();
if (!client.config.isDevelopment && !client.guilds.cache.some((guild) => guild.ownerId === message.author.id)) {
- row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
+ row.addComponents(new ButtonComponent({ style: ButtonStyle.Link, label: 'Invite Me', url: util.invite }));
}
if (!client.guilds.cache.get(client.config.supportGuild.id)?.members.cache.has(message.author.id)) {
row.addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite)
+ new ButtonComponent({ style: ButtonStyle.Link, label: 'Support Server', url: client.config.supportGuild.invite })
);
}
if (packageDotJSON?.repository)
- row.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository));
+ row.addComponents(new ButtonComponent({ style: ButtonStyle.Link, label: 'GitHub', url: packageDotJSON.repository }));
else void message.channel?.send('Error importing package.json, please report this to my developer.');
return row;
diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts
index d91f1e7..e14195e 100644
--- a/src/commands/info/links.ts
+++ b/src/commands/info/links.ts
@@ -22,11 +22,11 @@ export default class LinksCommand extends BushCommand {
public override async exec(message: BushMessage | BushSlashMessage) {
const buttonRow = new ActionRow();
if (!client.config.isDevelopment || message.author.isOwner()) {
- buttonRow.addComponents(new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Invite Me').setURL(util.invite));
+ buttonRow.addComponents(new ButtonComponent({ style: ButtonStyle.Link, label: 'Invite Me', url: util.invite }));
}
buttonRow.addComponents(
- new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('Support Server').setURL(client.config.supportGuild.invite),
- new ButtonComponent().setStyle(ButtonStyle.Link).setLabel('GitHub').setURL(packageDotJSON.repository)
+ new ButtonComponent({ style: ButtonStyle.Link, label: 'Support Server', url: client.config.supportGuild.invite }),
+ new ButtonComponent({ style: ButtonStyle.Link, label: 'GitHub', url: packageDotJSON.repository })
);
return await message.util.reply({ content: 'Here are some useful links:', components: [buttonRow] });
}