diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
commit | 0e87bbd3940d89defcb04926587b35c8f4d1947f (patch) | |
tree | e50860d4dc25a11d4c3977b583284c4bcad1b077 /src/listeners | |
parent | 661e4c9935aeb8760dafc7ced4bbec6cc356a033 (diff) | |
download | tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.gz tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.bz2 tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.zip |
remove util classes, move config out of src
Diffstat (limited to 'src/listeners')
74 files changed, 308 insertions, 309 deletions
diff --git a/src/listeners/bush/appealListener.ts b/src/listeners/bush/appealListener.ts index 64979b5..06eb245 100644 --- a/src/listeners/bush/appealListener.ts +++ b/src/listeners/bush/appealListener.ts @@ -1,5 +1,5 @@ /* eslint-disable no-control-regex */ -import { BushListener, ModLog, type BushClientEvents } from '#lib'; +import { BushListener, colors, mappings, ModLog, type BushClientEvents } from '#lib'; import assert from 'assert'; import { EmbedBuilder } from 'discord.js'; import UserInfoCommand from '../../commands/info/userInfo.js'; @@ -14,8 +14,8 @@ export default class AppealListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<any> { - if (!client.config.isProduction || !message.inGuild() || message.guildId !== client.consts.mappings.guilds.bush) return; + public async exec(...[message]: BushClientEvents['messageCreate']): Promise<any> { + if (!client.config.isProduction || !message.inGuild() || message.guildId !== mappings.guilds.bush) return; if (message.author.id !== '855446927688335370' || message.embeds.length < 1) return; const userId = message.embeds[0].fields?.find?.((f) => f.name === 'What is your discord ID?')?.value; @@ -32,7 +32,7 @@ export default class AppealListener extends BushListener { embeds: [ new EmbedBuilder() .setTimestamp() - .setColor(util.colors.error) + .setColor(colors.error) .setTitle( `${message.embeds[0].fields!.find((f) => f.name === 'What type of punishment are you appealing?')!.value} appeal` ) @@ -54,7 +54,7 @@ export default class AppealListener extends BushListener { const embed = new EmbedBuilder() .setTimestamp() - .setColor(util.colors.default) + .setColor(colors.default) .setTitle(`${message.embeds[0].fields!.find((f) => f.name === 'What type of punishment are you appealing?')!.value} appeal`) .setThumbnail(user.displayAvatarURL()); diff --git a/src/listeners/bush/joinAutoBan.ts b/src/listeners/bush/joinAutoBan.ts index 83efa06..eae18d3 100644 --- a/src/listeners/bush/joinAutoBan.ts +++ b/src/listeners/bush/joinAutoBan.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BushListener, type BushClientEvents } from '#lib'; +import { AllowedMentions, BushListener, colors, emojis, format, getShared, mappings, type BushClientEvents } from '#lib'; import { TextChannel } from 'discord.js'; export default class JoinAutoBanListener extends BushListener { @@ -10,14 +10,14 @@ export default class JoinAutoBanListener extends BushListener { }); } - public override async exec(...[member]: BushClientEvents['guildMemberAdd']): Promise<void> { + public async exec(...[member]: BushClientEvents['guildMemberAdd']): Promise<void> { if (!client.config.isProduction) return; - if (member.guild.id !== client.consts.mappings.guilds.bush) return; + if (member.guild.id !== mappings.guilds.bush) return; const guild = member.guild; // eslint-disable-next-line @typescript-eslint/no-unused-vars const user = member.user; - const code = util.getShared('autoBanCode'); + const code = getShared('autoBanCode'); if (!code) return; if (eval(code)) { const res = await member.bushBan({ @@ -28,7 +28,7 @@ export default class JoinAutoBanListener extends BushListener { if (!['success', 'failed to dm'].includes(res)) { return await guild.error( 'nameAutoBan', - `Failed to auto ban ${util.format.input(member.user.tag)} for blacklisted name, with error: ${util.format.input(res)}.` + `Failed to auto ban ${format.input(member.user.tag)} for blacklisted name, with error: ${format.input(res)}.` ); } @@ -38,7 +38,7 @@ export default class JoinAutoBanListener extends BushListener { { title: 'Name Auto Ban - User Join', description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for blacklisted name.`, - color: util.colors.red, + color: colors.red, author: { name: member.user.tag, icon_url: member.displayAvatarURL() @@ -50,8 +50,8 @@ export default class JoinAutoBanListener extends BushListener { const content = res === 'failed to dm' - ? `${util.emojis.warn} Banned ${util.format.input(member.user.tag)} however I could not send them a dm.` - : `${util.emojis.success} Successfully banned ${util.format.input(member.user.tag)}.`; + ? `${emojis.warn} Banned ${format.input(member.user.tag)} however I could not send them a dm.` + : `${emojis.success} Successfully banned ${format.input(member.user.tag)}.`; (<TextChannel>guild.channels.cache.find((c) => c.name === 'general')) ?.send({ content, allowedMentions: AllowedMentions.none() }) diff --git a/src/listeners/bush/supportThread.ts b/src/listeners/bush/supportThread.ts index 46ac96f..3651409 100644 --- a/src/listeners/bush/supportThread.ts +++ b/src/listeners/bush/supportThread.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { stripIndent } from '#tags'; import assert from 'assert'; import { EmbedBuilder, MessageType, PermissionFlagsBits, TextChannel } from 'discord.js'; @@ -12,7 +12,7 @@ export default class SupportThreadListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']): Promise<void | undefined> { + public async exec(...[message]: BushClientEvents['messageCreate']): Promise<void | undefined> { if (!client.config.isProduction || !message.inGuild()) return; if (![MessageType.Default, MessageType.Reply].includes(message.type)) return; if (message.thread) return; @@ -50,7 +50,7 @@ export default class SupportThreadListener extends BushListener { Please make sure you have the latest version found in <#693586404256645231>. Additionally if you need help installing the mod be sure to read <#737444942724726915> for a guide on how to do so.` ) - .setColor(util.colors.Blurple); + .setColor(colors.Blurple); void thread .send({ embeds: [embed] }) .then(() => diff --git a/src/listeners/bush/userUpdateAutoBan.ts b/src/listeners/bush/userUpdateAutoBan.ts index b9485b3..07381e0 100644 --- a/src/listeners/bush/userUpdateAutoBan.ts +++ b/src/listeners/bush/userUpdateAutoBan.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, BushListener, type BushClientEvents } from '#lib'; +import { AllowedMentions, BushListener, colors, emojis, format, getShared, mappings, type BushClientEvents } from '#lib'; import { GuildMember, type TextChannel } from 'discord.js'; export default class UserUpdateAutoBanListener extends BushListener { @@ -10,16 +10,16 @@ export default class UserUpdateAutoBanListener extends BushListener { }); } - public override async exec(...[_oldUser, newUser]: BushClientEvents['userUpdate']): Promise<void> { + public async exec(...[_oldUser, newUser]: BushClientEvents['userUpdate']): Promise<void> { if (!client.config.isProduction) return; // eslint-disable-next-line @typescript-eslint/no-unused-vars const user = newUser; - const code = util.getShared('autoBanCode'); + const code = getShared('autoBanCode'); if (!code) return; if (eval(code)) { const member = await client.guilds.cache - .get(client.consts.mappings.guilds.bush) + .get(mappings.guilds.bush) ?.members.fetch(newUser.id) .catch(() => undefined); if (!member || !(member instanceof GuildMember)) return; @@ -34,7 +34,7 @@ export default class UserUpdateAutoBanListener extends BushListener { if (!['success', 'failed to dm'].includes(res)) { return await guild.error( 'nameAutoBan', - `Failed to auto ban ${util.format.input(member.user.tag)} for blacklisted name, with error: ${util.format.input(res)}.` + `Failed to auto ban ${format.input(member.user.tag)} for blacklisted name, with error: ${format.input(res)}.` ); } @@ -44,7 +44,7 @@ export default class UserUpdateAutoBanListener extends BushListener { { title: 'Name Auto Ban - User Update', description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using blacklisted name.`, - color: util.colors.red, + color: colors.red, author: { name: member.user.tag, icon_url: member.displayAvatarURL() @@ -56,8 +56,8 @@ export default class UserUpdateAutoBanListener extends BushListener { const content = res === 'failed to dm' - ? `${util.emojis.warn} Banned ${util.format.input(member.user.tag)} however I could not send them a dm.` - : `${util.emojis.success} Successfully banned ${util.format.input(member.user.tag)}.`; + ? `${emojis.warn} Banned ${format.input(member.user.tag)} however I could not send them a dm.` + : `${emojis.success} Successfully banned ${format.input(member.user.tag)}.`; (<TextChannel>guild.channels.cache.find((c) => c.name === 'general')) ?.send({ content, allowedMentions: AllowedMentions.none() }) diff --git a/src/listeners/client/akairoDebug.ts b/src/listeners/client/akairoDebug.ts index 0cb57a5..208e289 100644 --- a/src/listeners/client/akairoDebug.ts +++ b/src/listeners/client/akairoDebug.ts @@ -9,7 +9,7 @@ export default class DiscordJsDebugListener extends BushListener { }); } - public override async exec(...[message, ...other]: BushClientEvents['debug']): Promise<void> { + public async exec(...[message, ...other]: BushClientEvents['debug']): Promise<void> { if (other.length && !message.includes('[registerInteractionCommands]')) void client.console.superVerboseRaw('akairoDebug', message, ...other); else void client.console.superVerbose('akairoDebug', message); diff --git a/src/listeners/client/dcjsDebug.ts b/src/listeners/client/dcjsDebug.ts index 52406c1..56a9eab 100644 --- a/src/listeners/client/dcjsDebug.ts +++ b/src/listeners/client/dcjsDebug.ts @@ -9,7 +9,7 @@ export default class DiscordJsDebugListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['debug']): Promise<void> { + public async exec(...[message]: BushClientEvents['debug']): Promise<void> { void client.console.superVerbose('dc.js-debug', message); } } diff --git a/src/listeners/client/dcjsError.ts b/src/listeners/client/dcjsError.ts index 4908720..c3cf8f0 100644 --- a/src/listeners/client/dcjsError.ts +++ b/src/listeners/client/dcjsError.ts @@ -9,7 +9,7 @@ export default class DiscordJsErrorListener extends BushListener { }); } - public override async exec(...[error]: BushClientEvents['error']): Promise<void> { + public async exec(...[error]: BushClientEvents['error']): Promise<void> { void client.console.superVerbose('dc.js-error', error); } } diff --git a/src/listeners/client/dcjsWarn.ts b/src/listeners/client/dcjsWarn.ts index cc2b30f..6c13630 100644 --- a/src/listeners/client/dcjsWarn.ts +++ b/src/listeners/client/dcjsWarn.ts @@ -9,7 +9,7 @@ export default class DiscordJsWarnListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['warn']): Promise<void> { + public async exec(...[message]: BushClientEvents['warn']): Promise<void> { void client.console.superVerbose('dc.js-warn', message); } } diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts index c550c6b..ae9919c 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -11,7 +11,7 @@ export default class ReadyListener extends BushListener { } // eslint-disable-next-line no-empty-pattern - public override async exec(...[]: BushClientEvents['ready']) { + public async exec(...[]: BushClientEvents['ready']) { process.emit('ready' as any); const tag = `<<${client.user?.tag}>>`, diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index feb85d1..8a05d39 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -1,4 +1,14 @@ -import { BushListener, type BushCommand, type BushCommandHandlerEvents, type CommandMessage, type SlashMessage } from '#lib'; +import { + BlockedReasons, + BushListener, + emojis, + format, + oxford, + type BushCommand, + type BushCommandHandlerEvents, + type CommandMessage, + type SlashMessage +} from '#lib'; import { type InteractionReplyOptions, type MessagePayload, type ReplyMessageOptions } from 'discord.js'; export default class CommandBlockedListener extends BushListener { @@ -10,7 +20,7 @@ export default class CommandBlockedListener extends BushListener { }); } - public override async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']) { + public async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']) { return await CommandBlockedListener.handleBlocked(message, command, reason); } @@ -24,85 +34,84 @@ export default class CommandBlockedListener extends BushListener { } was blocked because <<${reason}>>.`, true ); - const reasons = client.consts.BlockedReasons; switch (reason) { - case reasons.OWNER: { + case BlockedReasons.OWNER: { return await respond({ - content: `${util.emojis.error} Only my developers can run the ${util.format.input(command!.id)} command.`, + content: `${emojis.error} Only my developers can run the ${format.input(command!.id)} command.`, ephemeral: true }); } - case reasons.SUPER_USER: { + case BlockedReasons.SUPER_USER: { return await respond({ - content: `${util.emojis.error} You must be a superuser to run the ${util.format.input(command!.id)} command.`, + content: `${emojis.error} You must be a superuser to run the ${format.input(command!.id)} command.`, ephemeral: true }); } - case reasons.DISABLED_GLOBAL: { + case BlockedReasons.DISABLED_GLOBAL: { return await respond({ - content: `${util.emojis.error} My developers disabled the ${util.format.input(command!.id)} command.`, + content: `${emojis.error} My developers disabled the ${format.input(command!.id)} command.`, ephemeral: true }); } - case reasons.DISABLED_GUILD: { + case BlockedReasons.DISABLED_GUILD: { return await respond({ - content: `${util.emojis.error} The ${util.format.input( - command!.id - )} command is currently disabled in ${util.format.input(message.guild!.name)}.`, + content: `${emojis.error} The ${format.input(command!.id)} command is currently disabled in ${format.input( + message.guild!.name + )}.`, ephemeral: true }); } - case reasons.CHANNEL_GLOBAL_BLACKLIST: - case reasons.CHANNEL_GUILD_BLACKLIST: + case BlockedReasons.CHANNEL_GLOBAL_BLACKLIST: + case BlockedReasons.CHANNEL_GUILD_BLACKLIST: return isSlash ? await respond({ - content: `${util.emojis.error} You cannot use this bot in this channel.`, + content: `${emojis.error} You cannot use this bot in this channel.`, ephemeral: true }) - : await (message as CommandMessage).react(util.emojis.cross); - case reasons.USER_GLOBAL_BLACKLIST: - case reasons.USER_GUILD_BLACKLIST: + : await (message as CommandMessage).react(emojis.cross); + case BlockedReasons.USER_GLOBAL_BLACKLIST: + case BlockedReasons.USER_GUILD_BLACKLIST: return isSlash ? await respond({ - content: `${util.emojis.error} You are blacklisted from using this bot.`, + content: `${emojis.error} You are blacklisted from using this bot.`, ephemeral: true }) - : await (message as CommandMessage).react(util.emojis.cross); - case reasons.ROLE_BLACKLIST: { + : await (message as CommandMessage).react(emojis.cross); + case BlockedReasons.ROLE_BLACKLIST: { return isSlash ? await respond({ - content: `${util.emojis.error} One of your roles blacklists you from using this bot.`, + content: `${emojis.error} One of your roles blacklists you from using this bot.`, ephemeral: true }) - : await (message as CommandMessage).react(util.emojis.cross); + : await (message as CommandMessage).react(emojis.cross); } - case reasons.RESTRICTED_CHANNEL: { + case BlockedReasons.RESTRICTED_CHANNEL: { if (!command) break; const channels = command.restrictedChannels; const names: string[] = []; channels!.forEach((c) => { names.push(`<#${c}>`); }); - const pretty = util.oxford(names, 'and'); + const pretty = oxford(names, 'and'); return await respond({ - content: `${util.emojis.error} ${util.format.input(command!.id)} can only be run in ${pretty}.`, + content: `${emojis.error} ${format.input(command!.id)} can only be run in ${pretty}.`, ephemeral: true }); } - case reasons.RESTRICTED_GUILD: { + case BlockedReasons.RESTRICTED_GUILD: { if (!command) break; const guilds = command.restrictedGuilds; - const names = guilds!.map((g) => util.format.input(client.guilds.cache.get(g)?.name ?? g)); - const pretty = util.oxford(names, 'and'); + const names = guilds!.map((g) => format.input(client.guilds.cache.get(g)?.name ?? g)); + const pretty = oxford(names, 'and'); return await respond({ - content: `${util.emojis.error} ${util.format.input(command!.id)} can only be run in ${pretty}.`, + content: `${emojis.error} ${format.input(command!.id)} can only be run in ${pretty}.`, ephemeral: true }); } default: { return await respond({ - content: `${util.emojis.error} Command blocked with reason ${util.format.input(reason ?? 'unknown')}.`, + content: `${emojis.error} Command blocked with reason ${format.input(reason ?? 'unknown')}.`, ephemeral: true }); } diff --git a/src/listeners/commands/commandCooldown.ts b/src/listeners/commands/commandCooldown.ts index 92b0abe..74dd4eb 100644 --- a/src/listeners/commands/commandCooldown.ts +++ b/src/listeners/commands/commandCooldown.ts @@ -9,7 +9,7 @@ export default class CommandCooldownListener extends BushListener { }); } - public override async exec(...[message, command, remaining]: BushCommandHandlerEvents['cooldown']) { + public async exec(...[message, command, remaining]: BushCommandHandlerEvents['cooldown']) { void client.console.info( 'commandCooldown', `<<${message.author.tag}>> tried to run <<${ diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 878e459..ca6565e 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -1,6 +1,16 @@ -import { SlashMessage, type BushCommandHandlerEvents } from '#lib'; +import { + capitalize, + colors, + format, + formatError, + inspectAndRedact, + inspectCleanRedactCodeblock, + inspectCleanRedactHaste, + SlashMessage, + type BushCommandHandlerEvents +} from '#lib'; import { type AkairoMessage, type Command } from 'discord-akairo'; -import { ChannelType, EmbedBuilder, Formatters, GuildTextBasedChannel, type Message } from 'discord.js'; +import { ChannelType, EmbedBuilder, escapeInlineCode, Formatters, GuildTextBasedChannel, type Message } from 'discord.js'; import { BushListener } from '../../lib/extensions/discord-akairo/BushListener.js'; export default class CommandErrorListener extends BushListener { @@ -12,7 +22,7 @@ export default class CommandErrorListener extends BushListener { }); } - public override exec(...[error, message, command]: BushCommandHandlerEvents['error']) { + public exec(...[error, message, command]: BushCommandHandlerEvents['error']) { return CommandErrorListener.handleError(error, message, command); } @@ -49,7 +59,7 @@ export default class CommandErrorListener extends BushListener { `${isSlash ? 'slashC' : 'c'}ommandError`, `an error occurred with the <<${command}>> ${isSlash ? 'slash ' : ''}command in <<${channel}>> triggered by <<${ message?.author?.tag - }>>:\n${util.formatError(error, true)})}`, + }>>:\n${formatError(error, true)})}`, false ); @@ -127,16 +137,16 @@ export default class CommandErrorListener extends BushListener { stack: string; } ): EmbedBuilder[] { - const embeds = [new EmbedBuilder().setColor(util.colors.error)]; + const embeds = [new EmbedBuilder().setColor(colors.error)]; if (options.type === 'command-user') { embeds[0] .setTitle('An Error Occurred') .setDescription( `Oh no! ${ options.command - ? `While running the ${options.isSlash ? 'slash ' : ''}command ${util.format.input(options.command.id)}, a` + ? `While running the ${options.isSlash ? 'slash ' : ''}command ${format.input(options.command.id)}, a` : 'A' - }n error occurred. Please give the developers code ${util.format.input(`${options.errorNum}`)}.` + }n error occurred. Please give the developers code ${format.input(`${options.errorNum}`)}.` ) .setTimestamp(); return embeds; @@ -155,11 +165,11 @@ export default class CommandErrorListener extends BushListener { description.push(...options.haste); - embeds.push(new EmbedBuilder().setColor(util.colors.error).setTimestamp().setDescription(options.stack.substring(0, 4000))); + embeds.push(new EmbedBuilder().setColor(colors.error).setTimestamp().setDescription(options.stack.substring(0, 4000))); if (description.length) embeds[0].setDescription(description.join('\n').substring(0, 4000)); if (options.type === 'command-dev' || options.type === 'command-log') - embeds[0].setTitle(`${options.isSlash ? 'Slash ' : ''}CommandError #${util.format.input(`${options.errorNum}`)}`); + embeds[0].setTitle(`${options.isSlash ? 'Slash ' : ''}CommandError #${format.input(`${options.errorNum}`)}`); else if (options.type === 'uncaughtException') embeds[0].setTitle(`${options.context ? `[${Formatters.bold(options.context)}] An Error Occurred` : 'Uncaught Exception'}`); else if (options.type === 'unhandledRejection') @@ -199,7 +209,7 @@ export default class CommandErrorListener extends BushListener { for (const element in error) { if (['stack', 'name', 'message'].includes(element)) continue; else if (typeof (error as any)[element] === 'object') { - promises.push(util.inspectCleanRedactHaste((error as any)[element], inspectOptions)); + promises.push(inspectCleanRedactHaste((error as any)[element], inspectOptions)); } } @@ -218,14 +228,14 @@ export default class CommandErrorListener extends BushListener { if (['stack', 'name', 'message'].includes(element)) continue; else { ret.push( - `**Error ${util.capitalizeFirstLetter(element)}:** ${ - typeof (error as any)[element] === 'object' + `**Error ${capitalize(element)}:** ${ + typeof error[element] === 'object' ? `${ pair[element].url ? `[haste](${pair[element].url})${pair[element].error ? ` - ${pair[element].error}` : ''}` : pair[element].error }` - : `\`${util.discord.escapeInlineCode(util.inspectAndRedact((error as any)[element], inspectOptions))}\`` + : `\`${escapeInlineCode(inspectAndRedact((error as any)[element], inspectOptions))}\`` }` ); } @@ -234,7 +244,7 @@ export default class CommandErrorListener extends BushListener { } public static async getErrorStack(error: Error | any): Promise<string> { - return await util.inspectCleanRedactCodeblock(error, 'js', { colors: false }, 4000); + return await inspectCleanRedactCodeblock(error, 'js', { colors: false }, 4000); } } diff --git a/src/listeners/commands/commandLocked.ts b/src/listeners/commands/commandLocked.ts index 285eb50..22ed8e1 100644 --- a/src/listeners/commands/commandLocked.ts +++ b/src/listeners/commands/commandLocked.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BushListener, emojis, format, type BushCommandHandlerEvents } from '#lib'; export default class CommandLockedListener extends BushListener { public constructor() { @@ -9,9 +9,9 @@ export default class CommandLockedListener extends BushListener { }); } - public override async exec(...[message, command]: BushCommandHandlerEvents['commandLocked']) { + public async exec(...[message, command]: BushCommandHandlerEvents['commandLocked']) { return message.util.reply( - `${util.emojis.error} You cannot use the ${util.format.input(command.id)} command because it is already in use.` + `${emojis.error} You cannot use the ${format.input(command.id)} command because it is already in use.` ); } } diff --git a/src/listeners/commands/commandMissingPermissions.ts b/src/listeners/commands/commandMissingPermissions.ts index 2cbf17c..352899d 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BushListener, emojis, format, mappings, oxford, surroundArray, type BushCommandHandlerEvents } from '#lib'; import { type PermissionsString } from 'discord.js'; export default class CommandMissingPermissionsListener extends BushListener { @@ -10,7 +10,7 @@ export default class CommandMissingPermissionsListener extends BushListener { }); } - public override async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']) { + public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']) { return await CommandMissingPermissionsListener.handleMissing(message, command, type, missing); } @@ -20,11 +20,11 @@ export default class CommandMissingPermissionsListener extends BushListener { | BushCommandHandlerEvents['slashMissingPermissions'] ) { const niceMissing = (missing.includes('Administrator') ? (['Administrator'] as PermissionsString[]) : missing).map( - (perm) => client.consts.mappings.permissions[perm]?.name ?? missing + (perm) => mappings.permissions[perm]?.name ?? missing ); - const discordFormat = util.oxford(util.surroundArray(niceMissing, '**'), 'and', ''); - const consoleFormat = util.oxford(util.surroundArray(niceMissing, '<<', '>>'), 'and', ''); + const discordFormat = oxford(surroundArray(niceMissing, '**'), 'and', ''); + const consoleFormat = oxford(surroundArray(niceMissing, '<<', '>>'), 'and', ''); void client.console.info( 'commandMissingPermissions', `<<${message.author.tag}>> tried to run <<${ @@ -34,15 +34,15 @@ export default class CommandMissingPermissionsListener extends BushListener { if (type == 'client') { return await message.util .reply( - `${util.emojis.error} I am missing the ${discordFormat} permission${ + `${emojis.error} I am missing the ${discordFormat} permission${ missing.length ? 's' : '' - } required for the ${util.format.input(command?.id)} command.` + } required for the ${format.input(command?.id)} command.` ) .catch(() => {}); } else if (type == 'user') { return await message.util .reply( - `${util.emojis.error} You are missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the **${ + `${emojis.error} You are missing the ${discordFormat} permission${missing.length ? 's' : ''} required for the **${ command?.id }** command.` ) diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts index 02a0b75..89fea28 100644 --- a/src/listeners/commands/commandStarted.ts +++ b/src/listeners/commands/commandStarted.ts @@ -10,7 +10,7 @@ export default class CommandStartedListener extends BushListener { }); } - public override exec(...[message, command]: BushCommandHandlerEvents['commandStarted']): void { + public exec(...[message, command]: BushCommandHandlerEvents['commandStarted']): void { client.sentry.addBreadcrumb({ message: `[commandStarted] The ${command.id} was started by ${message.author.tag}.`, level: 'info', diff --git a/src/listeners/commands/messageBlocked.ts b/src/listeners/commands/messageBlocked.ts index 5a2b10d..997579c 100644 --- a/src/listeners/commands/messageBlocked.ts +++ b/src/listeners/commands/messageBlocked.ts @@ -9,7 +9,7 @@ export default class MessageBlockedListener extends BushListener { }); } - public override async exec(...[message, reason]: BushCommandHandlerEvents['messageBlocked']) { + public async exec(...[message, reason]: BushCommandHandlerEvents['messageBlocked']) { if (['client', 'bot'].includes(reason)) return; // return await CommandBlockedListener.handleBlocked(message as Message, null, reason); return void client.console.verbose(`messageBlocked`, `<<${message.author.tag}>>'s message was blocked because ${reason}`); diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index 6c0ed14..915b953 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -10,7 +10,7 @@ export default class SlashBlockedListener extends BushListener { }); } - public override async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']) { + public async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']) { return await CommandBlockedListener.handleBlocked(message, command, reason); } } diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index 25c0f3e..f851f4f 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -10,7 +10,7 @@ export default class SlashCommandErrorListener extends BushListener { }); } - public override async exec(...[error, message, command]: BushCommandHandlerEvents['slashError']) { + public async exec(...[error, message, command]: BushCommandHandlerEvents['slashError']) { return await CommandErrorListener.handleError(error, message, command); } } diff --git a/src/listeners/commands/slashMissingPermissions.ts b/src/listeners/commands/slashMissingPermissions.ts index 296f44b..3ae03e3 100644 --- a/src/listeners/commands/slashMissingPermissions.ts +++ b/src/listeners/commands/slashMissingPermissions.ts @@ -10,7 +10,7 @@ export default class SlashMissingPermissionsListener extends BushListener { }); } - public override async exec(...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions']) { + public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions']) { return await CommandMissingPermissionsListener.handleMissing(message, command, type, missing); } } diff --git a/src/listeners/commands/slashNotFound.ts b/src/listeners/commands/slashNotFound.ts index a8e4267..8c6d2d4 100644 --- a/src/listeners/commands/slashNotFound.ts +++ b/src/listeners/commands/slashNotFound.ts @@ -9,7 +9,7 @@ export default class SlashNotFoundListener extends BushListener { }); } - public override async exec(...[interaction]: BushCommandHandlerEvents['slashNotFound']) { + public async exec(...[interaction]: BushCommandHandlerEvents['slashNotFound']) { void client.console.info('slashNotFound', `<<${interaction?.commandName}>> could not be found.`); } } diff --git a/src/listeners/commands/slashStarted.ts b/src/listeners/commands/slashStarted.ts index 3d8334d..e2c8a47 100644 --- a/src/listeners/commands/slashStarted.ts +++ b/src/listeners/commands/slashStarted.ts @@ -10,7 +10,7 @@ export default class SlashStartedListener extends BushListener { }); } - public override async exec(...[message, command]: BushCommandHandlerEvents['slashStarted']) { + public async exec(...[message, command]: BushCommandHandlerEvents['slashStarted']) { client.sentry.addBreadcrumb({ message: `[slashStarted] The ${command.id} was started by ${message.author.tag}.`, level: 'info', diff --git a/src/listeners/contextCommands/contextCommandBlocked.ts b/src/listeners/contextCommands/contextCommandBlocked.ts index ba4af8c..a9397b6 100644 --- a/src/listeners/contextCommands/contextCommandBlocked.ts +++ b/src/listeners/contextCommands/contextCommandBlocked.ts @@ -1,4 +1,4 @@ -import { BushListener } from '#lib'; +import { BlockedReasons, BushListener, emojis, format } from '#lib'; import { type ContextMenuCommandHandlerEvents } from 'discord-akairo'; export default class ContextCommandBlockedListener extends BushListener { @@ -10,7 +10,7 @@ export default class ContextCommandBlockedListener extends BushListener { }); } - public override async exec(...[interaction, command, reason]: ContextMenuCommandHandlerEvents['blocked']) { + public async exec(...[interaction, command, reason]: ContextMenuCommandHandlerEvents['blocked']) { void client.console.info( `ContextCommandBlocked`, `<<${interaction.user.tag}>> tried to run <<${command}>> but was blocked because <<${reason}>>.`, @@ -18,21 +18,21 @@ export default class ContextCommandBlockedListener extends BushListener { ); switch (reason) { - case client.consts.BlockedReasons.OWNER: { + case BlockedReasons.OWNER: { return await interaction.reply({ - content: `${util.emojis.error} Only my developers can run the ${util.format.input(command!.id)} command.`, + content: `${emojis.error} Only my developers can run the ${format.input(command!.id)} command.`, ephemeral: true }); } - case client.consts.BlockedReasons.SUPER_USER: { + case BlockedReasons.SUPER_USER: { return await interaction.reply({ - content: `${util.emojis.error} You must be a superuser to run the ${util.format.input(command!.id)} command.`, + content: `${emojis.error} You must be a superuser to run the ${format.input(command!.id)} command.`, ephemeral: true }); } default: { return await interaction.reply({ - content: `${util.emojis.error} Command blocked with reason ${util.format.input(reason ?? 'unknown')}.`, + content: `${emojis.error} Command blocked with reason ${format.input(reason ?? 'unknown')}.`, ephemeral: true }); } diff --git a/src/listeners/contextCommands/contextCommandError.ts b/src/listeners/contextCommands/contextCommandError.ts index 19b5708..e69ed4e 100644 --- a/src/listeners/contextCommands/contextCommandError.ts +++ b/src/listeners/contextCommands/contextCommandError.ts @@ -1,4 +1,4 @@ -import { BushListener } from '#lib'; +import { BushListener, colors, format, formatError } from '#lib'; import { type ContextMenuCommand, type ContextMenuCommandHandlerEvents } from 'discord-akairo'; import { ChannelType, ContextMenuCommandInteraction, EmbedBuilder, GuildTextBasedChannel } from 'discord.js'; import CommandErrorListener, { IFuckedUpError } from '../commands/commandError.js'; @@ -12,7 +12,7 @@ export default class ContextCommandErrorListener extends BushListener { }); } - public override exec(...[error, interaction, command]: ContextMenuCommandHandlerEvents['error']) { + public exec(...[error, interaction, command]: ContextMenuCommandHandlerEvents['error']) { return ContextCommandErrorListener.handleError(error, interaction, command); } @@ -45,7 +45,7 @@ export default class ContextCommandErrorListener extends BushListener { `contextCommandError`, `an error occurred with the <<${command}>> context command in <<${channel}>> triggered by <<${ interaction?.user?.tag - }>>:\n${util.formatError(error, true)}`, + }>>:\n${formatError(error, true)}`, false ); @@ -92,14 +92,14 @@ export default class ContextCommandErrorListener extends BushListener { haste: string[]; stack: string; }): EmbedBuilder[] { - const embeds = [new EmbedBuilder().setColor(util.colors.error)]; + const embeds = [new EmbedBuilder().setColor(colors.error)]; if (options.type === 'command-user') { embeds[0] .setTitle('An Error Occurred') .setDescription( `Oh no! ${ - options.command ? `While running the command ${util.format.input(options.command.id)}, a` : 'A' - }n error occurred. Please give the developers code ${util.format.input(`${options.errorNum}`)}.` + options.command ? `While running the command ${format.input(options.command.id)}, a` : 'A' + }n error occurred. Please give the developers code ${format.input(`${options.errorNum}`)}.` ) .setTimestamp(); return embeds; @@ -116,11 +116,11 @@ export default class ContextCommandErrorListener extends BushListener { description.push(...options.haste); - embeds.push(new EmbedBuilder().setColor(util.colors.error).setTimestamp().setDescription(options.stack.substring(0, 4000))); + embeds.push(new EmbedBuilder().setColor(colors.error).setTimestamp().setDescription(options.stack.substring(0, 4000))); if (description.length) embeds[0].setDescription(description.join('\n').substring(0, 4000)); if (options.type === 'command-dev' || options.type === 'command-log') - embeds[0].setTitle(`ContextCommandError #${util.format.input(`${options.errorNum}`)}`); + embeds[0].setTitle(`ContextCommandError #${format.input(`${options.errorNum}`)}`); return embeds; } } diff --git a/src/listeners/contextCommands/contextCommandNotFound.ts b/src/listeners/contextCommands/contextCommandNotFound.ts index ca97ad1..65954a2 100644 --- a/src/listeners/contextCommands/contextCommandNotFound.ts +++ b/src/listeners/contextCommands/contextCommandNotFound.ts @@ -10,7 +10,7 @@ export default class ContextCommandNotFoundListener extends BushListener { }); } - public override async exec(...[interaction]: ContextMenuCommandHandlerEvents['notFound']) { + public async exec(...[interaction]: ContextMenuCommandHandlerEvents['notFound']) { void client.console.info('contextCommandNotFound', `<<${interaction?.commandName}>> could not be found.`); } } diff --git a/src/listeners/contextCommands/contextCommandStarted.ts b/src/listeners/contextCommands/contextCommandStarted.ts index 965b8b9..3aab07a 100644 --- a/src/listeners/contextCommands/contextCommandStarted.ts +++ b/src/listeners/contextCommands/contextCommandStarted.ts @@ -11,7 +11,7 @@ export default class ContextCommandStartedListener extends BushListener { }); } - public override async exec(...[interaction, command]: ContextMenuCommandHandlerEvents['started']) { + public async exec(...[interaction, command]: ContextMenuCommandHandlerEvents['started']) { client.sentry.addBreadcrumb({ message: `[contextCommandStarted] The ${command.id} was started by ${interaction.user.tag}.`, level: 'info', diff --git a/src/listeners/guild-custom/bushLockdown.ts b/src/listeners/guild-custom/bushLockdown.ts index 85890cf..930a8d2 100644 --- a/src/listeners/guild-custom/bushLockdown.ts +++ b/src/listeners/guild-custom/bushLockdown.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, type BushClientEvents } from '#lib'; import { EmbedBuilder } from 'discord.js'; export default class BushLockdownListener extends BushListener { @@ -10,12 +10,12 @@ export default class BushLockdownListener extends BushListener { }); } - public override async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushLockdown']) { + public async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushLockdown']) { const logChannel = await moderator.guild.getLogChannel('moderation'); if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Blurple) + .setColor(colors.Blurple) .setTimestamp() .addFields([ { name: '**Action**', value: `${'Lockdown'}` }, @@ -24,7 +24,7 @@ export default class BushLockdownListener extends BushListener { { name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, value: channelsSuccessMap - .map((success, channel) => `<#${channel}> ${success ? util.emojis.success : util.emojis.error}`) + .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) .join('\n') } ]); diff --git a/src/listeners/guild-custom/bushUnlockdown.ts b/src/listeners/guild-custom/bushUnlockdown.ts index 26217d8..b5a4482 100644 --- a/src/listeners/guild-custom/bushUnlockdown.ts +++ b/src/listeners/guild-custom/bushUnlockdown.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, type BushClientEvents } from '#lib'; import { EmbedBuilder } from 'discord.js'; export default class BushUnlockdownListener extends BushListener { @@ -10,12 +10,12 @@ export default class BushUnlockdownListener extends BushListener { }); } - public override async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushUnlockdown']) { + public async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushUnlockdown']) { const logChannel = await moderator.guild.getLogChannel('moderation'); if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Blurple) + .setColor(colors.Blurple) .setTimestamp() .addFields([ { name: '**Action**', value: `${'Unlockdown'}` }, @@ -24,7 +24,7 @@ export default class BushUnlockdownListener extends BushListener { { name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, value: channelsSuccessMap - .map((success, channel) => `<#${channel}> ${success ? util.emojis.success : util.emojis.error}`) + .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) .join('\n') } ]); diff --git a/src/listeners/guild/guildCreate.ts b/src/listeners/guild/guildCreate.ts index 56cd5df..fe23979 100644 --- a/src/listeners/guild/guildCreate.ts +++ b/src/listeners/guild/guildCreate.ts @@ -1,4 +1,4 @@ -import { BushListener, Guild, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, format, getConfigChannel, Guild, type BushClientEvents } from '#lib'; export default class GuildCreateListener extends BushListener { public constructor() { @@ -9,18 +9,18 @@ export default class GuildCreateListener extends BushListener { }); } - public override async exec(...[guild]: BushClientEvents['guildCreate']) { + public async exec(...[guild]: BushClientEvents['guildCreate']) { void client.console.info('guildCreate', `Joined <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.`); const g = await Guild.findByPk(guild.id); if (!g) void Guild.create({ id: guild.id }); - const channel = await util.getConfigChannel('servers'); + const channel = await getConfigChannel('servers'); if (!channel) return; return await channel.send({ embeds: [ { - color: util.colors.Green, - description: `${util.emojis.join} Joined ${util.format.input( + color: colors.Green, + description: `${emojis.join} Joined ${format.input( guild.name )} with **${guild.memberCount?.toLocaleString()}** members. I am now in **${client.guilds.cache.size}** guilds.`, timestamp: new Date().toISOString(), diff --git a/src/listeners/guild/guildDelete.ts b/src/listeners/guild/guildDelete.ts index 054c5e0..5efbe9b 100644 --- a/src/listeners/guild/guildDelete.ts +++ b/src/listeners/guild/guildDelete.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, format, getConfigChannel, type BushClientEvents } from '#lib'; export default class GuildDeleteListener extends BushListener { public constructor() { @@ -9,16 +9,16 @@ export default class GuildDeleteListener extends BushListener { }); } - public override async exec(...[guild]: BushClientEvents['guildDelete']) { + public async exec(...[guild]: BushClientEvents['guildDelete']) { void client.console.info('guildDelete', `Left <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.`); - const channel = await util.getConfigChannel('servers'); + const channel = await getConfigChannel('servers'); if (!channel) return; return await channel.send({ embeds: [ { - color: util.colors.Red, - description: `${util.emojis.leave} Left ${util.format.input( + color: colors.Red, + description: `${emojis.leave} Left ${format.input( guild.name )} with **${guild.memberCount?.toLocaleString()}** members. I am now in **${client.guilds.cache.size}** guilds.`, timestamp: new Date().toISOString(), diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index de1f859..004a2c2 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, format, type BushClientEvents } from '#lib'; import { EmbedBuilder, type GuildMember, type TextChannel } from 'discord.js'; export default class GuildMemberAddListener extends BushListener { @@ -10,7 +10,7 @@ export default class GuildMemberAddListener extends BushListener { }); } - public override async exec(...[member]: BushClientEvents['guildMemberAdd']) { + public async exec(...[member]: BushClientEvents['guildMemberAdd']) { void this.sendWelcomeMessage(member); } @@ -30,24 +30,24 @@ export default class GuildMemberAddListener extends BushListener { const embed = new EmbedBuilder() .setDescription( - `${util.emojis.join} ${util.format.input( + `${emojis.join} ${format.input( member.user.tag )} joined the server. There are now ${member.guild.memberCount.toLocaleString()} members.` ) - .setColor(util.colors.green); + .setColor(colors.green); await welcome .send({ embeds: [embed] }) .then(() => client.console.info( 'guildMemberAdd', - `Sent a message for ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog(member.guild.name)}.` + `Sent a message for ${format.inputLog(member.user.tag)} in ${format.inputLog(member.guild.name)}.` ) ) .catch(() => welcome.guild.error( 'Welcome Message', - `Failed to send message for ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog(member.guild.name)}.` + `Failed to send message for ${format.inputLog(member.user.tag)} in ${format.inputLog(member.guild.name)}.` ) ); } diff --git a/src/listeners/guild/guildMemberRemove.ts b/src/listeners/guild/guildMemberRemove.ts index 59f8800..80e9ee8 100644 --- a/src/listeners/guild/guildMemberRemove.ts +++ b/src/listeners/guild/guildMemberRemove.ts @@ -1,4 +1,4 @@ -import { BushListener, StickyRole, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, format, sleep, StickyRole, Time, type BushClientEvents } from '#lib'; import { EmbedBuilder, type GuildMember, type PartialGuildMember, type TextChannel } from 'discord.js'; export default class GuildMemberRemoveListener extends BushListener { @@ -10,7 +10,7 @@ export default class GuildMemberRemoveListener extends BushListener { }); } - public override async exec(...[member]: BushClientEvents['guildMemberRemove']) { + public async exec(...[member]: BushClientEvents['guildMemberRemove']) { void this.sendWelcomeMessage(member); void this.stickyRoles(member); } @@ -18,7 +18,7 @@ export default class GuildMemberRemoveListener extends BushListener { private async sendWelcomeMessage(member: GuildMember | PartialGuildMember) { if (client.config.isDevelopment) return; const user = member.partial ? await client.users.fetch(member.id) : member.user; - await util.sleep(50 * Time.Millisecond); // ban usually triggers after member leave + await sleep(50 * Time.Millisecond); // ban usually triggers after member leave const isBan = member.guild.bans.cache.has(member.id); const welcomeChannel = await member.guild.getSetting('welcomeChannel'); if (!welcomeChannel) return; @@ -26,23 +26,23 @@ export default class GuildMemberRemoveListener extends BushListener { if (member.guild.id !== welcome?.guild.id) throw new Error('Welcome channel must be in the guild.'); const embed: EmbedBuilder = new EmbedBuilder() .setDescription( - `${util.emojis.leave} ${util.format.input(user.tag)} ${ + `${emojis.leave} ${format.input(user.tag)} ${ isBan ? 'got banned from' : 'left' } the server. There are now ${welcome.guild.memberCount.toLocaleString()} members.` ) - .setColor(isBan ? util.colors.orange : util.colors.red); + .setColor(isBan ? colors.orange : colors.red); welcome .send({ embeds: [embed] }) .then(() => client.console.info( 'guildMemberRemove', - `Sent a message for ${util.format.inputLog(user.tag)} in ${util.format.inputLog(member.guild.name)}.` + `Sent a message for ${format.inputLog(user.tag)} in ${format.inputLog(member.guild.name)}.` ) ) .catch(() => member.guild.error( 'Welcome Message Error', - `Failed to send message for ${util.format.input(user.tag)} in ${util.format.input(member.guild.name)}.` + `Failed to send message for ${format.input(user.tag)} in ${format.input(member.guild.name)}.` ) ); } @@ -74,7 +74,7 @@ export default class GuildMemberRemoveListener extends BushListener { .then(() => client.console.info( 'guildMemberRemove', - `${isNew ? 'Created' : 'Updated'} info for ${util.format.inputLog(member.user.tag)}.` + `${isNew ? 'Created' : 'Updated'} info for ${format.inputLog(member.user.tag)}.` ) ); } diff --git a/src/listeners/guild/joinRoles.ts b/src/listeners/guild/joinRoles.ts index dab623f..f2922c8 100644 --- a/src/listeners/guild/joinRoles.ts +++ b/src/listeners/guild/joinRoles.ts @@ -1,4 +1,4 @@ -import { BushListener, StickyRole, type BushClientEvents } from '#lib'; +import { BushListener, colors, format, StickyRole, type BushClientEvents } from '#lib'; import { type GuildMember, type Snowflake } from 'discord.js'; export default class JoinRolesListener extends BushListener { @@ -10,7 +10,7 @@ export default class JoinRolesListener extends BushListener { }); } - public override async exec(...[oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { if (client.config.isDevelopment) return; if (oldMember.pending && !newMember.pending) { const feat = { @@ -58,8 +58,8 @@ export default class JoinRolesListener extends BushListener { embeds: [ { title: 'Sticky Roles Error', - description: `There was an error returning ${util.format.input(member.user.tag)}'s roles.`, - color: util.colors.error + description: `There was an error returning ${format.input(member.user.tag)}'s roles.`, + color: colors.error } ] }); @@ -68,7 +68,7 @@ export default class JoinRolesListener extends BushListener { if (addedRoles) { void client.console.info( 'guildMemberAdd', - `Assigned sticky roles to ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog(member.guild.name)}.` + `Assigned sticky roles to ${format.inputLog(member.user.tag)} in ${format.inputLog(member.guild.name)}.` ); } else if (!addedRoles) { const failedRoles: string[] = []; @@ -82,9 +82,7 @@ export default class JoinRolesListener extends BushListener { } else { void client.console.info( 'guildMemberAdd', - `[Fallback] Assigned sticky roles to ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog( - member.guild.name - )}.` + `[Fallback] Assigned sticky roles to ${format.inputLog(member.user.tag)} in ${format.inputLog(member.guild.name)}.` ); } } @@ -106,13 +104,13 @@ export default class JoinRolesListener extends BushListener { .then(() => client.console.info( 'guildMemberAdd', - `Assigned join roles to ${util.format.inputLog(member.user.tag)} in ${util.format.inputLog(member.guild.name)}.` + `Assigned join roles to ${format.inputLog(member.user.tag)} in ${format.inputLog(member.guild.name)}.` ) ) .catch(() => member.guild.error( 'Join Roles Error', - `Failed to assign join roles to ${util.format.input(member.user.tag)}, in ${util.format.input(member.guild.name)}.` + `Failed to assign join roles to ${format.input(member.user.tag)}, in ${format.input(member.guild.name)}.` ) ); } diff --git a/src/listeners/guild/syncUnbanPunishmentModel.ts b/src/listeners/guild/syncUnbanPunishmentModel.ts index 44f5bb4..80a8ce2 100644 --- a/src/listeners/guild/syncUnbanPunishmentModel.ts +++ b/src/listeners/guild/syncUnbanPunishmentModel.ts @@ -9,7 +9,7 @@ export default class SyncUnbanListener extends BushListener { }); } - public override async exec(...[ban]: BushClientEvents['guildBanRemove']) { + public async exec(...[ban]: BushClientEvents['guildBanRemove']) { const bans = await ActivePunishment.findAll({ where: { user: ban.user.id, diff --git a/src/listeners/interaction/interactionCreate.ts b/src/listeners/interaction/interactionCreate.ts index 48a2149..6c421d1 100644 --- a/src/listeners/interaction/interactionCreate.ts +++ b/src/listeners/interaction/interactionCreate.ts @@ -1,4 +1,4 @@ -import { AutoMod, BushListener, type BushClientEvents } from '#lib'; +import { AutoMod, BushListener, emojis, format, oxford, surroundArray, type BushClientEvents } from '#lib'; import { InteractionType } from 'discord.js'; export default class InteractionCreateListener extends BushListener { @@ -10,7 +10,7 @@ export default class InteractionCreateListener extends BushListener { }); } - public override async exec(...[interaction]: BushClientEvents['interactionCreate']) { + public async exec(...[interaction]: BushClientEvents['interactionCreate']) { if (!interaction) return; if ('customId' in interaction && (interaction as any)['customId'].startsWith('test')) return; void client.console.verbose( @@ -26,31 +26,31 @@ export default class InteractionCreateListener extends BushListener { else if (id.startsWith('button-role;') && interaction.inCachedGuild()) { const [, roleId] = id.split(';'); const role = interaction.guild.roles.cache.get(roleId); - if (!role) return interaction.reply({ content: `${util.emojis.error} That role does not exist.`, ephemeral: true }); + if (!role) return interaction.reply({ content: `${emojis.error} That role does not exist.`, ephemeral: true }); const has = interaction.member.roles.cache.has(roleId); await interaction.deferReply({ ephemeral: true }); if (has) { const success = await interaction.member.roles.remove(roleId).catch(() => false); if (success) return interaction.editReply({ - content: `${util.emojis.success} Removed the ${role} role from you.`, + content: `${emojis.success} Removed the ${role} role from you.`, allowedMentions: {} }); else return interaction.editReply({ - content: `${util.emojis.error} Failed to remove ${role} from you.`, + content: `${emojis.error} Failed to remove ${role} from you.`, allowedMentions: {} }); } else { const success = await interaction.member.roles.add(roleId).catch(() => false); if (success) return interaction.editReply({ - content: `${util.emojis.success} Added the ${role} role to you.`, + content: `${emojis.success} Added the ${role} role to you.`, allowedMentions: {} }); else return interaction.editReply({ - content: `${util.emojis.error} Failed to add ${role} to you.`, + content: `${emojis.error} Failed to add ${role} to you.`, allowedMentions: {} }); } @@ -60,8 +60,8 @@ export default class InteractionCreateListener extends BushListener { return await interaction.reply({ content: `You selected ${ Array.isArray(interaction.values) - ? util.oxford(util.surroundArray(interaction.values, '`'), 'and', '') - : util.format.input(interaction.values) + ? oxford(surroundArray(interaction.values, '`'), 'and', '') + : format.input(interaction.values) }.`, ephemeral: true }); diff --git a/src/listeners/member-custom/bushBan.ts b/src/listeners/member-custom/bushBan.ts index 1727433..32610ea 100644 --- a/src/listeners/member-custom/bushBan.ts +++ b/src/listeners/member-custom/bushBan.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushBanListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushBanListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushBan']) { + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushBan']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -26,7 +26,7 @@ export default class BushBanListener extends BushListener { { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } ]); - if (duration) logEmbed.addFields([{ name: '**Duration**', value: util.humanizeDuration(duration) }]); + if (duration) logEmbed.addFields([{ name: '**Duration**', value: humanizeDuration(duration) }]); if (dmSuccess === false) logEmbed.addFields([{ name: '**Additional Info**', value: 'Could not dm user.' }]); return await logChannel.send({ embeds: [logEmbed] }); } diff --git a/src/listeners/member-custom/bushBlock.ts b/src/listeners/member-custom/bushBlock.ts index 7cc33d2..6d15a2b 100644 --- a/src/listeners/member-custom/bushBlock.ts +++ b/src/listeners/member-custom/bushBlock.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushBlockListener extends BushListener { @@ -10,15 +10,13 @@ export default class BushBlockListener extends BushListener { }); } - public override async exec( - ...[victim, moderator, guild, reason, caseID, duration, dmSuccess, channel]: BushClientEvents['bushBlock'] - ) { + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess, channel]: BushClientEvents['bushBlock']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Purple) + .setColor(colors.Purple) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -30,7 +28,7 @@ export default class BushBlockListener extends BushListener { { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } ]); - if (duration) logEmbed.addFields([{ name: '**Duration**', value: `${util.humanizeDuration(duration) || duration}` }]); + if (duration) logEmbed.addFields([{ name: '**Duration**', value: `${humanizeDuration(duration) || duration}` }]); if (dmSuccess === false) logEmbed.addFields([{ name: '**Additional Info**', value: 'Could not dm user.' }]); return await logChannel.send({ embeds: [logEmbed] }); } diff --git a/src/listeners/member-custom/bushKick.ts b/src/listeners/member-custom/bushKick.ts index 1be7bf9..65a6942 100644 --- a/src/listeners/member-custom/bushKick.ts +++ b/src/listeners/member-custom/bushKick.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushKickListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushKickListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushKick']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushKick']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushLevelUpdate.ts b/src/listeners/member-custom/bushLevelUpdate.ts index 2a7b75b..a9c0820 100644 --- a/src/listeners/member-custom/bushLevelUpdate.ts +++ b/src/listeners/member-custom/bushLevelUpdate.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, format, type BushClientEvents } from '#lib'; import assert from 'assert'; import { type TextChannel } from 'discord.js'; @@ -13,7 +13,7 @@ export default class BushLevelUpdateListener extends BushListener { }); } - public override async exec(...[member, _oldLevel, newLevel, _currentXp, message]: Args) { + public async exec(...[member, _oldLevel, newLevel, _currentXp, message]: Args) { void this.sendLevelUpMessages(member, newLevel, message); void this.assignLevelRoles(member, newLevel, message); } @@ -27,7 +27,7 @@ export default class BushLevelUpdateListener extends BushListener { .catch(() => null)) ?? message.channel) as TextChannel; const success = await channel - .send(`${util.format.input(member.user.tag)} leveled up to level ${util.format.input(`${newLevel}`)}.`) + .send(`${format.input(member.user.tag)} leveled up to level ${format.input(`${newLevel}`)}.`) .catch(() => null); if (!success) diff --git a/src/listeners/member-custom/bushMute.ts b/src/listeners/member-custom/bushMute.ts index a0aa37d..77ea74c 100644 --- a/src/listeners/member-custom/bushMute.ts +++ b/src/listeners/member-custom/bushMute.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushMuteListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushMuteListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushMute']) { + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushMute']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Orange) + .setColor(colors.Orange) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -26,7 +26,7 @@ export default class BushMuteListener extends BushListener { { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } ]); - if (duration) logEmbed.addFields([{ name: '**Duration**', value: `${util.humanizeDuration(duration) || duration}` }]); + if (duration) logEmbed.addFields([{ name: '**Duration**', value: `${humanizeDuration(duration) || duration}` }]); if (dmSuccess === false) logEmbed.addFields([{ name: '**Additional Info**', value: 'Could not dm user.' }]); return await logChannel.send({ embeds: [logEmbed] }); } diff --git a/src/listeners/member-custom/bushPunishRole.ts b/src/listeners/member-custom/bushPunishRole.ts index 5604bac..2e5b17b 100644 --- a/src/listeners/member-custom/bushPunishRole.ts +++ b/src/listeners/member-custom/bushPunishRole.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushPunishRoleListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushPunishRoleListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, duration]: BushClientEvents['bushPunishRole']) { + public async exec(...[victim, moderator, guild, reason, caseID, duration]: BushClientEvents['bushPunishRole']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Yellow) + .setColor(colors.Yellow) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -26,7 +26,7 @@ export default class BushPunishRoleListener extends BushListener { { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } ]); - if (duration) logEmbed.addFields([{ name: '**Duration**', value: util.humanizeDuration(duration) }]); + if (duration) logEmbed.addFields([{ name: '**Duration**', value: humanizeDuration(duration) }]); return await logChannel.send({ embeds: [logEmbed] }); } } diff --git a/src/listeners/member-custom/bushPunishRoleRemove.ts b/src/listeners/member-custom/bushPunishRoleRemove.ts index 1a13de0..7bc9863 100644 --- a/src/listeners/member-custom/bushPunishRoleRemove.ts +++ b/src/listeners/member-custom/bushPunishRoleRemove.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushPunishRoleRemoveListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushPunishRoleRemoveListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, role]: BushClientEvents['bushPunishRoleRemove']) { + public async exec(...[victim, moderator, guild, reason, caseID, role]: BushClientEvents['bushPunishRoleRemove']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Green) + .setColor(colors.Green) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushPurge.ts b/src/listeners/member-custom/bushPurge.ts index 3334bad..ea30bc5 100644 --- a/src/listeners/member-custom/bushPurge.ts +++ b/src/listeners/member-custom/bushPurge.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, emojis, inspectCleanRedactHaste, type BushClientEvents } from '#lib'; import { EmbedBuilder } from 'discord.js'; export default class BushPurgeListener extends BushListener { @@ -10,7 +10,7 @@ export default class BushPurgeListener extends BushListener { }); } - public override async exec(...[moderator, guild, channel, messages]: BushClientEvents['bushPurge']) { + public async exec(...[moderator, guild, channel, messages]: BushClientEvents['bushPurge']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; @@ -21,10 +21,10 @@ export default class BushPurgeListener extends BushListener { embeds: m.embeds, attachments: [...m.attachments.values()] })); - const haste = await util.inspectCleanRedactHaste(mappedMessages); + const haste = await inspectCleanRedactHaste(mappedMessages); const logEmbed = new EmbedBuilder() - .setColor(util.colors.DarkPurple) + .setColor(colors.DarkPurple) .setTimestamp() .setFooter({ text: `${messages.size.toLocaleString()} Messages` }) .setAuthor({ name: moderator.tag, iconURL: moderator.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -35,7 +35,7 @@ export default class BushPurgeListener extends BushListener { { name: '**Messages**', value: `${ - haste.url ? `[haste](${haste.url})${haste.error ? `- ${haste.error}` : ''}` : `${util.emojis.error} ${haste.error}` + haste.url ? `[haste](${haste.url})${haste.error ? `- ${haste.error}` : ''}` : `${emojis.error} ${haste.error}` }` } ]); diff --git a/src/listeners/member-custom/bushRemoveTimeout.ts b/src/listeners/member-custom/bushRemoveTimeout.ts index aafa11e..742d407 100644 --- a/src/listeners/member-custom/bushRemoveTimeout.ts +++ b/src/listeners/member-custom/bushRemoveTimeout.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushRemoveTimeoutListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushRemoveTimeoutListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushRemoveTimeout']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushRemoveTimeout']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Green) + .setColor(colors.Green) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushTimeout.ts b/src/listeners/member-custom/bushTimeout.ts index 07a7105..4621921 100644 --- a/src/listeners/member-custom/bushTimeout.ts +++ b/src/listeners/member-custom/bushTimeout.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushTimeoutListener extends BushListener { @@ -10,15 +10,13 @@ export default class BushTimeoutListener extends BushListener { }); } - public override async exec( - ...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushTimeout'] - ) { + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BushClientEvents['bushTimeout']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Orange) + .setColor(colors.Orange) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) @@ -27,7 +25,7 @@ export default class BushTimeoutListener extends BushListener { { name: '**User**', value: `${user} (${user.tag})` }, { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, - { name: '**Duration**', value: `${util.humanizeDuration(duration) || duration}` } + { name: '**Duration**', value: `${humanizeDuration(duration) || duration}` } ]); if (dmSuccess === false) logEmbed.addFields([{ name: '**Additional Info**', value: 'Could not dm user.' }]); return await logChannel.send({ embeds: [logEmbed] }); diff --git a/src/listeners/member-custom/bushUnban.ts b/src/listeners/member-custom/bushUnban.ts index 2628d36..463ce6c 100644 --- a/src/listeners/member-custom/bushUnban.ts +++ b/src/listeners/member-custom/bushUnban.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushUnbanListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushUnbanListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushUnban']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushUnban']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Green) + .setColor(colors.Green) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushUnblock.ts b/src/listeners/member-custom/bushUnblock.ts index 238c5b5..43b7b2b 100644 --- a/src/listeners/member-custom/bushUnblock.ts +++ b/src/listeners/member-custom/bushUnblock.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushUnblockListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushUnblockListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess, channel]: BushClientEvents['bushUnblock']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess, channel]: BushClientEvents['bushUnblock']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Green) + .setColor(colors.Green) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushUnmute.ts b/src/listeners/member-custom/bushUnmute.ts index e7f6793..614a826 100644 --- a/src/listeners/member-custom/bushUnmute.ts +++ b/src/listeners/member-custom/bushUnmute.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushUnmuteListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushUnmuteListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushUnmute']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushUnmute']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Green) + .setColor(colors.Green) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/bushUpdateModlog.ts b/src/listeners/member-custom/bushUpdateModlog.ts index f49defe..5e29b9a 100644 --- a/src/listeners/member-custom/bushUpdateModlog.ts +++ b/src/listeners/member-custom/bushUpdateModlog.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, inspectCleanRedactCodeblock, type BushClientEvents } from '#lib'; import { EmbedBuilder } from 'discord.js'; export default class BushUpdateModlogListener extends BushListener { @@ -10,12 +10,12 @@ export default class BushUpdateModlogListener extends BushListener { }); } - public override async exec(...[moderator, modlogID, key, oldModlog, newModlog]: BushClientEvents['bushUpdateModlog']) { + public async exec(...[moderator, modlogID, key, oldModlog, newModlog]: BushClientEvents['bushUpdateModlog']) { const logChannel = await moderator.guild.getLogChannel('moderation'); if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Blurple) + .setColor(colors.Blurple) .setTimestamp() .setAuthor({ name: moderator.user.tag, @@ -26,8 +26,8 @@ export default class BushUpdateModlogListener extends BushListener { { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, { name: '**ModLog Changed**', value: modlogID }, { name: '**Value Changed**', value: key }, - { name: '**Old Value**', value: await util.inspectCleanRedactCodeblock(oldModlog, undefined, undefined, 1024) }, - { name: '**New Value**', value: await util.inspectCleanRedactCodeblock(newModlog, undefined, undefined, 1024) } + { name: '**Old Value**', value: await inspectCleanRedactCodeblock(oldModlog, undefined, undefined, 1024) }, + { name: '**New Value**', value: await inspectCleanRedactCodeblock(newModlog, undefined, undefined, 1024) } ]); return await logChannel.send({ embeds: [logEmbed] }); diff --git a/src/listeners/member-custom/bushUpdateSettings.ts b/src/listeners/member-custom/bushUpdateSettings.ts index 948bbe7..e367c4e 100644 --- a/src/listeners/member-custom/bushUpdateSettings.ts +++ b/src/listeners/member-custom/bushUpdateSettings.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, inspectCleanRedactCodeblock, type BushClientEvents } from '#lib'; import { EmbedBuilder } from 'discord.js'; export default class BushUpdateSettingsListener extends BushListener { @@ -10,11 +10,11 @@ export default class BushUpdateSettingsListener extends BushListener { }); } - public override async exec(...[setting, guild, oldSettings, newSettings, moderator]: BushClientEvents['bushUpdateSettings']) { + public async exec(...[setting, guild, oldSettings, newSettings, moderator]: BushClientEvents['bushUpdateSettings']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; - const logEmbed = new EmbedBuilder().setColor(util.colors.Blurple).setTimestamp(); + const logEmbed = new EmbedBuilder().setColor(colors.Blurple).setTimestamp(); if (moderator) logEmbed.setAuthor({ @@ -25,8 +25,8 @@ export default class BushUpdateSettingsListener extends BushListener { if (moderator) logEmbed.addFields([{ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }]); logEmbed.addFields([ { name: '**Setting Changed**', value: setting }, - { name: '**Old Value**', value: await util.inspectCleanRedactCodeblock(oldSettings, 'js', undefined, 1024) }, - { name: '**New Value**', value: await util.inspectCleanRedactCodeblock(newSettings, 'js', undefined, 1024) } + { name: '**Old Value**', value: await inspectCleanRedactCodeblock(oldSettings, 'js', undefined, 1024) }, + { name: '**New Value**', value: await inspectCleanRedactCodeblock(newSettings, 'js', undefined, 1024) } ]); return await logChannel.send({ embeds: [logEmbed] }); diff --git a/src/listeners/member-custom/bushWarn.ts b/src/listeners/member-custom/bushWarn.ts index ede56fd..b9c1868 100644 --- a/src/listeners/member-custom/bushWarn.ts +++ b/src/listeners/member-custom/bushWarn.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, type BushClientEvents } from '#lib'; import { EmbedBuilder, GuildMember } from 'discord.js'; export default class BushWarnListener extends BushListener { @@ -10,13 +10,13 @@ export default class BushWarnListener extends BushListener { }); } - public override async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushWarn']) { + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BushClientEvents['bushWarn']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const user = victim instanceof GuildMember ? victim.user : victim; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Yellow) + .setColor(colors.Yellow) .setTimestamp() .setFooter({ text: `CaseID: ${caseID}` }) .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) diff --git a/src/listeners/member-custom/massBan.ts b/src/listeners/member-custom/massBan.ts index 29f7ce3..ca41f29 100644 --- a/src/listeners/member-custom/massBan.ts +++ b/src/listeners/member-custom/massBan.ts @@ -1,4 +1,4 @@ -import { BanResponse, banResponse, BushListener, type BushClientEvents } from '#lib'; +import { BanResponse, banResponse, BushListener, colors, emojis, overflowEmbed, type BushClientEvents } from '#lib'; export default class MassBanListener extends BushListener { public constructor() { @@ -9,20 +9,19 @@ export default class MassBanListener extends BushListener { }); } - public override async exec(...[moderator, guild, reason, results]: BushClientEvents['massBan']) { + public async exec(...[moderator, guild, reason, results]: BushClientEvents['massBan']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; const success = (res: BanResponse): boolean => [banResponse.SUCCESS, banResponse.DM_ERROR].includes(res as any); const lines = results.map( - (reason, user) => - `${success(reason) ? util.emojis.success : util.emojis.error} ${user}${success(reason) ? '' : ` - ${reason}`}` + (reason, user) => `${success(reason) ? emojis.success : emojis.error} ${user}${success(reason) ? '' : ` - ${reason}`}` ); - const embeds = util.overflowEmbed( + const embeds = overflowEmbed( { - color: util.colors.DarkRed, + color: colors.DarkRed, title: 'Mass Ban', timestamp: new Date().toISOString(), fields: [ diff --git a/src/listeners/member-custom/massEvidence.ts b/src/listeners/member-custom/massEvidence.ts index 4a45ee7..f0f75df 100644 --- a/src/listeners/member-custom/massEvidence.ts +++ b/src/listeners/member-custom/massEvidence.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, overflowEmbed, type BushClientEvents } from '#lib'; export default class MassEvidenceListener extends BushListener { public constructor() { @@ -9,13 +9,13 @@ export default class MassEvidenceListener extends BushListener { }); } - public override async exec(...[moderator, guild, evidence, lines]: BushClientEvents['massEvidence']) { + public async exec(...[moderator, guild, evidence, lines]: BushClientEvents['massEvidence']) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; - const embeds = util.overflowEmbed( + const embeds = overflowEmbed( { - color: util.colors.DarkRed, + color: colors.DarkRed, title: 'Mass Evidence', timestamp: new Date().toISOString(), fields: [ diff --git a/src/listeners/message/autoPublisher.ts b/src/listeners/message/autoPublisher.ts index 8f3462f..c669930 100644 --- a/src/listeners/message/autoPublisher.ts +++ b/src/listeners/message/autoPublisher.ts @@ -10,7 +10,7 @@ export default class autoPublisherListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (!message.guild || !(await message.guild.hasFeature('autoPublish'))) return; const autoPublishChannels = await message.guild.getSetting('autoPublishChannels'); if (autoPublishChannels) { diff --git a/src/listeners/message/automodCreate.ts b/src/listeners/message/automodCreate.ts index 8824c72..0f089a3 100644 --- a/src/listeners/message/automodCreate.ts +++ b/src/listeners/message/automodCreate.ts @@ -9,7 +9,7 @@ export default class AutomodMessageCreateListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { return new AutoMod(message); } } diff --git a/src/listeners/message/automodUpdate.ts b/src/listeners/message/automodUpdate.ts index d2e6f40..fa00f92 100644 --- a/src/listeners/message/automodUpdate.ts +++ b/src/listeners/message/automodUpdate.ts @@ -9,7 +9,7 @@ export default class AutomodMessageUpdateListener extends BushListener { }); } - public override async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { + public async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { const fullMessage = newMessage.partial ? await newMessage.fetch().catch(() => null) : newMessage; if (!fullMessage) return; return new AutoMod(fullMessage); diff --git a/src/listeners/message/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts index 122f289..15d97e3 100644 --- a/src/listeners/message/blacklistedFile.ts +++ b/src/listeners/message/blacklistedFile.ts @@ -65,7 +65,7 @@ export default class BlacklistedFileListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (!message.guild || !(await message.guild.hasFeature('blacklistedFile'))) return; // const embedAttachments = message.embeds.filter((e) => ['image', 'video', 'gifv'].includes(e.type)); const foundEmojis = [...message.content.matchAll(/<(?<animated>a?):\w+:(?<id>\d+)>/g)]; diff --git a/src/listeners/message/boosterMessage.ts b/src/listeners/message/boosterMessage.ts index 989f671..e33abfb 100644 --- a/src/listeners/message/boosterMessage.ts +++ b/src/listeners/message/boosterMessage.ts @@ -10,7 +10,7 @@ export default class BoosterMessageListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (!message.guild || !(await message.guild?.hasFeature('boosterMessageReact'))) return; if (message.type === MessageType.UserPremiumGuildSubscription) { return await message.react('<:nitroboost:785160348885975062>').catch(() => { diff --git a/src/listeners/message/directMessage.ts b/src/listeners/message/directMessage.ts index 87480b0..463e4d8 100644 --- a/src/listeners/message/directMessage.ts +++ b/src/listeners/message/directMessage.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, colors, getConfigChannel, type BushClientEvents } from '#lib'; import { ChannelType, EmbedBuilder } from 'discord.js'; export default class DirectMessageListener extends BushListener { @@ -10,7 +10,7 @@ export default class DirectMessageListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (message.channel.type === ChannelType.DM) { if (!(message.author.id == client.user!.id) && message.author.bot) return; if (client.cache.global.blacklistedUsers.includes(message.author.id)) return; @@ -23,7 +23,7 @@ export default class DirectMessageListener extends BushListener { iconURL: `${message.author.displayAvatarURL()}` }) .setDescription(`**DM:**\n${message}`) - .setColor(util.colors.blue); + .setColor(colors.blue); } else { dmLogEmbed .setAuthor({ @@ -31,7 +31,7 @@ export default class DirectMessageListener extends BushListener { iconURL: `${message.channel.recipient?.displayAvatarURL()}` }) .setDescription(`**DM:**\n${message}`) - .setColor(util.colors.red) + .setColor(colors.red) .setTimestamp(); } if (message.attachments.filter((a) => typeof a.size == 'number').size == 1) { @@ -39,7 +39,7 @@ export default class DirectMessageListener extends BushListener { } else if (message.attachments.size > 0) { dmLogEmbed.addFields([{ name: 'Attachments', value: message.attachments.map((a) => a.proxyURL).join('\n') }]); } - const dmChannel = await util.getConfigChannel('dm'); + const dmChannel = await getConfigChannel('dm'); await dmChannel.send({ embeds: [dmLogEmbed] }); } } diff --git a/src/listeners/message/highlight.ts b/src/listeners/message/highlight.ts index d7965c5..d68337c 100644 --- a/src/listeners/message/highlight.ts +++ b/src/listeners/message/highlight.ts @@ -9,7 +9,7 @@ export default class HighlightListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (!message.inGuild()) return; if (message.author.bot || message.system) return; if (!(await message.guild.hasFeature('highlight'))) return; // allows highlighting to be disabled on a guild-by-guild basis diff --git a/src/listeners/message/level.ts b/src/listeners/message/level.ts index 08a8a7c..a72ae02 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -1,4 +1,4 @@ -import { BushListener, Level, type BushCommandHandlerEvents } from '#lib'; +import { BushListener, handleError, Level, type BushCommandHandlerEvents } from '#lib'; import { MessageType } from 'discord.js'; export default class LevelListener extends BushListener { @@ -11,7 +11,7 @@ export default class LevelListener extends BushListener { }); } - public override async exec(...[message]: BushCommandHandlerEvents['messageInvalid']) { + public async exec(...[message]: BushCommandHandlerEvents['messageInvalid']) { if (message.author.bot || !message.author || !message.inGuild()) return; if (!(await message.guild.hasFeature('leveling'))) return; if (this.#levelCooldowns.has(`${message.guildId}-${message.author.id}`)) return; @@ -33,7 +33,7 @@ export default class LevelListener extends BushListener { const xpToGive = Level.genRandomizedXp(); user.xp = user.xp + xpToGive; const success = await user.save().catch((e) => { - void util.handleError('level', e); + void handleError('level', e); return false; }); const newLevel = Level.convertXpToLevel(user.xp); diff --git a/src/listeners/message/quoteCreate.ts b/src/listeners/message/quoteCreate.ts index 0d8b464..d43eef7 100644 --- a/src/listeners/message/quoteCreate.ts +++ b/src/listeners/message/quoteCreate.ts @@ -1,4 +1,4 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BushListener, resolveMessagesFromLinks, type BushClientEvents } from '#lib'; export default class QuoteCreateListener extends BushListener { public constructor() { @@ -9,11 +9,11 @@ export default class QuoteCreateListener extends BushListener { }); } - public override async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BushClientEvents['messageCreate']) { if (message.author.id !== '322862723090219008' || !client.config.isProduction) return; if (!message.inGuild()) return; - const messages = await util.resolveMessagesFromLinks(message.content); + const messages = await resolveMessagesFromLinks(message.content); if (!messages.length) return; for (const msg of messages) { diff --git a/src/listeners/message/quoteEdit.ts b/src/listeners/message/quoteEdit.ts index 790f05a..7da0d95 100644 --- a/src/listeners/message/quoteEdit.ts +++ b/src/listeners/message/quoteEdit.ts @@ -9,7 +9,7 @@ // }); // } -// public override async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { +// public async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { // return; // // if (newMessage.partial) newMessage = await newMessage.fetch(); // // return new QuoteCreateListener().exec(newMessage); diff --git a/src/listeners/message/verbose.ts b/src/listeners/message/verbose.ts index 1225412..e3ef04f 100644 --- a/src/listeners/message/verbose.ts +++ b/src/listeners/message/verbose.ts @@ -10,7 +10,7 @@ export default class MessageVerboseListener extends BushListener { }); } - public override exec(...[message]: BushClientEvents['messageCreate']): void { + public exec(...[message]: BushClientEvents['messageCreate']): void { if (client.customReady) { if (message.channel?.type === ChannelType.DM) return; void client.console.verbose( diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts index 0c30724..543f459 100644 --- a/src/listeners/other/consoleListener.ts +++ b/src/listeners/other/consoleListener.ts @@ -11,7 +11,7 @@ import { promisify } from 'util'; }); } - public override async exec(line: string) { + public async exec(line: string) { if (line.startsWith('eval ') || line.startsWith('ev ')) { /* eslint-disable @typescript-eslint/no-unused-vars */ const sh = promisify(exec), @@ -32,7 +32,6 @@ import { promisify } from 'util'; Embed, SelectMenuComponent, ReactionCollector, - Util, Collection } = await import('discord.js'); /* eslint-enable @typescript-eslint/no-unused-vars */ diff --git a/src/listeners/other/exit.ts b/src/listeners/other/exit.ts index 26ed36f..e16aeb7 100644 --- a/src/listeners/other/exit.ts +++ b/src/listeners/other/exit.ts @@ -8,7 +8,7 @@ export default class ExitListener extends BushListener { }); } - public override async exec(code: number) { + public async exec(code: number) { await client.console.error('processExit', `Process ended with code <<${code}>>.`); } } diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index ad82469..79bf5de 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -1,4 +1,4 @@ -import { BushListener } from '#lib'; +import { BushListener, formatError } from '#lib'; import CommandErrorListener from '../commands/commandError.js'; export default class PromiseRejectionListener extends BushListener { @@ -10,7 +10,7 @@ export default class PromiseRejectionListener extends BushListener { }); } - public override async exec(error: Error) { + public async exec(error: Error) { process.listeners('unhandledRejection').forEach((listener) => { if (listener.toString() === this.exec.toString()) return; process.removeListener('unhandledRejection', listener); @@ -20,11 +20,7 @@ export default class PromiseRejectionListener extends BushListener { level: 'error' }); - void client.console.error( - 'promiseRejection', - `An unhanded promise rejection occurred:\n${util.formatError(error, true)}`, - false - ); + void client.console.error('promiseRejection', `An unhanded promise rejection occurred:\n${formatError(error, true)}`, false); if (!error.message.includes('reason: getaddrinfo ENOTFOUND canary.discord.com')) void client.console.channelError({ embeds: await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error }) diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index 8eb326f..3e80feb 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -1,4 +1,4 @@ -import { BushListener } from '#lib'; +import { BushListener, formatError } from '#lib'; import CommandErrorListener from '../commands/commandError.js'; export default class UncaughtExceptionListener extends BushListener { @@ -10,7 +10,7 @@ export default class UncaughtExceptionListener extends BushListener { }); } - public override async exec(error: Error) { + public async exec(error: Error) { process.listeners('uncaughtException').forEach((listener) => { if (listener.toString() === this.exec.toString()) return; process.removeListener('uncaughtException', listener); @@ -19,7 +19,7 @@ export default class UncaughtExceptionListener extends BushListener { level: 'error' }); - void client.console.error('uncaughtException', `An uncaught exception occurred:\n${util.formatError(error, true)}`, false); + void client.console.error('uncaughtException', `An uncaught exception occurred:\n${formatError(error, true)}`, false); void client.console.channelError({ embeds: await CommandErrorListener.generateErrorEmbed({ type: 'uncaughtException', error: error }) }); diff --git a/src/listeners/other/warning.ts b/src/listeners/other/warning.ts index 800472a..ba38f5f 100644 --- a/src/listeners/other/warning.ts +++ b/src/listeners/other/warning.ts @@ -1,4 +1,4 @@ -import { BushListener } from '#lib'; +import { BushListener, colors, formatError } from '#lib'; import CommandErrorListener from '../commands/commandError.js'; export default class WarningListener extends BushListener { @@ -9,17 +9,17 @@ export default class WarningListener extends BushListener { }); } - public override async exec(error: Error) { + public async exec(error: Error) { if (error.name === 'ExperimentalWarning') return; client.sentry.captureException(error, { level: 'warning' }); - void client.console.warn('warning', `A warning occurred:\n${util.formatError(error, true)}`, false); + void client.console.warn('warning', `A warning occurred:\n${formatError(error, true)}`, false); const embeds = await CommandErrorListener.generateErrorEmbed({ type: 'unhandledRejection', error: error }); - embeds[0].setColor(util.colors.warn).setTitle('A Warning Occurred'); + embeds[0].setColor(colors.warn).setTitle('A Warning Occurred'); void client.console.channelError({ embeds }); } diff --git a/src/listeners/rest/rateLimit.ts b/src/listeners/rest/rateLimit.ts index 4884e9f..5878d81 100644 --- a/src/listeners/rest/rateLimit.ts +++ b/src/listeners/rest/rateLimit.ts @@ -10,7 +10,7 @@ export default class RateLimitedListener extends BushListener { }); } - public override async exec(...[message]: RestEvents['rateLimited']): Promise<void> { + public async exec(...[message]: RestEvents['rateLimited']): Promise<void> { void client.console.superVerboseRaw('rateLimited', message); } } diff --git a/src/listeners/track-manual-punishments/modlogSyncBan.ts b/src/listeners/track-manual-punishments/modlogSyncBan.ts index be937b9..45d6f51 100644 --- a/src/listeners/track-manual-punishments/modlogSyncBan.ts +++ b/src/listeners/track-manual-punishments/modlogSyncBan.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncBanListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncBanListener extends BushListener { }); } - public override async exec(...[ban]: BushClientEvents['guildBanAdd']) { + public async exec(...[ban]: BushClientEvents['guildBanAdd']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.members.me) return; // bot was banned if (!ban.guild.members.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { @@ -21,7 +21,7 @@ export default class ModlogSyncBanListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await ban.guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanAdd })).entries.filter( (entry) => entry.target?.id === ban.user.id @@ -33,9 +33,7 @@ export default class ModlogSyncBanListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -51,7 +49,7 @@ export default class ModlogSyncBanListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncKick.ts b/src/listeners/track-manual-punishments/modlogSyncKick.ts index d136780..d901f5f 100644 --- a/src/listeners/track-manual-punishments/modlogSyncKick.ts +++ b/src/listeners/track-manual-punishments/modlogSyncKick.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncKickListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncKickListener extends BushListener { }); } - public override async exec(...[member]: BushClientEvents['guildMemberRemove']) { + public async exec(...[member]: BushClientEvents['guildMemberRemove']) { if (!(await member.guild.hasFeature('logManualPunishments'))) return; if (!member.guild.members.me) return; // bot was removed from guild if (!member.guild.members.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { @@ -21,7 +21,7 @@ export default class ModlogSyncKickListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await member.guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick })).entries.filter( (entry) => entry.target?.id === member.user.id @@ -33,9 +33,7 @@ export default class ModlogSyncKickListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -51,7 +49,7 @@ export default class ModlogSyncKickListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts index adcd7fe..4619edd 100644 --- a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts +++ b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncTimeoutListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { }); } - public override async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('logManualPunishments'))) return; if (!newMember.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return newMember.guild.error( @@ -20,7 +20,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await newMember.guild.fetchAuditLogs({ type: AuditLogEvent.MemberUpdate })).entries.filter( (entry) => entry.target?.id === newMember.user.id @@ -35,9 +35,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { if (!timeOut) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const newTime = <string | null>timeOut.new ? new Date(<string>timeOut.new) : null; @@ -56,7 +54,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors[newTime ? 'Orange' : 'Green']) + .setColor(colors[newTime ? 'Orange' : 'Green']) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncUnban.ts b/src/listeners/track-manual-punishments/modlogSyncUnban.ts index af0b21f..34979a5 100644 --- a/src/listeners/track-manual-punishments/modlogSyncUnban.ts +++ b/src/listeners/track-manual-punishments/modlogSyncUnban.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncUnbanListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncUnbanListener extends BushListener { }); } - public override async exec(...[ban]: BushClientEvents['guildBanRemove']) { + public async exec(...[ban]: BushClientEvents['guildBanRemove']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return ban.guild.error( @@ -20,7 +20,7 @@ export default class ModlogSyncUnbanListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await ban.guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanRemove })).entries.filter( (entry) => entry.target?.id === ban.user.id @@ -32,9 +32,7 @@ export default class ModlogSyncUnbanListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -50,7 +48,7 @@ export default class ModlogSyncUnbanListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Orange) + .setColor(colors.Orange) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/ws/INTERACTION_CREATE.ts b/src/listeners/ws/INTERACTION_CREATE.ts index 408e7e5..5f479ad 100644 --- a/src/listeners/ws/INTERACTION_CREATE.ts +++ b/src/listeners/ws/INTERACTION_CREATE.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, PunishmentTypePresent } from '#lib'; +import { BushListener, capitalize, colors, emojis, Moderation, PunishmentTypePresent } from '#lib'; import assert from 'assert'; import { ActionRowBuilder, @@ -30,7 +30,7 @@ export default class WsInteractionCreateListener extends BushListener { }); } - public override async exec(interaction: APIInteraction) { + public async exec(interaction: APIInteraction) { // console.dir(interaction); const respond = ( @@ -67,7 +67,7 @@ export default class WsInteractionCreateListener extends BushListener { return respond({ type: InteractionResponseType.ChannelMessageWithSource, data: { - content: `${util.emojis.error} I am no longer in that server.` + content: `${emojis.error} I am no longer in that server.` } }); @@ -75,7 +75,7 @@ export default class WsInteractionCreateListener extends BushListener { type: InteractionResponseType.Modal, data: { custom_id: `appeal_submit;${punishment};${guildId};${userId};${modlogCase}`, - title: `${util.capitalize(punishment)} Appeal`, + title: `${capitalize(punishment)} Appeal`, components: [ { type: ComponentType.ActionRow, @@ -177,7 +177,7 @@ export default class WsInteractionCreateListener extends BushListener { return respond({ type: InteractionResponseType.ChannelMessageWithSource, data: { - content: `${util.emojis.error} I am no longer in that server.` + content: `${emojis.error} I am no longer in that server.` } }); @@ -186,7 +186,7 @@ export default class WsInteractionCreateListener extends BushListener { return respond({ type: InteractionResponseType.ChannelMessageWithSource, data: { - content: `${util.emojis.error} ${guild.name} has misconfigured their appeals channel.` + content: `${emojis.error} ${guild.name} has misconfigured their appeals channel.` } }); @@ -197,8 +197,8 @@ export default class WsInteractionCreateListener extends BushListener { // const caseId = await ModLog.findOne({ where: { user: userId, guild: guildId, id: modlogCase } }); const embed = new EmbedBuilder() - .setTitle(`${util.capitalize(punishment)} Appeal`) - .setColor(util.colors.newBlurple) + .setTitle(`${capitalize(punishment)} Appeal`) + .setColor(colors.newBlurple) .setTimestamp() .setFooter({ text: `CaseID: ${modlogCase}` }) .setAuthor({ name: user.tag, iconURL: user.displayAvatarURL() }) |