aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/AutoMod.ts29
-rw-r--r--src/lib/common/ButtonPaginator.ts55
-rw-r--r--src/lib/common/ConfirmationPrompt.ts4
-rw-r--r--src/lib/common/DeleteButton.ts11
-rw-r--r--src/lib/common/util/Moderation.ts11
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()
]
})
];