aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/AutoMod.ts22
-rw-r--r--src/lib/common/ButtonPaginator.ts35
-rw-r--r--src/lib/common/ConfirmationPrompt.ts8
-rw-r--r--src/lib/common/DeleteButton.ts8
-rw-r--r--src/lib/common/util/Moderation.ts8
5 files changed, 41 insertions, 40 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index db3e709..5534728 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -1,7 +1,15 @@
import { banResponse, Moderation, type BushButtonInteraction, type BushMessage } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
-import { ActionRow, ButtonComponent, ButtonStyle, Embed, GuildMember, PermissionFlagsBits, type TextChannel } from 'discord.js';
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ GuildMember,
+ PermissionFlagsBits,
+ type TextChannel
+} from 'discord.js';
/**
* Handles auto moderation functionality.
@@ -153,7 +161,7 @@ export class AutoMod {
const color = this.punish({ severity: Severity.TEMP_MUTE, reason: 'everyone mention and scam phrase' } as BadWordDetails);
void this.message.guild!.sendLogChannel('automod', {
embeds: [
- new Embed()
+ new EmbedBuilder()
.setTitle(`[Severity ${Severity.TEMP_MUTE}] Mention Scam Deleted`)
.setDescription(
`**User:** ${this.message.author} (${this.message.author.tag})\n**Sent From:** <#${this.message.channel.id}> [Jump to context](${this.message.url})`
@@ -163,8 +171,8 @@ export class AutoMod {
.setTimestamp()
],
components: [
- new ActionRow().addComponents(
- new ButtonComponent({
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder({
style: ButtonStyle.Danger,
label: 'Ban User',
customId: `automod;ban;${this.message.author.id};everyone mention and scam phrase`
@@ -316,7 +324,7 @@ export class AutoMod {
await this.message.guild!.sendLogChannel('automod', {
embeds: [
- new Embed()
+ new EmbedBuilder()
.setTitle(`[Severity ${highestOffence.severity}] Automod Action Performed`)
.setDescription(
`**User:** ${this.message.author} (${this.message.author.tag})\n**Sent From:** <#${
@@ -331,8 +339,8 @@ export class AutoMod {
components:
highestOffence.severity >= 2
? [
- new ActionRow().addComponents(
- new ButtonComponent({
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder({
style: ButtonStyle.Danger,
label: 'Ban User',
customId: `automod;ban;${this.message.author.id};${highestOffence.reason}`
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index e3d4207..59dcb68 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -1,14 +1,7 @@
import { DeleteButton, type BushMessage, type BushSlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
-import { APIEmbed } from 'discord-api-types/v9';
-import {
- ActionRow,
- ButtonComponent,
- ButtonStyle,
- Embed,
- type MessageActionRowComponent,
- type MessageComponentInteraction
-} from 'discord.js';
+import { APIEmbed } from 'discord-api-types/v10';
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, type MessageComponentInteraction } from 'discord.js';
/**
* Sends multiple embeds with controls to switch between them
@@ -22,7 +15,7 @@ export class ButtonPaginator {
/**
* The embeds to paginate
*/
- protected embeds: Embed[] | APIEmbed[];
+ protected embeds: EmbedBuilder[] | APIEmbed[];
/**
* The optional text to send with the paginator
@@ -53,7 +46,7 @@ export class ButtonPaginator {
*/
protected constructor(
message: BushMessage | BushSlashMessage,
- embeds: Embed[] | APIEmbed[],
+ embeds: EmbedBuilder[] | APIEmbed[],
text: string | null,
deleteOnExit: boolean,
startOn: number
@@ -66,8 +59,8 @@ export class ButtonPaginator {
// add footers
for (let i = 0; i < embeds.length; i++) {
- if (embeds[i] instanceof Embed) {
- (embeds[i] as Embed).setFooter({ text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}` });
+ if (embeds[i] instanceof EmbedBuilder) {
+ (embeds[i] as EmbedBuilder).setFooter({ text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}` });
} else {
(embeds[i] as APIEmbed).footer = {
text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}`
@@ -177,33 +170,33 @@ export class ButtonPaginator {
* @param disableAll Whether to disable all buttons
* @returns The generated {@link ActionRow}
*/
- protected getPaginationRow(disableAll = false): ActionRow<MessageActionRowComponent> {
- return new ActionRow().addComponents(
- new ButtonComponent({
+ protected getPaginationRow(disableAll = false) {
+ return new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_beginning',
emoji: PaginateEmojis.BEGINNING,
disabled: disableAll || this.curPage === 0
}),
- new ButtonComponent({
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_back',
emoji: PaginateEmojis.BACK,
disabled: disableAll || this.curPage === 0
}),
- new ButtonComponent({
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_stop',
emoji: PaginateEmojis.STOP,
disabled: disableAll
}),
- new ButtonComponent({
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_next',
emoji: PaginateEmojis.FORWARD,
disabled: disableAll || this.curPage === this.numPages - 1
}),
- new ButtonComponent({
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate_end',
emoji: PaginateEmojis.END,
@@ -222,7 +215,7 @@ export class ButtonPaginator {
*/
public static async send(
message: BushMessage | BushSlashMessage,
- embeds: (Embed | APIEmbed)[],
+ embeds: EmbedBuilder[] | APIEmbed[],
text: string | null = null,
deleteOnExit = true,
startOn = 1
diff --git a/src/lib/common/ConfirmationPrompt.ts b/src/lib/common/ConfirmationPrompt.ts
index 4ff00ce..e86c236 100644
--- a/src/lib/common/ConfirmationPrompt.ts
+++ b/src/lib/common/ConfirmationPrompt.ts
@@ -1,5 +1,5 @@
import { type BushMessage, type BushSlashMessage } from '#lib';
-import { ActionRow, ButtonComponent, ButtonStyle, type MessageComponentInteraction, type MessageOptions } from 'discord.js';
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type MessageComponentInteraction, type MessageOptions } from 'discord.js';
/**
* Sends a message with buttons for the user to confirm or cancel the action.
@@ -29,9 +29,9 @@ export class ConfirmationPrompt {
*/
protected async send(): Promise<boolean> {
this.messageOptions.components = [
- new ActionRow().addComponents(
- new ButtonComponent({ style: ButtonStyle.Success, customId: 'confirmationPrompt_confirm', label: 'Yes' }),
- new ButtonComponent({ style: ButtonStyle.Danger, customId: 'confirmationPrompt_cancel', label: 'No' })
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder({ style: ButtonStyle.Success, customId: 'confirmationPrompt_confirm', label: 'Yes' }),
+ new ButtonBuilder({ style: ButtonStyle.Danger, customId: 'confirmationPrompt_cancel', label: 'No' })
)
];
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index 0a9fd79..4874f78 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -1,8 +1,8 @@
import { PaginateEmojis, type BushMessage, type BushSlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
import {
- ActionRow,
- ButtonComponent,
+ ActionRowBuilder,
+ ButtonBuilder,
ButtonStyle,
MessageComponentInteraction,
MessageEditOptions,
@@ -66,8 +66,8 @@ export class DeleteButton {
*/
protected updateComponents(edit = false, disable = false): void {
this.messageOptions.components = [
- new ActionRow().addComponents(
- new ButtonComponent({
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder({
style: ButtonStyle.Primary,
customId: 'paginate__stop',
emoji: PaginateEmojis.STOP,
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index afe220c..f388121 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, Embed, PermissionFlagsBits, type Snowflake } from 'discord.js';
+import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, PermissionFlagsBits, type Snowflake } from 'discord.js';
enum punishMap {
'warned' = 'warn',
@@ -265,7 +265,7 @@ export class Moderation {
const ending = await options.guild.getSetting('punishmentEnding');
const dmEmbed =
ending && ending.length && options.sendFooter
- ? new Embed().setDescription(ending).setColor(util.colors.newBlurple)
+ ? new EmbedBuilder().setDescription(ending).setColor(util.colors.newBlurple)
: undefined;
const appealsEnabled = !!(
@@ -286,9 +286,9 @@ export class Moderation {
let components;
if (appealsEnabled && options.modlog)
components = [
- new ActionRow({
+ new ActionRowBuilder<ButtonBuilder>({
components: [
- new ButtonComponent({
+ new ButtonBuilder({
customId: `appeal;${this.punishmentToPresentTense(options.punishment)};${options.guild.id};${client.users.resolveId(
options.user
)};${options.modlog}`,