aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/AutoMod.ts12
-rw-r--r--src/lib/common/ButtonPaginator.ts81
-rw-r--r--src/lib/common/DeleteButton.ts12
-rw-r--r--src/lib/common/util/Moderation.ts4
4 files changed, 52 insertions, 57 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index 4de242a..c57d581 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -4,8 +4,8 @@ import {
ButtonComponent,
ButtonStyle,
ChannelType,
+ Embed,
GuildMember,
- MessageEmbed,
Permissions,
type TextChannel
} from 'discord.js';
@@ -142,12 +142,12 @@ 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 MessageEmbed()
+ new Embed()
.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})`
)
- .addField('Message Content', `${await util.codeblock(this.message.content, 1024)}`)
+ .addField({ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` })
.setColor(color)
.setTimestamp()
],
@@ -250,7 +250,7 @@ export class AutoMod {
* @param color The color that the log embed should be (based on the severity)
* @param offences The other offences that were also matched in the message
*/
- private async log(highestOffence: BadWordDetails, color: `#${string}`, offences: BadWordDetails[]) {
+ private async log(highestOffence: BadWordDetails, color: number, offences: BadWordDetails[]) {
void client.console.info(
'autoMod',
`Severity <<${highestOffence.severity}>> action performed on <<${this.message.author.tag}>> (<<${
@@ -260,14 +260,14 @@ export class AutoMod {
await this.message.guild!.sendLogChannel('automod', {
embeds: [
- new MessageEmbed()
+ new Embed()
.setTitle(`[Severity ${highestOffence.severity}] Automod Action Performed`)
.setDescription(
`**User:** ${this.message.author} (${this.message.author.tag})\n**Sent From**: <#${
this.message.channel.id
}> [Jump to context](${this.message.url})\n**Blacklisted Words:** ${offences.map((o) => `\`${o.match}\``).join(', ')}`
)
- .addField('Message Content', `${await util.codeblock(this.message.content, 1024)}`)
+ .addField({ name: 'Message Content', value: `${await util.codeblock(this.message.content, 1024)}` })
.setColor(color)
.setTimestamp()
.setAuthor({ name: this.message.author.tag, url: this.message.author.displayAvatarURL() })
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index 9e72551..0c18119 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -1,15 +1,7 @@
import { DeleteButton, type BushMessage, type BushSlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
-import {
- ActionRow,
- ActionRowComponent,
- ButtonComponent,
- ButtonStyle,
- ComponentType,
- MessageEmbed,
- type MessageComponentInteraction,
- type MessageEmbedOptions
-} from 'discord.js';
+import { APIEmbed } from 'discord-api-types';
+import { ActionRow, ActionRowComponent, ButtonComponent, ButtonStyle, Embed, type MessageComponentInteraction } from 'discord.js';
/**
* Sends multiple embeds with controls to switch between them
@@ -23,7 +15,7 @@ export class ButtonPaginator {
/**
* The embeds to paginate
*/
- protected embeds: MessageEmbed[] | MessageEmbedOptions[];
+ protected embeds: Embed[] | APIEmbed[];
/**
* The optional text to send with the paginator
@@ -54,7 +46,7 @@ export class ButtonPaginator {
*/
protected constructor(
message: BushMessage | BushSlashMessage,
- embeds: MessageEmbed[] | MessageEmbedOptions[],
+ embeds: Embed[] | APIEmbed[],
text: string | null,
deleteOnExit: boolean,
startOn: number
@@ -68,10 +60,10 @@ export class ButtonPaginator {
// add footers
for (let i = 0; i < embeds.length; i++) {
- if (embeds[i] instanceof MessageEmbed) {
- (embeds[i] as MessageEmbed).setFooter({ text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}` });
+ if (embeds[i] instanceof Embed) {
+ (embeds[i] as Embed).setFooter({ text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}` });
} else {
- (embeds[i] as MessageEmbedOptions).footer = {
+ (embeds[i] as APIEmbed).footer = {
text: `Page ${(i + 1).toLocaleString()}/${embeds.length.toLocaleString()}`
};
}
@@ -96,16 +88,9 @@ export class ButtonPaginator {
})) as BushMessage;
const collector = this.sentMessage.createMessageComponentCollector({
- componentType: ComponentType.Button,
- filter: (i) => {
- const ret = i.customId.startsWith('paginate_') && i.message.id === this.sentMessage!.id;
- console.debug(ret);
- return ret;
- },
- idle: 300000
+ filter: (i) => i.customId.startsWith('paginate_'),
+ time: 300_000
});
- console.debug('got here');
-
collector.on('collect', (i) => void this.collect(i));
collector.on('end', () => void this.end());
}
@@ -115,9 +100,8 @@ export class ButtonPaginator {
* @param interaction The interaction received
*/
protected async collect(interaction: MessageComponentInteraction) {
- console.debug(1);
if (interaction.user.id !== this.message.author.id && !client.config.owners.includes(interaction.user.id))
- return await interaction?.deferUpdate(); /* .catch(() => null); */
+ return await interaction?.deferUpdate().catch(() => null);
switch (interaction.customId) {
case 'paginate_beginning':
@@ -130,16 +114,17 @@ export class ButtonPaginator {
break;
case 'paginate_stop':
if (this.deleteOnExit) {
- await interaction.deferUpdate(); /* .catch(() => null); */
- await this.sentMessage!.delete(); /* .catch(() => null); */
+ await interaction.deferUpdate().catch(() => null);
+ await this.sentMessage!.delete().catch(() => null);
break;
} else {
- await interaction?.update({
- content: `${this.text ? `${this.text}\n` : ''}Command closed by user.`,
- embeds: [],
- components: []
- });
- /* .catch(() => null); */
+ await interaction
+ ?.update({
+ content: `${this.text ? `${this.text}\n` : ''}Command closed by user.`,
+ embeds: [],
+ components: []
+ })
+ .catch(() => null);
break;
}
case 'paginate_next':
@@ -158,12 +143,13 @@ export class ButtonPaginator {
*/
protected async end() {
if (this.sentMessage && !CommandUtil.deletedMessages.has(this.sentMessage.id))
- await this.sentMessage.edit({
- content: this.text,
- embeds: [this.embeds[this.curPage]],
- components: [this.getPaginationRow(true)]
- });
- /* .catch(() => null); */
+ await this.sentMessage
+ .edit({
+ content: this.text,
+ embeds: [this.embeds[this.curPage]],
+ components: [this.getPaginationRow(true)]
+ })
+ .catch(() => null);
}
/**
@@ -171,12 +157,13 @@ export class ButtonPaginator {
* @param interaction The interaction received
*/
protected async edit(interaction: MessageComponentInteraction) {
- await interaction?.update({
- content: this.text,
- embeds: [this.embeds[this.curPage]],
- components: [this.getPaginationRow()]
- });
- /* .catch(() => null); */
+ await interaction
+ ?.update({
+ content: this.text,
+ embeds: [this.embeds[this.curPage]],
+ components: [this.getPaginationRow()]
+ })
+ .catch(() => null);
}
/**
@@ -224,7 +211,7 @@ export class ButtonPaginator {
*/
public static async send(
message: BushMessage | BushSlashMessage,
- embeds: MessageEmbed[] | MessageEmbedOptions[],
+ embeds: (Embed | APIEmbed)[],
text: string | null = null,
deleteOnExit = true,
startOn = 1
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index edc40fe..cf3b416 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -1,6 +1,14 @@
import { PaginateEmojis, type BushMessage, type BushSlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
-import { ActionRow, ButtonComponent, ButtonStyle, MessageComponentInteraction, type MessageOptions } from 'discord.js';
+import {
+ ActionRow,
+ ButtonComponent,
+ ButtonStyle,
+ MessageComponentInteraction,
+ MessageEditOptions,
+ MessagePayload,
+ type MessageOptions
+} from 'discord.js';
/**
* Sends a message with a button for the user to delete it.
@@ -47,7 +55,7 @@ export class DeleteButton {
collector.on('end', async () => {
this.updateComponents(true, true);
- await msg.edit(this.messageOptions).catch(() => undefined);
+ await msg.edit(<string | MessagePayload | MessageEditOptions>this.messageOptions).catch(() => undefined);
});
}
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index 84d9fbf..62dbc90 100644
--- a/src/lib/common/util/Moderation.ts
+++ b/src/lib/common/util/Moderation.ts
@@ -10,7 +10,7 @@ import {
type BushUserResolvable,
type ModLogType
} from '#lib';
-import { MessageEmbed, Permissions, type Snowflake } from 'discord.js';
+import { Embed, Permissions, type Snowflake } from 'discord.js';
/**
* A utility class with moderation-related methods.
@@ -208,7 +208,7 @@ export class Moderation {
const ending = await options.guild.getSetting('punishmentEnding');
const dmEmbed =
ending && ending.length && options.sendFooter
- ? new MessageEmbed().setDescription(ending).setColor(util.colors.newBlurple)
+ ? new Embed().setDescription(ending).setColor(util.colors.newBlurple)
: undefined;
const dmSuccess = await client.users