diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 21:42:06 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 21:42:06 -0500 |
commit | b5ada8dca12013bfc730a50f4e8808d61bce23ba (patch) | |
tree | 721f5c0f3068a7f98b30e257b3d58b2713f2f9bf /src/lib/common | |
parent | 973bbebfd0a47b0b36d19fccf6a882e971beaaa5 (diff) | |
download | tanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.tar.gz tanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.tar.bz2 tanzanite-b5ada8dca12013bfc730a50f4e8808d61bce23ba.zip |
fix(FeaturesCommand): properly hide disabled features
Diffstat (limited to 'src/lib/common')
-rw-r--r-- | src/lib/common/AutoMod.ts | 29 | ||||
-rw-r--r-- | src/lib/common/ButtonPaginator.ts | 55 | ||||
-rw-r--r-- | src/lib/common/ConfirmationPrompt.ts | 4 | ||||
-rw-r--r-- | src/lib/common/DeleteButton.ts | 11 | ||||
-rw-r--r-- | src/lib/common/util/Moderation.ts | 11 |
5 files changed, 57 insertions, 53 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts index d043ef0..93d2f8f 100644 --- a/src/lib/common/AutoMod.ts +++ b/src/lib/common/AutoMod.ts @@ -162,17 +162,15 @@ export class AutoMod { .setColor(color) .setTimestamp() ], - components: - Severity.TEMP_MUTE >= 2 - ? [ - new ActionRow().addComponents( - new ButtonComponent() - .setStyle(ButtonStyle.Danger) - .setLabel('Ban User') - .setCustomId(`automod;ban;${this.message.author.id};everyone mention and scam phrase`) - ) - ] - : undefined + components: [ + new ActionRow().addComponents( + new ButtonComponent({ + style: ButtonStyle.Danger, + label: 'Ban User', + customId: `automod;ban;${this.message.author.id};everyone mention and scam phrase` + }) + ) + ] }); } } @@ -334,10 +332,11 @@ export class AutoMod { highestOffence.severity >= 2 ? [ new ActionRow().addComponents( - new ButtonComponent() - .setStyle(ButtonStyle.Danger) - .setLabel('Ban User') - .setCustomId(`automod;ban;${this.message.author.id};${highestOffence.reason}`) + new ButtonComponent({ + style: ButtonStyle.Danger, + label: 'Ban User', + customId: `automod;ban;${this.message.author.id};${highestOffence.reason}` + }) ) ] : undefined diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts index a289855..15c07fa 100644 --- a/src/lib/common/ButtonPaginator.ts +++ b/src/lib/common/ButtonPaginator.ts @@ -172,31 +172,36 @@ export class ButtonPaginator { */ protected getPaginationRow(disableAll = false): ActionRow<ActionRowComponent> { return new ActionRow().addComponents( - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate_beginning') - .setEmoji(PaginateEmojis.BEGINNING) - .setDisabled(disableAll || this.curPage === 0), - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate_back') - .setEmoji(PaginateEmojis.BACK) - .setDisabled(disableAll || this.curPage === 0), - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate_stop') - .setEmoji(PaginateEmojis.STOP) - .setDisabled(disableAll), - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate_next') - .setEmoji(PaginateEmojis.FORWARD) - .setDisabled(disableAll || this.curPage === this.embeds.length - 1), - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate_end') - .setEmoji(PaginateEmojis.END) - .setDisabled(disableAll || this.curPage === this.embeds.length - 1) + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate_beginning', + emoji: PaginateEmojis.BEGINNING, + disabled: disableAll || this.curPage === 0 + }), + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate_back', + emoji: PaginateEmojis.BACK, + disabled: disableAll || this.curPage === 0 + }), + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate_stop', + emoji: PaginateEmojis.STOP, + disabled: disableAll + }), + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate_next', + emoji: PaginateEmojis.FORWARD, + disabled: disableAll || this.curPage === this.numPages - 1 + }), + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate_end', + emoji: PaginateEmojis.END, + disabled: disableAll || this.curPage === this.numPages - 1 + }) ); } diff --git a/src/lib/common/ConfirmationPrompt.ts b/src/lib/common/ConfirmationPrompt.ts index b775640..4ff00ce 100644 --- a/src/lib/common/ConfirmationPrompt.ts +++ b/src/lib/common/ConfirmationPrompt.ts @@ -30,8 +30,8 @@ export class ConfirmationPrompt { protected async send(): Promise<boolean> { this.messageOptions.components = [ new ActionRow().addComponents( - new ButtonComponent().setStyle(ButtonStyle.Success).setCustomId('confirmationPrompt_confirm').setLabel('Yes'), - new ButtonComponent().setStyle(ButtonStyle.Danger).setCustomId('confirmationPrompt_cancel').setLabel('No') + new ButtonComponent({ style: ButtonStyle.Success, customId: 'confirmationPrompt_confirm', label: 'Yes' }), + new ButtonComponent({ style: ButtonStyle.Danger, customId: 'confirmationPrompt_cancel', label: 'No' }) ) ]; diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts index cf3b416..0a9fd79 100644 --- a/src/lib/common/DeleteButton.ts +++ b/src/lib/common/DeleteButton.ts @@ -67,11 +67,12 @@ export class DeleteButton { protected updateComponents(edit = false, disable = false): void { this.messageOptions.components = [ new ActionRow().addComponents( - new ButtonComponent() - .setStyle(ButtonStyle.Primary) - .setCustomId('paginate__stop') - .setEmoji(PaginateEmojis.STOP) - .setDisabled(disable) + new ButtonComponent({ + style: ButtonStyle.Primary, + customId: 'paginate__stop', + emoji: PaginateEmojis.STOP, + disabled: disable + }) ) ]; if (edit) { diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts index 365dbd5..afe220c 100644 --- a/src/lib/common/util/Moderation.ts +++ b/src/lib/common/util/Moderation.ts @@ -11,7 +11,7 @@ import { type ModLogType } from '#lib'; import assert from 'assert'; -import { ActionRow, ButtonComponent, ButtonStyle, ComponentType, Embed, PermissionFlagsBits, type Snowflake } from 'discord.js'; +import { ActionRow, ButtonComponent, ButtonStyle, Embed, PermissionFlagsBits, type Snowflake } from 'discord.js'; enum punishMap { 'warned' = 'warn', @@ -289,13 +289,12 @@ export class Moderation { new ActionRow({ components: [ new ButtonComponent({ - custom_id: `appeal;${this.punishmentToPresentTense(options.punishment)};${ - options.guild.id - };${client.users.resolveId(options.user)};${options.modlog}`, + customId: `appeal;${this.punishmentToPresentTense(options.punishment)};${options.guild.id};${client.users.resolveId( + options.user + )};${options.modlog}`, style: ButtonStyle.Primary, - type: ComponentType.Button, label: 'Appeal' - }) + }).toJSON() ] }) ]; |