aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-14 12:47:57 -0400
commit661e4c9935aeb8760dafc7ced4bbec6cc356a033 (patch)
treebb4c12bdef067d203f100e13e05ccb705b299834 /src/lib/common
parenteaf592b72eb5b1d66aa2bde5151a8947570a506c (diff)
downloadtanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.gz
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.tar.bz2
tanzanite-661e4c9935aeb8760dafc7ced4bbec6cc356a033.zip
remove the war crimes that I previously committed
- Remove custom typings and replace with declaration merging - Fix the typings for args - Replace all discord-api-types imports with discord.js imports - Fix discord.js breaking changes
Diffstat (limited to 'src/lib/common')
-rw-r--r--src/lib/common/AutoMod.ts12
-rw-r--r--src/lib/common/ButtonPaginator.ts25
-rw-r--r--src/lib/common/ConfirmationPrompt.ts8
-rw-r--r--src/lib/common/DeleteButton.ts10
-rw-r--r--src/lib/common/HighlightManager.ts10
-rw-r--r--src/lib/common/util/Arg.ts16
-rw-r--r--src/lib/common/util/Moderation.ts51
7 files changed, 74 insertions, 58 deletions
diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts
index f30eab7..982e0e8 100644
--- a/src/lib/common/AutoMod.ts
+++ b/src/lib/common/AutoMod.ts
@@ -1,4 +1,4 @@
-import { banResponse, Moderation, type BushButtonInteraction, type BushMessage } from '#lib';
+import { banResponse, Moderation } from '#lib';
import assert from 'assert';
import chalk from 'chalk';
import {
@@ -8,6 +8,8 @@ import {
EmbedBuilder,
GuildMember,
PermissionFlagsBits,
+ type ButtonInteraction,
+ type Message,
type TextChannel
} from 'discord.js';
@@ -18,7 +20,7 @@ export class AutoMod {
/**
* The message to check for blacklisted phrases on
*/
- private message: BushMessage;
+ private message: Message;
/**
* Whether or not a punishment has already been given to the user
@@ -28,7 +30,7 @@ export class AutoMod {
/**
* @param message The message to check and potentially perform automod actions to
*/
- public constructor(message: BushMessage) {
+ public constructor(message: Message) {
this.message = message;
if (message.author.id === client.user?.id) return;
void this.handle();
@@ -355,7 +357,7 @@ export class AutoMod {
* Handles the ban button in the automod log.
* @param interaction The button interaction.
*/
- public static async handleInteraction(interaction: BushButtonInteraction) {
+ public static async handleInteraction(interaction: ButtonInteraction) {
if (!interaction.memberPermissions?.has(PermissionFlagsBits.BanMembers))
return interaction.reply({
content: `${util.emojis.error} You are missing the **Ban Members** permission.`,
@@ -382,7 +384,7 @@ export class AutoMod {
user: userId,
reason,
moderator: interaction.user.id,
- evidence: (interaction.message as BushMessage).url ?? undefined
+ evidence: (interaction.message as Message).url ?? undefined
});
const victimUserFormatted = (await util.resolveNonCachedUser(userId))?.tag ?? userId;
diff --git a/src/lib/common/ButtonPaginator.ts b/src/lib/common/ButtonPaginator.ts
index cc95601..64870cf 100644
--- a/src/lib/common/ButtonPaginator.ts
+++ b/src/lib/common/ButtonPaginator.ts
@@ -1,7 +1,14 @@
-import { DeleteButton, type BushMessage, type BushSlashMessage } from '#lib';
+import { DeleteButton, type CommandMessage, type SlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
-import { APIEmbed } from 'discord-api-types/v10';
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, type MessageComponentInteraction } from 'discord.js';
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ type APIEmbed,
+ type Message,
+ type MessageComponentInteraction
+} from 'discord.js';
/**
* Sends multiple embeds with controls to switch between them
@@ -10,7 +17,7 @@ export class ButtonPaginator {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* The embeds to paginate
@@ -35,7 +42,7 @@ export class ButtonPaginator {
/**
* The paginator message
*/
- protected sentMessage: BushMessage | undefined;
+ protected sentMessage: Message | undefined;
/**
* @param message The message to respond to
@@ -45,7 +52,7 @@ export class ButtonPaginator {
* @param startOn The page to start from (**not** the index)
*/
protected constructor(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
embeds: EmbedBuilder[] | APIEmbed[],
text: string | null,
deleteOnExit: boolean,
@@ -80,11 +87,11 @@ export class ButtonPaginator {
* Sends the paginator message
*/
protected async send() {
- this.sentMessage = (await this.message.util.reply({
+ this.sentMessage = await this.message.util.reply({
content: this.text,
embeds: [this.embeds[this.curPage]],
components: [this.getPaginationRow()]
- })) as BushMessage;
+ });
const collector = this.sentMessage.createMessageComponentCollector({
filter: (i) => i.customId.startsWith('paginate_'),
@@ -214,7 +221,7 @@ export class ButtonPaginator {
* @param startOn The page to start from (**not** the index)
*/
public static async send(
- message: BushMessage | BushSlashMessage,
+ message: CommandMessage | SlashMessage,
embeds: EmbedBuilder[] | APIEmbed[],
text: string | null = null,
deleteOnExit = true,
diff --git a/src/lib/common/ConfirmationPrompt.ts b/src/lib/common/ConfirmationPrompt.ts
index c611fd3..c95dbbc 100644
--- a/src/lib/common/ConfirmationPrompt.ts
+++ b/src/lib/common/ConfirmationPrompt.ts
@@ -1,4 +1,4 @@
-import { type BushMessage, type BushSlashMessage } from '#lib';
+import { type CommandMessage, type SlashMessage } from '#lib';
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type MessageComponentInteraction, type MessageOptions } from 'discord.js';
/**
@@ -13,13 +13,13 @@ export class ConfirmationPrompt {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* @param message The message to respond to
* @param options The send message options
*/
- protected constructor(message: BushMessage | BushSlashMessage, messageOptions: MessageOptions) {
+ protected constructor(message: CommandMessage | SlashMessage, messageOptions: MessageOptions) {
this.message = message;
this.messageOptions = messageOptions;
}
@@ -71,7 +71,7 @@ export class ConfirmationPrompt {
* @param message The message to respond to
* @param options The send message options
*/
- public static async send(message: BushMessage | BushSlashMessage, sendOptions: MessageOptions): Promise<boolean> {
+ public static async send(message: CommandMessage | SlashMessage, sendOptions: MessageOptions): Promise<boolean> {
return new ConfirmationPrompt(message, sendOptions).send();
}
}
diff --git a/src/lib/common/DeleteButton.ts b/src/lib/common/DeleteButton.ts
index 03e2639..91f4bfa 100644
--- a/src/lib/common/DeleteButton.ts
+++ b/src/lib/common/DeleteButton.ts
@@ -1,4 +1,4 @@
-import { PaginateEmojis, type BushMessage, type BushSlashMessage } from '#lib';
+import { PaginateEmojis, type CommandMessage, type SlashMessage } from '#lib';
import { CommandUtil } from 'discord-akairo';
import {
ActionRowBuilder,
@@ -22,13 +22,13 @@ export class DeleteButton {
/**
* The message that triggered the command
*/
- protected message: BushMessage | BushSlashMessage;
+ protected message: CommandMessage | SlashMessage;
/**
* @param message The message to respond to
* @param options The send message options
*/
- protected constructor(message: BushMessage | BushSlashMessage, options: MessageOptions) {
+ protected constructor(message: CommandMessage | SlashMessage, options: MessageOptions) {
this.message = message;
this.messageOptions = options;
}
@@ -39,7 +39,7 @@ export class DeleteButton {
protected async send() {
this.updateComponents();
- const msg = (await this.message.util.reply(this.messageOptions)) as BushMessage;
+ const msg = await this.message.util.reply(this.messageOptions);
const collector = msg.createMessageComponentCollector({
filter: (interaction) => interaction.customId == 'paginate__stop' && interaction.message?.id == msg.id,
@@ -85,7 +85,7 @@ export class DeleteButton {
* @param message The message to respond to
* @param options The send message options
*/
- public static async send(message: BushMessage | BushSlashMessage, options: Omit<MessageOptions, 'components'>) {
+ public static async send(message: CommandMessage | SlashMessage, options: Omit<MessageOptions, 'components'>) {
return new DeleteButton(message, options).send();
}
}
diff --git a/src/lib/common/HighlightManager.ts b/src/lib/common/HighlightManager.ts
index fffb266..fdec322 100644
--- a/src/lib/common/HighlightManager.ts
+++ b/src/lib/common/HighlightManager.ts
@@ -1,6 +1,6 @@
-import { Highlight, type BushMessage, type HighlightWord } from '#lib';
+import { Highlight, type HighlightWord } from '#lib';
import assert from 'assert';
-import { Collection, type Snowflake } from 'discord.js';
+import { Collection, type Message, type Snowflake } from 'discord.js';
import { Time } from '../utils/BushConstants.js';
const NOTIFY_COOLDOWN = 5 * Time.Minute;
@@ -75,7 +75,7 @@ export class HighlightManager {
* @param message The message to check.
* @returns A collection users mapped to the highlight matched
*/
- public checkMessage(message: BushMessage): Collection<Snowflake, HighlightWord> {
+ public checkMessage(message: Message): Collection<Snowflake, HighlightWord> {
// even if there are multiple matches, only the first one is returned
const ret = new Collection<Snowflake, HighlightWord>();
if (!message.content || !message.inGuild()) return ret;
@@ -225,7 +225,7 @@ export class HighlightManager {
* @param hl The highlight that was matched.
* @returns Whether or a dm was sent.
*/
- public async notify(message: BushMessage, user: Snowflake, hl: HighlightWord): Promise<boolean> {
+ public async notify(message: Message, user: Snowflake, hl: HighlightWord): Promise<boolean> {
assert(message.inGuild());
dmCooldown: {
@@ -301,7 +301,7 @@ export class HighlightManager {
* Updates the time that a user last talked in a particular guild.
* @param message The message the user sent.
*/
- public updateLastTalked(message: BushMessage): void {
+ public updateLastTalked(message: Message): void {
if (!message.inGuild()) return;
const lastTalked = (
this.userLastTalkedCooldown.has(message.guildId)
diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts
index 01d3b0b..51d8065 100644
--- a/src/lib/common/util/Arg.ts
+++ b/src/lib/common/util/Arg.ts
@@ -1,4 +1,10 @@
-import { type BaseBushArgumentType, type BushArgumentType, type BushArgumentTypeCaster, type BushSlashMessage } from '#lib';
+import {
+ type BaseBushArgumentType,
+ type BushArgumentType,
+ type BushArgumentTypeCaster,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import { Argument, type Flag, type ParsedValuePredicate } from 'discord-akairo';
import { type Message } from 'discord.js';
@@ -12,10 +18,10 @@ export class Arg {
* @param message - Message that called the command.
* @param phrase - Phrase to process.
*/
- public static async cast<T extends ATC>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<ATCR<T>>;
- public static async cast<T extends KBAT>(type: T, message: Message | BushSlashMessage, phrase: string): Promise<BAT[T]>;
- public static async cast(type: AT | ATC, message: Message | BushSlashMessage, phrase: string): Promise<any>;
- public static async cast(type: ATC | AT, message: Message | BushSlashMessage, phrase: string): Promise<any> {
+ public static async cast<T extends ATC>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<ATCR<T>>;
+ public static async cast<T extends KBAT>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<BAT[T]>;
+ public static async cast(type: AT | ATC, message: CommandMessage | SlashMessage, phrase: string): Promise<any>;
+ public static async cast(type: ATC | AT, message: CommandMessage | SlashMessage, phrase: string): Promise<any> {
return Argument.cast(type as any, client.commandHandler.resolver, message as Message, phrase);
}
diff --git a/src/lib/common/util/Moderation.ts b/src/lib/common/util/Moderation.ts
index 9f93375..6cdc141 100644
--- a/src/lib/common/util/Moderation.ts
+++ b/src/lib/common/util/Moderation.ts
@@ -1,17 +1,18 @@
-import {
- ActivePunishment,
- ActivePunishmentType,
- Guild,
- ModLog,
- type BushGuild,
- type BushGuildMember,
- type BushGuildMemberResolvable,
- type BushGuildResolvable,
- type BushUserResolvable,
- type ModLogType
-} from '#lib';
+import { ActivePunishment, ActivePunishmentType, Guild as GuildDB, ModLog, type ModLogType } from '#lib';
import assert from 'assert';
-import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, PermissionFlagsBits, type Snowflake } from 'discord.js';
+import {
+ ActionRowBuilder,
+ ButtonBuilder,
+ ButtonStyle,
+ EmbedBuilder,
+ PermissionFlagsBits,
+ type Guild,
+ type GuildMember,
+ type GuildMemberResolvable,
+ type GuildResolvable,
+ type Snowflake,
+ type UserResolvable
+} from 'discord.js';
enum punishMap {
'warned' = 'warn',
@@ -52,8 +53,8 @@ export class Moderation {
* @returns `true` if the moderator can perform the action otherwise a reason why they can't.
*/
public static async permissionCheck(
- moderator: BushGuildMember,
- victim: BushGuildMember,
+ moderator: GuildMember,
+ victim: GuildMember,
type:
| 'mute'
| 'unmute'
@@ -146,7 +147,7 @@ export class Moderation {
getCaseNumber = false
): Promise<{ log: ModLog | null; caseNum: number | null }> {
// If guild does not exist create it so the modlog can reference a guild.
- await Guild.findOrCreate({
+ await GuildDB.findOrCreate({
where: { id: options.guild },
defaults: { id: options.guild }
});
@@ -349,17 +350,17 @@ export interface CreateModLogEntryOptions extends BaseCreateModLogEntryOptions {
/**
* The user that a modlog entry is created for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The moderator that created the modlog entry.
*/
- moderator: BushGuildMemberResolvable;
+ moderator: GuildMemberResolvable;
/**
* The guild that the punishment is created for.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
}
/**
@@ -394,7 +395,7 @@ export interface CreatePunishmentEntryOptions {
/**
* The user that the punishment is created for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The length of time the punishment lasts for.
@@ -404,7 +405,7 @@ export interface CreatePunishmentEntryOptions {
/**
* The guild that the punishment is created for.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
/**
* The id of the modlog that is linked to the punishment entry.
@@ -429,12 +430,12 @@ export interface RemovePunishmentEntryOptions {
/**
* The user that the punishment is destroyed for.
*/
- user: BushGuildMemberResolvable;
+ user: GuildMemberResolvable;
/**
* The guild that the punishment was in.
*/
- guild: BushGuildResolvable;
+ guild: GuildResolvable;
/**
* Extra information for the punishment. The role for role punishments and the channel for blocks.
@@ -454,12 +455,12 @@ export interface PunishDMOptions {
/**
* The guild that the punishment is taking place in.
*/
- guild: BushGuild;
+ guild: Guild;
/**
* The user that is being punished.
*/
- user: BushUserResolvable;
+ user: UserResolvable;
/**
* The punishment that the user has received.