aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/AutoMod.ts8
-rw-r--r--src/lib/common/ButtonPaginator.ts31
-rw-r--r--src/lib/common/DeleteButton.ts5
-rw-r--r--src/lib/common/Format.ts2
-rw-r--r--src/lib/common/Moderation.ts12
-rw-r--r--src/lib/common/typings/BushInspectOptions.d.ts2
-rw-r--r--src/lib/common/util/Arg.ts8
7 files changed, 30 insertions, 38 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index 38c488b..c749a33 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -1,10 +1,8 @@
-import { GuildMember, MessageActionRow, MessageButton, MessageEmbed, TextChannel } from 'discord.js';
+import { Moderation, type BushButtonInteraction, type BushMessage } from '@lib';
+import { GuildMember, MessageActionRow, MessageButton, MessageEmbed, type TextChannel } from 'discord.js';
import badLinksArray from '../badlinks';
import badLinksSecretArray from '../badlinks-secret'; // I cannot make this public so just make a new file that export defaults an empty array
import badWords from '../badwords';
-import { BushButtonInteraction } from '../extensions/discord.js/BushButtonInteraction';
-import { BushMessage } from '../extensions/discord.js/BushMessage';
-import { Moderation } from './Moderation';
export class AutoMod {
private message: BushMessage;
@@ -190,7 +188,7 @@ export class AutoMod {
const [action, userId, reason] = interaction.customId.replace('automod;', '').split(';');
switch (action) {
case 'ban': {
- const victim = await interaction.guild!.members.fetch(userId);
+ const victim = await interaction.guild!.members.fetch(userId).catch(() => null);
const moderator =
interaction.member instanceof GuildMember
? interaction.member
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index da595d5..58134b5 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -1,13 +1,12 @@
+import { DeleteButton, type BushMessage, type BushSlashMessage } from '@lib';
import {
Constants,
MessageActionRow,
MessageButton,
- MessageComponentInteraction,
MessageEmbed,
- MessageEmbedOptions
+ type MessageComponentInteraction,
+ type MessageEmbedOptions
} from 'discord.js';
-import { BushMessage, BushSlashMessage } from '..';
-import { DeleteButton } from './DeleteButton';
export class ButtonPaginator {
protected message: BushMessage | BushSlashMessage;
@@ -86,7 +85,7 @@ export class ButtonPaginator {
protected async collect(interaction: MessageComponentInteraction) {
if (interaction.user.id !== this.message.author.id && !client.config.owners.includes(interaction.user.id))
- return await interaction?.deferUpdate().catch(() => undefined);
+ return await interaction?.deferUpdate().catch(() => null);
switch (interaction.customId) {
case 'paginate_beginning':
@@ -97,8 +96,8 @@ export class ButtonPaginator {
return await this.edit(interaction);
case 'paginate_stop':
if (this.deleteOnExit) {
- await interaction.deferUpdate().catch(() => undefined);
- return await this.sentMessage!.delete().catch(() => undefined);
+ await interaction.deferUpdate().catch(() => null);
+ return await this.sentMessage!.delete().catch(() => null);
} else {
return await interaction
?.update({
@@ -106,7 +105,7 @@ export class ButtonPaginator {
embeds: [],
components: []
})
- .catch(() => undefined);
+ .catch(() => null);
}
case 'paginate_next':
this.curPage++;
@@ -125,19 +124,15 @@ export class ButtonPaginator {
embeds: [this.embeds[this.curPage]],
components: [this.getPaginationRow(true)]
})
- .catch(() => undefined);
+ .catch(() => null);
}
protected async edit(interaction: MessageComponentInteraction) {
- try {
- return interaction?.update({
- content: this.text,
- embeds: [this.embeds[this.curPage]],
- components: [this.getPaginationRow()]
- });
- } catch (e) {
- return undefined;
- }
+ return interaction?.update({
+ content: this.text,
+ embeds: [this.embeds[this.curPage]],
+ components: [this.getPaginationRow()]
+ }).catch(() => null);
}
protected getPaginationRow(disableAll = false): MessageActionRow {
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index 7d2e41b..95bae24 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -1,6 +1,5 @@
-import { Constants, MessageActionRow, MessageButton, MessageComponentInteraction, MessageOptions } from 'discord.js';
-import { BushMessage, BushSlashMessage } from '..';
-import { PaginateEmojis } from './ButtonPaginator';
+import { PaginateEmojis, type BushMessage, type BushSlashMessage } from '@lib';
+import { Constants, MessageActionRow, MessageButton, type MessageComponentInteraction, type MessageOptions } from 'discord.js';
export class DeleteButton {
protected messageOptions: MessageOptions;
diff --git a/src/lib/common/Format.ts b/src/lib/common/Format.ts
index ba1ee9f..2557b17 100644
--- a/src/lib/common/Format.ts
+++ b/src/lib/common/Format.ts
@@ -1,5 +1,5 @@
+import { type CodeBlockLang } from '@lib';
import { Formatters, Util } from 'discord.js';
-import { CodeBlockLang } from './typings/CodeBlockLang';
/**
* Formats and escapes content for formatting
diff --git a/src/lib/common/Moderation.ts b/src/lib/common/Moderation.ts
index 0c7c21a..d0367d5 100644
--- a/src/lib/common/Moderation.ts
+++ b/src/lib/common/Moderation.ts
@@ -1,14 +1,14 @@
-import { Snowflake } from 'discord-api-types';
import {
ActivePunishment,
ActivePunishmentType,
- BushGuildMember,
- BushGuildMemberResolvable,
- BushGuildResolvable,
Guild,
ModLog,
- ModLogType
-} from '..';
+ ModLogType,
+ type BushGuildMember,
+ type BushGuildMemberResolvable,
+ type BushGuildResolvable
+} from '@lib';
+import { type Snowflake } from 'discord.js';
export class Moderation {
/**
diff --git a/src/lib/common/typings/BushInspectOptions.d.ts b/src/lib/common/typings/BushInspectOptions.d.ts
index c2a2360..11c2dc1 100644
--- a/src/lib/common/typings/BushInspectOptions.d.ts
+++ b/src/lib/common/typings/BushInspectOptions.d.ts
@@ -1,4 +1,4 @@
-import { InspectOptions } from 'util';
+import { type InspectOptions } from 'util';
/**
* {@link https://nodejs.org/api/util.html#util_util_inspect_object_options}
diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts
index d267eb9..3c8e642 100644
--- a/src/lib/common/util/Arg.ts
+++ b/src/lib/common/util/Arg.ts
@@ -1,6 +1,6 @@
-import { AkairoMessage, Argument, ArgumentTypeCaster, Flag, ParsedValuePredicate } from 'discord-akairo';
-import { Message } from 'discord.js';
-import { BushArgumentType } from '../..';
+import { type BushArgumentType, type BushMessage, type BushSlashMessage } from '@lib';
+import { Argument, type ArgumentTypeCaster, type Flag, type ParsedValuePredicate } from 'discord-akairo';
+import { type Message } from 'discord.js';
export class Arg {
/**
@@ -9,7 +9,7 @@ export class Arg {
* @param message - Message that called the command.
* @param phrase - Phrase to process.
*/
- public static cast(type: BushArgumentType, message: Message | AkairoMessage, phrase: string): Promise<any> {
+ public static cast(type: BushArgumentType, message: BushMessage | BushSlashMessage, phrase: string): Promise<any> {
return Argument.cast(type, client.commandHandler.resolver, message as Message, phrase);
}