From 14eb0e617b084080c4cffc5b781b311c65c5f928 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 28 Aug 2022 21:51:17 -0400 Subject: rebrand v3 --- src/listeners/automod/automodCreate.ts | 9 +- src/listeners/automod/automodUpdate.ts | 9 +- src/listeners/automod/memberAutomod.ts | 6 +- src/listeners/automod/presenceAutomod.ts | 6 +- src/listeners/bush/appealListener.ts | 9 +- src/listeners/bush/joinAutoBan.ts | 11 +- src/listeners/bush/supportThread.ts | 9 +- src/listeners/bush/userUpdateAutoBan.ts | 11 +- src/listeners/client/akairoDebug.ts | 9 +- src/listeners/client/dcjsDebug.ts | 15 --- src/listeners/client/dcjsError.ts | 15 --- src/listeners/client/dcjsWarn.ts | 15 --- src/listeners/client/djsDebug.ts | 14 +++ src/listeners/client/djsError.ts | 14 +++ src/listeners/client/djsWarn.ts | 14 +++ src/listeners/client/ready.ts | 6 +- src/listeners/commands/commandBlocked.ts | 15 ++- src/listeners/commands/commandCooldown.ts | 9 +- src/listeners/commands/commandError.ts | 9 +- src/listeners/commands/commandLocked.ts | 9 +- .../commands/commandMissingPermissions.ts | 13 ++- src/listeners/commands/commandStarted.ts | 9 +- src/listeners/commands/messageBlocked.ts | 9 +- src/listeners/commands/slashBlocked.ts | 9 +- src/listeners/commands/slashCommandError.ts | 9 +- src/listeners/commands/slashMissingPermissions.ts | 9 +- src/listeners/commands/slashNotFound.ts | 9 +- src/listeners/commands/slashStarted.ts | 9 +- .../contextCommands/contextCommandBlocked.ts | 7 +- .../contextCommands/contextCommandError.ts | 7 +- .../contextCommands/contextCommandNotFound.ts | 7 +- .../contextCommands/contextCommandStarted.ts | 7 +- src/listeners/guild-custom/bushLockdown.ts | 33 ------ src/listeners/guild-custom/bushUnlockdown.ts | 33 ------ src/listeners/guild-custom/lockdown.ts | 32 ++++++ src/listeners/guild-custom/unlockdown.ts | 32 ++++++ src/listeners/guild/guildCreate.ts | 9 +- src/listeners/guild/guildDelete.ts | 9 +- src/listeners/guild/guildMemberAdd.ts | 9 +- src/listeners/guild/guildMemberRemove.ts | 9 +- src/listeners/guild/joinRoles.ts | 9 +- src/listeners/guild/syncUnbanPunishmentModel.ts | 9 +- src/listeners/interaction/interactionCreate.ts | 9 +- src/listeners/member-custom/bushBan.ts | 33 ------ src/listeners/member-custom/bushBlock.ts | 35 ------- src/listeners/member-custom/bushKick.ts | 32 ------ src/listeners/member-custom/bushLevelUpdate.ts | 64 ------------ src/listeners/member-custom/bushMute.ts | 33 ------ src/listeners/member-custom/bushPunishRole.ts | 32 ------ .../member-custom/bushPunishRoleRemove.ts | 33 ------ src/listeners/member-custom/bushPurge.ts | 44 -------- src/listeners/member-custom/bushRemoveTimeout.ts | 32 ------ src/listeners/member-custom/bushTimeout.ts | 33 ------ src/listeners/member-custom/bushUnban.ts | 32 ------ src/listeners/member-custom/bushUnblock.ts | 33 ------ src/listeners/member-custom/bushUnmute.ts | 32 ------ src/listeners/member-custom/bushUpdateModlog.ts | 41 -------- src/listeners/member-custom/bushUpdateSettings.ts | 34 ------ src/listeners/member-custom/bushWarn.ts | 32 ------ src/listeners/member-custom/customBan.ts | 32 ++++++ src/listeners/member-custom/customBlock.ts | 36 +++++++ src/listeners/member-custom/customKick.ts | 31 ++++++ src/listeners/member-custom/customMute.ts | 32 ++++++ src/listeners/member-custom/customPurge.ts | 43 ++++++++ src/listeners/member-custom/customRemoveTimeout.ts | 31 ++++++ src/listeners/member-custom/customTimeout.ts | 32 ++++++ src/listeners/member-custom/customUnban.ts | 31 ++++++ src/listeners/member-custom/customUnblock.ts | 32 ++++++ src/listeners/member-custom/customUnmute.ts | 31 ++++++ src/listeners/member-custom/customWarnMember.ts | 31 ++++++ src/listeners/member-custom/levelUpdate.ts | 63 +++++++++++ src/listeners/member-custom/massBan.ts | 11 +- src/listeners/member-custom/massEvidence.ts | 11 +- src/listeners/member-custom/punishRole.ts | 31 ++++++ src/listeners/member-custom/punishRoleRemove.ts | 32 ++++++ src/listeners/member-custom/updateModlog.ts | 40 +++++++ src/listeners/member-custom/updateSettings.ts | 33 ++++++ src/listeners/message/autoPublisher.ts | 9 +- src/listeners/message/blacklistedFile.ts | 7 +- src/listeners/message/boosterMessage.ts | 9 +- src/listeners/message/directMessage.ts | 9 +- src/listeners/message/highlight.ts | 9 +- src/listeners/message/level.ts | 11 +- src/listeners/message/quoteCreate.ts | 9 +- src/listeners/message/quoteEdit.ts | 7 +- src/listeners/message/verbose.ts | 9 +- src/listeners/other/consoleListener.ts | 116 ++++++++++----------- src/listeners/other/exit.ts | 4 +- src/listeners/other/promiseRejection.ts | 4 +- src/listeners/other/uncaughtException.ts | 4 +- src/listeners/other/warning.ts | 4 +- src/listeners/rest/rateLimit.ts | 7 +- .../track-manual-punishments/modlogSyncBan.ts | 9 +- .../track-manual-punishments/modlogSyncKick.ts | 9 +- .../track-manual-punishments/modlogSyncTimeout.ts | 9 +- .../track-manual-punishments/modlogSyncUnban.ts | 9 +- src/listeners/ws/INTERACTION_CREATE.ts | 7 +- 97 files changed, 932 insertions(+), 998 deletions(-) delete mode 100644 src/listeners/client/dcjsDebug.ts delete mode 100644 src/listeners/client/dcjsError.ts delete mode 100644 src/listeners/client/dcjsWarn.ts create mode 100644 src/listeners/client/djsDebug.ts create mode 100644 src/listeners/client/djsError.ts create mode 100644 src/listeners/client/djsWarn.ts delete mode 100644 src/listeners/guild-custom/bushLockdown.ts delete mode 100644 src/listeners/guild-custom/bushUnlockdown.ts create mode 100644 src/listeners/guild-custom/lockdown.ts create mode 100644 src/listeners/guild-custom/unlockdown.ts delete mode 100644 src/listeners/member-custom/bushBan.ts delete mode 100644 src/listeners/member-custom/bushBlock.ts delete mode 100644 src/listeners/member-custom/bushKick.ts delete mode 100644 src/listeners/member-custom/bushLevelUpdate.ts delete mode 100644 src/listeners/member-custom/bushMute.ts delete mode 100644 src/listeners/member-custom/bushPunishRole.ts delete mode 100644 src/listeners/member-custom/bushPunishRoleRemove.ts delete mode 100644 src/listeners/member-custom/bushPurge.ts delete mode 100644 src/listeners/member-custom/bushRemoveTimeout.ts delete mode 100644 src/listeners/member-custom/bushTimeout.ts delete mode 100644 src/listeners/member-custom/bushUnban.ts delete mode 100644 src/listeners/member-custom/bushUnblock.ts delete mode 100644 src/listeners/member-custom/bushUnmute.ts delete mode 100644 src/listeners/member-custom/bushUpdateModlog.ts delete mode 100644 src/listeners/member-custom/bushUpdateSettings.ts delete mode 100644 src/listeners/member-custom/bushWarn.ts create mode 100644 src/listeners/member-custom/customBan.ts create mode 100644 src/listeners/member-custom/customBlock.ts create mode 100644 src/listeners/member-custom/customKick.ts create mode 100644 src/listeners/member-custom/customMute.ts create mode 100644 src/listeners/member-custom/customPurge.ts create mode 100644 src/listeners/member-custom/customRemoveTimeout.ts create mode 100644 src/listeners/member-custom/customTimeout.ts create mode 100644 src/listeners/member-custom/customUnban.ts create mode 100644 src/listeners/member-custom/customUnblock.ts create mode 100644 src/listeners/member-custom/customUnmute.ts create mode 100644 src/listeners/member-custom/customWarnMember.ts create mode 100644 src/listeners/member-custom/levelUpdate.ts create mode 100644 src/listeners/member-custom/punishRole.ts create mode 100644 src/listeners/member-custom/punishRoleRemove.ts create mode 100644 src/listeners/member-custom/updateModlog.ts create mode 100644 src/listeners/member-custom/updateSettings.ts (limited to 'src/listeners') diff --git a/src/listeners/automod/automodCreate.ts b/src/listeners/automod/automodCreate.ts index 529651c..e2454e6 100644 --- a/src/listeners/automod/automodCreate.ts +++ b/src/listeners/automod/automodCreate.ts @@ -1,15 +1,14 @@ -import { BushListener, MessageAutomod, type BushClientEvents } from '#lib'; +import { BotListener, MessageAutomod, type BotClientEvents } from '#lib'; -export default class AutomodMessageCreateListener extends BushListener { +export default class AutomodMessageCreateListener extends BotListener { public constructor() { super('automodCreate', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['messageCreate']) { if (message.member === null) return; return new MessageAutomod(message); } diff --git a/src/listeners/automod/automodUpdate.ts b/src/listeners/automod/automodUpdate.ts index d68759f..0609e67 100644 --- a/src/listeners/automod/automodUpdate.ts +++ b/src/listeners/automod/automodUpdate.ts @@ -1,15 +1,14 @@ -import { BushListener, MessageAutomod, type BushClientEvents } from '#lib'; +import { BotListener, MessageAutomod, type BotClientEvents } from '#lib'; -export default class AutomodMessageUpdateListener extends BushListener { +export default class AutomodMessageUpdateListener extends BotListener { public constructor() { super('automodUpdate', { emitter: 'client', - event: 'messageUpdate', - category: 'message' + event: 'messageUpdate' }); } - public async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { + public async exec(...[_, newMessage]: BotClientEvents['messageUpdate']) { const fullMessage = newMessage.partial ? await newMessage.fetch().catch(() => null) : newMessage; if (!fullMessage?.member) return; return new MessageAutomod(fullMessage); diff --git a/src/listeners/automod/memberAutomod.ts b/src/listeners/automod/memberAutomod.ts index 01eb56c..557d13a 100644 --- a/src/listeners/automod/memberAutomod.ts +++ b/src/listeners/automod/memberAutomod.ts @@ -1,7 +1,7 @@ -import { BushClientEvents, BushListener, MemberAutomod } from '#lib'; +import { BotClientEvents, BotListener, MemberAutomod } from '#lib'; import chalk from 'chalk'; -export default class PresenceAutomodListener extends BushListener { +export default class PresenceAutomodListener extends BotListener { public constructor() { super('memberAutomod', { emitter: 'client', @@ -9,7 +9,7 @@ export default class PresenceAutomodListener extends BushListener { }); } - public async exec(...[_, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[_, newMember]: BotClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('automodMembers'))) return; if (!(await newMember.guild.hasFeature('automod'))) return; diff --git a/src/listeners/automod/presenceAutomod.ts b/src/listeners/automod/presenceAutomod.ts index eb536bf..a89d45c 100644 --- a/src/listeners/automod/presenceAutomod.ts +++ b/src/listeners/automod/presenceAutomod.ts @@ -1,6 +1,6 @@ -import { BushClientEvents, BushListener, PresenceAutomod } from '#lib'; +import { BotClientEvents, BotListener, PresenceAutomod } from '#lib'; -export default class PresenceAutomodListener extends BushListener { +export default class PresenceAutomodListener extends BotListener { public constructor() { super('presenceAutomod', { emitter: 'client', @@ -8,7 +8,7 @@ export default class PresenceAutomodListener extends BushListener { }); } - public async exec(...[_, newPresence]: BushClientEvents['presenceUpdate']) { + public async exec(...[_, newPresence]: BotClientEvents['presenceUpdate']) { if (!newPresence.member || !newPresence.guild) return; if (!newPresence.activities.length) return; diff --git a/src/listeners/bush/appealListener.ts b/src/listeners/bush/appealListener.ts index a4e1f00..ecc65c5 100644 --- a/src/listeners/bush/appealListener.ts +++ b/src/listeners/bush/appealListener.ts @@ -1,19 +1,18 @@ -import { BushListener, colors, mappings, ModLog, type BushClientEvents } from '#lib'; +import { BotListener, colors, mappings, ModLog, type BotClientEvents } from '#lib'; import assert from 'assert/strict'; import { EmbedBuilder } from 'discord.js'; import UserInfoCommand from '../../commands/info/userInfo.js'; import ModlogCommand from '../../commands/moderation/modlog.js'; -export default class AppealListener extends BushListener { +export default class AppealListener extends BotListener { public constructor() { super('appealListener', { emitter: 'client', - event: 'messageCreate', - category: 'bush' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']): Promise { + public async exec(...[message]: BotClientEvents['messageCreate']): Promise { if (!this.client.config.isProduction || !message.inGuild() || message.guildId !== mappings.guilds["Moulberry's Bush"]) return; if (message.author.id !== '855446927688335370' || message.embeds.length < 1) return; diff --git a/src/listeners/bush/joinAutoBan.ts b/src/listeners/bush/joinAutoBan.ts index 4370e86..66fdf54 100644 --- a/src/listeners/bush/joinAutoBan.ts +++ b/src/listeners/bush/joinAutoBan.ts @@ -1,16 +1,15 @@ -import { AllowedMentions, BushListener, colors, emojis, format, mappings, type BushClientEvents } from '#lib'; +import { AllowedMentions, BotListener, colors, emojis, format, mappings, type BotClientEvents } from '#lib'; import { TextChannel } from 'discord.js'; -export default class JoinAutoBanListener extends BushListener { +export default class JoinAutoBanListener extends BotListener { public constructor() { super('joinAutoBan', { emitter: 'client', - event: 'guildMemberAdd', - category: 'bush' + event: 'guildMemberAdd' }); } - public async exec(...[member]: BushClientEvents['guildMemberAdd']): Promise { + public async exec(...[member]: BotClientEvents['guildMemberAdd']): Promise { if (!this.client.config.isProduction) return; if (member.guild.id !== mappings.guilds["Moulberry's Bush"]) return; const guild = member.guild; @@ -20,7 +19,7 @@ export default class JoinAutoBanListener extends BushListener { const code = this.client.utils.getShared('autoBanCode'); if (!code) return; if (eval(code)) { - const res = await member.bushBan({ + const res = await member.customBan({ reason: '[AutoBan] Impersonation is not allowed.', moderator: member.guild.members.me! }); diff --git a/src/listeners/bush/supportThread.ts b/src/listeners/bush/supportThread.ts index 5145ff2..3e806e2 100644 --- a/src/listeners/bush/supportThread.ts +++ b/src/listeners/bush/supportThread.ts @@ -1,18 +1,17 @@ -import { BushListener, colors, mappings, type BushClientEvents } from '#lib'; +import { BotListener, colors, mappings, type BotClientEvents } from '#lib'; import { stripIndent } from '#tags'; import assert from 'assert/strict'; import { EmbedBuilder, MessageType, PermissionFlagsBits, TextChannel } from 'discord.js'; -export default class SupportThreadListener extends BushListener { +export default class SupportThreadListener extends BotListener { public constructor() { super('supportThread', { emitter: 'client', - event: 'messageCreate', - category: 'bush' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']): Promise { + public async exec(...[message]: BotClientEvents['messageCreate']): Promise { if (!this.client.config.isProduction || !message.inGuild()) return; if (![MessageType.Default, MessageType.Reply].includes(message.type)) return; if (message.thread) return; diff --git a/src/listeners/bush/userUpdateAutoBan.ts b/src/listeners/bush/userUpdateAutoBan.ts index adfb80c..ae8bca3 100644 --- a/src/listeners/bush/userUpdateAutoBan.ts +++ b/src/listeners/bush/userUpdateAutoBan.ts @@ -1,16 +1,15 @@ -import { AllowedMentions, BushListener, colors, emojis, format, mappings, type BushClientEvents } from '#lib'; +import { AllowedMentions, BotListener, colors, emojis, format, mappings, type BotClientEvents } from '#lib'; import { GuildMember, type TextChannel } from 'discord.js'; -export default class UserUpdateAutoBanListener extends BushListener { +export default class UserUpdateAutoBanListener extends BotListener { public constructor() { super('userUpdateAutoBan', { emitter: 'client', - event: 'userUpdate', - category: 'bush' + event: 'userUpdate' }); } - public async exec(...[_oldUser, newUser]: BushClientEvents['userUpdate']): Promise { + public async exec(...[_oldUser, newUser]: BotClientEvents['userUpdate']): Promise { if (!this.client.config.isProduction) return; // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -26,7 +25,7 @@ export default class UserUpdateAutoBanListener extends BushListener { const guild = member.guild; - const res = await member.bushBan({ + const res = await member.customBan({ reason: '[AutoBan] Impersonation is not allowed.', moderator: member.guild.members.me! }); diff --git a/src/listeners/client/akairoDebug.ts b/src/listeners/client/akairoDebug.ts index 3fa7977..af973bf 100644 --- a/src/listeners/client/akairoDebug.ts +++ b/src/listeners/client/akairoDebug.ts @@ -1,15 +1,14 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BotListener, type BotClientEvents } from '#lib'; -export default class DiscordJsDebugListener extends BushListener { +export default class DiscordJsDebugListener extends BotListener { public constructor() { super('akairoDebug', { emitter: 'client', - event: 'akairoDebug', - category: 'client' + event: 'akairoDebug' }); } - public async exec(...[message, ...other]: BushClientEvents['debug']): Promise { + public async exec(...[message, ...other]: BotClientEvents['debug']): Promise { if (other.length && !message.includes('[registerInteractionCommands]')) void this.client.console.superVerboseRaw('akairoDebug', message, ...other); else void this.client.console.superVerbose('akairoDebug', message); diff --git a/src/listeners/client/dcjsDebug.ts b/src/listeners/client/dcjsDebug.ts deleted file mode 100644 index 4b80c65..0000000 --- a/src/listeners/client/dcjsDebug.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { BushListener, type BushClientEvents } from '#lib'; - -export default class DiscordJsDebugListener extends BushListener { - public constructor() { - super('discordJsDebug', { - emitter: 'client', - event: 'debug', - category: 'client' - }); - } - - public async exec(...[message]: BushClientEvents['debug']): Promise { - void this.client.console.superVerbose('dc.js-debug', message); - } -} diff --git a/src/listeners/client/dcjsError.ts b/src/listeners/client/dcjsError.ts deleted file mode 100644 index a39a92d..0000000 --- a/src/listeners/client/dcjsError.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { BushListener, type BushClientEvents } from '#lib'; - -export default class DiscordJsErrorListener extends BushListener { - public constructor() { - super('discordJsError', { - emitter: 'client', - event: 'error', - category: 'client' - }); - } - - public async exec(...[error]: BushClientEvents['error']): Promise { - void this.client.console.superVerbose('dc.js-error', error); - } -} diff --git a/src/listeners/client/dcjsWarn.ts b/src/listeners/client/dcjsWarn.ts deleted file mode 100644 index b187f0c..0000000 --- a/src/listeners/client/dcjsWarn.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { BushListener, type BushClientEvents } from '#lib'; - -export default class DiscordJsWarnListener extends BushListener { - public constructor() { - super('discordJsWarn', { - emitter: 'client', - event: 'warn', - category: 'client' - }); - } - - public async exec(...[message]: BushClientEvents['warn']): Promise { - void this.client.console.superVerbose('dc.js-warn', message); - } -} diff --git a/src/listeners/client/djsDebug.ts b/src/listeners/client/djsDebug.ts new file mode 100644 index 0000000..28bac7f --- /dev/null +++ b/src/listeners/client/djsDebug.ts @@ -0,0 +1,14 @@ +import { BotListener, type BotClientEvents } from '#lib'; + +export default class DiscordJsDebugListener extends BotListener { + public constructor() { + super('discordJsDebug', { + emitter: 'client', + event: 'debug' + }); + } + + public async exec(...[message]: BotClientEvents['debug']): Promise { + void this.client.console.superVerbose('dc.js-debug', message); + } +} diff --git a/src/listeners/client/djsError.ts b/src/listeners/client/djsError.ts new file mode 100644 index 0000000..04fbfaa --- /dev/null +++ b/src/listeners/client/djsError.ts @@ -0,0 +1,14 @@ +import { BotListener, type BotClientEvents } from '#lib'; + +export default class DiscordJsErrorListener extends BotListener { + public constructor() { + super('discordJsError', { + emitter: 'client', + event: 'error' + }); + } + + public async exec(...[error]: BotClientEvents['error']): Promise { + void this.client.console.superVerbose('dc.js-error', error); + } +} diff --git a/src/listeners/client/djsWarn.ts b/src/listeners/client/djsWarn.ts new file mode 100644 index 0000000..9162a36 --- /dev/null +++ b/src/listeners/client/djsWarn.ts @@ -0,0 +1,14 @@ +import { BotListener, type BotClientEvents } from '#lib'; + +export default class DiscordJsWarnListener extends BotListener { + public constructor() { + super('discordJsWarn', { + emitter: 'client', + event: 'warn' + }); + } + + public async exec(...[message]: BotClientEvents['warn']): Promise { + void this.client.console.superVerbose('dc.js-warn', message); + } +} diff --git a/src/listeners/client/ready.ts b/src/listeners/client/ready.ts index a6a289c..1c887ed 100644 --- a/src/listeners/client/ready.ts +++ b/src/listeners/client/ready.ts @@ -1,7 +1,7 @@ -import { BushClientEvents, BushListener, Guild } from '#lib'; +import { BotClientEvents, BotListener, Guild } from '#lib'; import chalk from 'chalk'; -export default class ReadyListener extends BushListener { +export default class ReadyListener extends BotListener { public constructor() { super('ready', { emitter: 'client', @@ -11,7 +11,7 @@ export default class ReadyListener extends BushListener { } // eslint-disable-next-line no-empty-pattern - public async exec(...[]: BushClientEvents['ready']) { + public async exec(...[]: BotClientEvents['ready']) { process.emit('ready' as any); const tag = `<<${this.client.user?.tag}>>`, diff --git a/src/listeners/commands/commandBlocked.ts b/src/listeners/commands/commandBlocked.ts index 1324d5f..d9a95c1 100644 --- a/src/listeners/commands/commandBlocked.ts +++ b/src/listeners/commands/commandBlocked.ts @@ -1,33 +1,32 @@ import { BlockedReasons, - BushListener, + BotListener, emojis, format, oxford, - type BushCommand, - type BushCommandHandlerEvents, + type BotCommand, + type BotCommandHandlerEvents, type CommandMessage, type SlashMessage } from '#lib'; import { type Client, type InteractionReplyOptions, type ReplyMessageOptions } from 'discord.js'; -export default class CommandBlockedListener extends BushListener { +export default class CommandBlockedListener extends BotListener { public constructor() { super('commandBlocked', { emitter: 'commandHandler', - event: 'commandBlocked', - category: 'commands' + event: 'commandBlocked' }); } - public async exec(...[message, command, reason]: BushCommandHandlerEvents['commandBlocked']) { + public async exec(...[message, command, reason]: BotCommandHandlerEvents['commandBlocked']) { return await CommandBlockedListener.handleBlocked(this.client, message, command, reason); } public static async handleBlocked( client: Client, message: CommandMessage | SlashMessage, - command: BushCommand | null, + command: BotCommand | null, reason?: string ) { const isSlash = !!command && !!message.util?.isSlash; diff --git a/src/listeners/commands/commandCooldown.ts b/src/listeners/commands/commandCooldown.ts index 5f4d70e..1a5b790 100644 --- a/src/listeners/commands/commandCooldown.ts +++ b/src/listeners/commands/commandCooldown.ts @@ -1,15 +1,14 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; -export default class CommandCooldownListener extends BushListener { +export default class CommandCooldownListener extends BotListener { public constructor() { super('commandCooldown', { emitter: 'commandHandler', - event: 'cooldown', - category: 'commands' + event: 'cooldown' }); } - public async exec(...[message, command, remaining]: BushCommandHandlerEvents['cooldown']) { + public async exec(...[message, command, remaining]: BotCommandHandlerEvents['cooldown']) { void this.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 7e14bc3..b96b8de 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -1,15 +1,14 @@ -import { BushListener, handleCommandError, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, handleCommandError, type BotCommandHandlerEvents } from '#lib'; -export default class CommandErrorListener extends BushListener { +export default class CommandErrorListener extends BotListener { public constructor() { super('commandError', { emitter: 'commandHandler', - event: 'error', - category: 'commands' + event: 'error' }); } - public exec(...[error, message, command]: BushCommandHandlerEvents['error']) { + public exec(...[error, message, command]: BotCommandHandlerEvents['error']) { return handleCommandError(this.client, error, message, command); } } diff --git a/src/listeners/commands/commandLocked.ts b/src/listeners/commands/commandLocked.ts index 22ed8e1..fbceca8 100644 --- a/src/listeners/commands/commandLocked.ts +++ b/src/listeners/commands/commandLocked.ts @@ -1,15 +1,14 @@ -import { BushListener, emojis, format, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, emojis, format, type BotCommandHandlerEvents } from '#lib'; -export default class CommandLockedListener extends BushListener { +export default class CommandLockedListener extends BotListener { public constructor() { super('commandLocked', { emitter: 'commandHandler', - event: 'commandLocked', - category: 'commands' + event: 'commandLocked' }); } - public async exec(...[message, command]: BushCommandHandlerEvents['commandLocked']) { + public async exec(...[message, command]: BotCommandHandlerEvents['commandLocked']) { return message.util.reply( `${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 4d39264..a2ec461 100644 --- a/src/listeners/commands/commandMissingPermissions.ts +++ b/src/listeners/commands/commandMissingPermissions.ts @@ -1,24 +1,23 @@ -import { BushListener, emojis, format, mappings, oxford, surroundArray, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, emojis, format, mappings, oxford, surroundArray, type BotCommandHandlerEvents } from '#lib'; import { Client, type PermissionsString } from 'discord.js'; -export default class CommandMissingPermissionsListener extends BushListener { +export default class CommandMissingPermissionsListener extends BotListener { public constructor() { super('commandMissingPermissions', { emitter: 'commandHandler', - event: 'missingPermissions', - category: 'commands' + event: 'missingPermissions' }); } - public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['missingPermissions']) { + public async exec(...[message, command, type, missing]: BotCommandHandlerEvents['missingPermissions']) { return await CommandMissingPermissionsListener.handleMissing(this.client, message, command, type, missing); } public static async handleMissing( client: Client, ...[message, command, type, missing]: - | BushCommandHandlerEvents['missingPermissions'] - | BushCommandHandlerEvents['slashMissingPermissions'] + | BotCommandHandlerEvents['missingPermissions'] + | BotCommandHandlerEvents['slashMissingPermissions'] ) { const niceMissing = (missing.includes('Administrator') ? (['Administrator'] as PermissionsString[]) : missing).map( (perm) => mappings.permissions[perm]?.name ?? missing diff --git a/src/listeners/commands/commandStarted.ts b/src/listeners/commands/commandStarted.ts index 9d0e4cb..407662c 100644 --- a/src/listeners/commands/commandStarted.ts +++ b/src/listeners/commands/commandStarted.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; import { ChannelType } from 'discord.js'; -export default class CommandStartedListener extends BushListener { +export default class CommandStartedListener extends BotListener { public constructor() { super('commandStarted', { emitter: 'commandHandler', - event: 'commandStarted', - category: 'commands' + event: 'commandStarted' }); } - public exec(...[message, command]: BushCommandHandlerEvents['commandStarted']): void { + public exec(...[message, command]: BotCommandHandlerEvents['commandStarted']): void { this.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 d73cff1..3d92d32 100644 --- a/src/listeners/commands/messageBlocked.ts +++ b/src/listeners/commands/messageBlocked.ts @@ -1,15 +1,14 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; -export default class MessageBlockedListener extends BushListener { +export default class MessageBlockedListener extends BotListener { public constructor() { super('messageBlocked', { emitter: 'commandHandler', - event: 'messageBlocked', - category: 'commands' + event: 'messageBlocked' }); } - public async exec(...[message, reason]: BushCommandHandlerEvents['messageBlocked']) { + public async exec(...[message, reason]: BotCommandHandlerEvents['messageBlocked']) { if (['client', 'bot'].includes(reason)) return; // return await CommandBlockedListener.handleBlocked(message as Message, null, reason); return void this.client.console.verbose( diff --git a/src/listeners/commands/slashBlocked.ts b/src/listeners/commands/slashBlocked.ts index c877708..528c97b 100644 --- a/src/listeners/commands/slashBlocked.ts +++ b/src/listeners/commands/slashBlocked.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; import CommandBlockedListener from './commandBlocked.js'; -export default class SlashBlockedListener extends BushListener { +export default class SlashBlockedListener extends BotListener { public constructor() { super('slashBlocked', { emitter: 'commandHandler', - event: 'slashBlocked', - category: 'commands' + event: 'slashBlocked' }); } - public async exec(...[message, command, reason]: BushCommandHandlerEvents['slashBlocked']) { + public async exec(...[message, command, reason]: BotCommandHandlerEvents['slashBlocked']) { return await CommandBlockedListener.handleBlocked(this.client, message, command, reason); } } diff --git a/src/listeners/commands/slashCommandError.ts b/src/listeners/commands/slashCommandError.ts index aca7c5b..03eb34a 100644 --- a/src/listeners/commands/slashCommandError.ts +++ b/src/listeners/commands/slashCommandError.ts @@ -1,15 +1,14 @@ -import { BushListener, handleCommandError, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, handleCommandError, type BotCommandHandlerEvents } from '#lib'; -export default class SlashCommandErrorListener extends BushListener { +export default class SlashCommandErrorListener extends BotListener { public constructor() { super('slashError', { emitter: 'commandHandler', - event: 'slashError', - category: 'commands' + event: 'slashError' }); } - public async exec(...[error, message, command]: BushCommandHandlerEvents['slashError']) { + public async exec(...[error, message, command]: BotCommandHandlerEvents['slashError']) { return await handleCommandError(this.client, error, message, command); } } diff --git a/src/listeners/commands/slashMissingPermissions.ts b/src/listeners/commands/slashMissingPermissions.ts index 0a1383b..68388bf 100644 --- a/src/listeners/commands/slashMissingPermissions.ts +++ b/src/listeners/commands/slashMissingPermissions.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; import CommandMissingPermissionsListener from './commandMissingPermissions.js'; -export default class SlashMissingPermissionsListener extends BushListener { +export default class SlashMissingPermissionsListener extends BotListener { public constructor() { super('slashMissingPermissions', { emitter: 'commandHandler', - event: 'slashMissingPermissions', - category: 'commands' + event: 'slashMissingPermissions' }); } - public async exec(...[message, command, type, missing]: BushCommandHandlerEvents['slashMissingPermissions']) { + public async exec(...[message, command, type, missing]: BotCommandHandlerEvents['slashMissingPermissions']) { return await CommandMissingPermissionsListener.handleMissing(this.client, message, command, type, missing); } } diff --git a/src/listeners/commands/slashNotFound.ts b/src/listeners/commands/slashNotFound.ts index cc14969..7e76fe6 100644 --- a/src/listeners/commands/slashNotFound.ts +++ b/src/listeners/commands/slashNotFound.ts @@ -1,15 +1,14 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; -export default class SlashNotFoundListener extends BushListener { +export default class SlashNotFoundListener extends BotListener { public constructor() { super('slashNotFound', { emitter: 'commandHandler', - event: 'slashNotFound', - category: 'commands' + event: 'slashNotFound' }); } - public async exec(...[interaction]: BushCommandHandlerEvents['slashNotFound']) { + public async exec(...[interaction]: BotCommandHandlerEvents['slashNotFound']) { void this.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 c2ece5e..898af13 100644 --- a/src/listeners/commands/slashStarted.ts +++ b/src/listeners/commands/slashStarted.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, type BotCommandHandlerEvents } from '#lib'; import { ChannelType } from 'discord.js'; -export default class SlashStartedListener extends BushListener { +export default class SlashStartedListener extends BotListener { public constructor() { super('slashStarted', { emitter: 'commandHandler', - event: 'slashStarted', - category: 'commands' + event: 'slashStarted' }); } - public async exec(...[message, command]: BushCommandHandlerEvents['slashStarted']) { + public async exec(...[message, command]: BotCommandHandlerEvents['slashStarted']) { this.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 bb237a0..d8d002e 100644 --- a/src/listeners/contextCommands/contextCommandBlocked.ts +++ b/src/listeners/contextCommands/contextCommandBlocked.ts @@ -1,12 +1,11 @@ -import { BlockedReasons, BushListener, emojis, format } from '#lib'; +import { BlockedReasons, BotListener, emojis, format } from '#lib'; import { type ContextMenuCommandHandlerEvents } from 'discord-akairo'; -export default class ContextCommandBlockedListener extends BushListener { +export default class ContextCommandBlockedListener extends BotListener { public constructor() { super('contextCommandBlocked', { emitter: 'contextMenuCommandHandler', - event: 'blocked', - category: 'contextCommands' + event: 'blocked' }); } diff --git a/src/listeners/contextCommands/contextCommandError.ts b/src/listeners/contextCommands/contextCommandError.ts index 6951ce3..091bee9 100644 --- a/src/listeners/contextCommands/contextCommandError.ts +++ b/src/listeners/contextCommands/contextCommandError.ts @@ -1,13 +1,12 @@ -import { BushListener, colors, format, formatError, getErrorHaste, getErrorStack, IFuckedUpError } from '#lib'; +import { BotListener, colors, format, formatError, getErrorHaste, getErrorStack, IFuckedUpError } from '#lib'; import { type ContextMenuCommand, type ContextMenuCommandHandlerEvents } from 'discord-akairo'; import { ChannelType, Client, ContextMenuCommandInteraction, EmbedBuilder, GuildTextBasedChannel } from 'discord.js'; -export default class ContextCommandErrorListener extends BushListener { +export default class ContextCommandErrorListener extends BotListener { public constructor() { super('contextCommandError', { emitter: 'contextMenuCommandHandler', - event: 'error', - category: 'contextCommands' + event: 'error' }); } diff --git a/src/listeners/contextCommands/contextCommandNotFound.ts b/src/listeners/contextCommands/contextCommandNotFound.ts index f5097f3..4bb397e 100644 --- a/src/listeners/contextCommands/contextCommandNotFound.ts +++ b/src/listeners/contextCommands/contextCommandNotFound.ts @@ -1,12 +1,11 @@ -import { BushListener } from '#lib'; +import { BotListener } from '#lib'; import { type ContextMenuCommandHandlerEvents } from 'discord-akairo'; -export default class ContextCommandNotFoundListener extends BushListener { +export default class ContextCommandNotFoundListener extends BotListener { public constructor() { super('contextCommandNotFound', { emitter: 'contextMenuCommandHandler', - event: 'notFound', - category: 'contextCommands' + event: 'notFound' }); } diff --git a/src/listeners/contextCommands/contextCommandStarted.ts b/src/listeners/contextCommands/contextCommandStarted.ts index 2d1e9ef..867af54 100644 --- a/src/listeners/contextCommands/contextCommandStarted.ts +++ b/src/listeners/contextCommands/contextCommandStarted.ts @@ -1,13 +1,12 @@ -import { BushListener } from '#lib'; +import { BotListener } from '#lib'; import { ContextMenuCommandHandlerEvents } from 'discord-akairo'; import { ApplicationCommandType, ChannelType } from 'discord.js'; -export default class ContextCommandStartedListener extends BushListener { +export default class ContextCommandStartedListener extends BotListener { public constructor() { super('contextCommandStarted', { emitter: 'contextMenuCommandHandler', - event: 'started', - category: 'contextCommands' + event: 'started' }); } diff --git a/src/listeners/guild-custom/bushLockdown.ts b/src/listeners/guild-custom/bushLockdown.ts deleted file mode 100644 index 51d1c3d..0000000 --- a/src/listeners/guild-custom/bushLockdown.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, emojis, type BushClientEvents } from '#lib'; -import { EmbedBuilder } from 'discord.js'; - -export default class BushLockdownListener extends BushListener { - public constructor() { - super('bushLockdown', { - emitter: 'client', - event: 'bushLockdown', - category: 'guild-custom' - }); - } - - public async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushLockdown']) { - const logChannel = await moderator.guild.getLogChannel('moderation'); - if (!logChannel) return; - - const logEmbed = new EmbedBuilder() - .setColor(colors.Blurple) - .setTimestamp() - .addFields( - { name: '**Action**', value: `${'Lockdown'}` }, - { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, - { - name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, - value: channelsSuccessMap - .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) - .join('\n') - } - ); - return await logChannel.send({ embeds: [logEmbed] }); - } -} diff --git a/src/listeners/guild-custom/bushUnlockdown.ts b/src/listeners/guild-custom/bushUnlockdown.ts deleted file mode 100644 index 18cb792..0000000 --- a/src/listeners/guild-custom/bushUnlockdown.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, emojis, type BushClientEvents } from '#lib'; -import { EmbedBuilder } from 'discord.js'; - -export default class BushUnlockdownListener extends BushListener { - public constructor() { - super('bushUnlockdown', { - emitter: 'client', - event: 'bushUnlockdown', - category: 'guild-custom' - }); - } - - public async exec(...[moderator, reason, channelsSuccessMap, _all]: BushClientEvents['bushUnlockdown']) { - const logChannel = await moderator.guild.getLogChannel('moderation'); - if (!logChannel) return; - - const logEmbed = new EmbedBuilder() - .setColor(colors.Blurple) - .setTimestamp() - .addFields( - { name: '**Action**', value: `${'Unlockdown'}` }, - { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, - { - name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, - value: channelsSuccessMap - .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) - .join('\n') - } - ); - return await logChannel.send({ embeds: [logEmbed] }); - } -} diff --git a/src/listeners/guild-custom/lockdown.ts b/src/listeners/guild-custom/lockdown.ts new file mode 100644 index 0000000..bf3ee7c --- /dev/null +++ b/src/listeners/guild-custom/lockdown.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, emojis, type BotClientEvents } from '#lib'; +import { EmbedBuilder } from 'discord.js'; + +export default class LockdownListener extends BotListener { + public constructor() { + super('lockdown', { + emitter: 'client', + event: 'lockdown' + }); + } + + public async exec(...[moderator, reason, channelsSuccessMap, _all]: BotClientEvents['lockdown']) { + const logChannel = await moderator.guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Blurple) + .setTimestamp() + .addFields( + { name: '**Action**', value: `${'Lockdown'}` }, + { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, + { + name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, + value: channelsSuccessMap + .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) + .join('\n') + } + ); + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/guild-custom/unlockdown.ts b/src/listeners/guild-custom/unlockdown.ts new file mode 100644 index 0000000..e08a42b --- /dev/null +++ b/src/listeners/guild-custom/unlockdown.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, emojis, type BotClientEvents } from '#lib'; +import { EmbedBuilder } from 'discord.js'; + +export default class UnlockdownListener extends BotListener { + public constructor() { + super('unlockdown', { + emitter: 'client', + event: 'unlockdown' + }); + } + + public async exec(...[moderator, reason, channelsSuccessMap, _all]: BotClientEvents['unlockdown']) { + const logChannel = await moderator.guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Blurple) + .setTimestamp() + .addFields( + { name: '**Action**', value: `${'Unlockdown'}` }, + { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, + { + name: `**Channel${channelsSuccessMap.size > 1 ? 's' : ''}**`, + value: channelsSuccessMap + .map((success, channel) => `<#${channel}> ${success ? emojis.success : emojis.error}`) + .join('\n') + } + ); + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/guild/guildCreate.ts b/src/listeners/guild/guildCreate.ts index 9f5f56c..3db28d6 100644 --- a/src/listeners/guild/guildCreate.ts +++ b/src/listeners/guild/guildCreate.ts @@ -1,15 +1,14 @@ -import { BushListener, colors, emojis, format, Guild, type BushClientEvents } from '#lib'; +import { BotListener, colors, emojis, format, Guild, type BotClientEvents } from '#lib'; -export default class GuildCreateListener extends BushListener { +export default class GuildCreateListener extends BotListener { public constructor() { super('guildCreate', { emitter: 'client', - event: 'guildCreate', // when the bot joins a guild - category: 'guild' + event: 'guildCreate' // when the bot joins a guild }); } - public async exec(...[guild]: BushClientEvents['guildCreate']) { + public async exec(...[guild]: BotClientEvents['guildCreate']) { void this.client.console.info( 'guildCreate', `Joined <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.` diff --git a/src/listeners/guild/guildDelete.ts b/src/listeners/guild/guildDelete.ts index 62d98e3..2cc23f1 100644 --- a/src/listeners/guild/guildDelete.ts +++ b/src/listeners/guild/guildDelete.ts @@ -1,15 +1,14 @@ -import { BushListener, colors, emojis, format, type BushClientEvents } from '#lib'; +import { BotListener, colors, emojis, format, type BotClientEvents } from '#lib'; -export default class GuildDeleteListener extends BushListener { +export default class GuildDeleteListener extends BotListener { public constructor() { super('guildDelete', { emitter: 'client', - event: 'guildDelete', // when the bot leaves a guild - category: 'guild' + event: 'guildDelete' // when the bot leaves a guild }); } - public async exec(...[guild]: BushClientEvents['guildDelete']) { + public async exec(...[guild]: BotClientEvents['guildDelete']) { void this.client.console.info( 'guildDelete', `Left <<${guild.name}>> with <<${guild.memberCount?.toLocaleString()}>> members.` diff --git a/src/listeners/guild/guildMemberAdd.ts b/src/listeners/guild/guildMemberAdd.ts index f1f90af..9268f01 100644 --- a/src/listeners/guild/guildMemberAdd.ts +++ b/src/listeners/guild/guildMemberAdd.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, emojis, format, type BushClientEvents } from '#lib'; +import { BotListener, colors, emojis, format, type BotClientEvents } from '#lib'; import { EmbedBuilder, type GuildMember, type TextChannel } from 'discord.js'; -export default class GuildMemberAddListener extends BushListener { +export default class GuildMemberAddListener extends BotListener { public constructor() { super('guildMemberAdd', { emitter: 'client', - event: 'guildMemberAdd', - category: 'guild' + event: 'guildMemberAdd' }); } - public async exec(...[member]: BushClientEvents['guildMemberAdd']) { + public async exec(...[member]: BotClientEvents['guildMemberAdd']) { void this.sendWelcomeMessage(member); } diff --git a/src/listeners/guild/guildMemberRemove.ts b/src/listeners/guild/guildMemberRemove.ts index 39bab24..ee626d6 100644 --- a/src/listeners/guild/guildMemberRemove.ts +++ b/src/listeners/guild/guildMemberRemove.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, emojis, format, sleep, StickyRole, Time, type BushClientEvents } from '#lib'; +import { BotListener, colors, emojis, format, sleep, StickyRole, Time, type BotClientEvents } from '#lib'; import { EmbedBuilder, type GuildMember, type PartialGuildMember, type TextChannel } from 'discord.js'; -export default class GuildMemberRemoveListener extends BushListener { +export default class GuildMemberRemoveListener extends BotListener { public constructor() { super('guildMemberRemove', { emitter: 'client', - event: 'guildMemberRemove', - category: 'guild' + event: 'guildMemberRemove' }); } - public async exec(...[member]: BushClientEvents['guildMemberRemove']) { + public async exec(...[member]: BotClientEvents['guildMemberRemove']) { void this.sendWelcomeMessage(member); void this.stickyRoles(member); } diff --git a/src/listeners/guild/joinRoles.ts b/src/listeners/guild/joinRoles.ts index 539fa71..142d4cd 100644 --- a/src/listeners/guild/joinRoles.ts +++ b/src/listeners/guild/joinRoles.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, format, StickyRole, type BushClientEvents } from '#lib'; +import { BotListener, colors, format, StickyRole, type BotClientEvents } from '#lib'; import { type GuildMember, type Snowflake } from 'discord.js'; -export default class JoinRolesListener extends BushListener { +export default class JoinRolesListener extends BotListener { public constructor() { super('joinRoles', { emitter: 'client', - event: 'guildMemberUpdate', // listens to guildMemberUpdate so that the role's aren't given before the member accepts the welcome screen - category: 'guild' + event: 'guildMemberUpdate' // listens to guildMemberUpdate so that the role's aren't given before the member accepts the welcome screen }); } - public async exec(...[oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[oldMember, newMember]: BotClientEvents['guildMemberUpdate']) { if (this.client.config.isDevelopment) return; if (oldMember.pending && !newMember.pending) { const feat = { diff --git a/src/listeners/guild/syncUnbanPunishmentModel.ts b/src/listeners/guild/syncUnbanPunishmentModel.ts index 80a8ce2..352d704 100644 --- a/src/listeners/guild/syncUnbanPunishmentModel.ts +++ b/src/listeners/guild/syncUnbanPunishmentModel.ts @@ -1,15 +1,14 @@ -import { ActivePunishment, ActivePunishmentType, BushListener, type BushClientEvents } from '#lib'; +import { ActivePunishment, ActivePunishmentType, BotListener, type BotClientEvents } from '#lib'; -export default class SyncUnbanListener extends BushListener { +export default class SyncUnbanListener extends BotListener { public constructor() { super('syncUnbanPunishmentModel', { emitter: 'client', - event: 'guildBanRemove', - category: 'guild' + event: 'guildBanRemove' }); } - public async exec(...[ban]: BushClientEvents['guildBanRemove']) { + public async exec(...[ban]: BotClientEvents['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 8dd753b..d8a5cc9 100644 --- a/src/listeners/interaction/interactionCreate.ts +++ b/src/listeners/interaction/interactionCreate.ts @@ -1,16 +1,15 @@ -import { BushListener, emojis, format, handleAutomodInteraction, oxford, surroundArray, type BushClientEvents } from '#lib'; +import { BotListener, emojis, format, handleAutomodInteraction, oxford, surroundArray, type BotClientEvents } from '#lib'; import { InteractionType } from 'discord.js'; -export default class InteractionCreateListener extends BushListener { +export default class InteractionCreateListener extends BotListener { public constructor() { super('interactionCreate', { emitter: 'client', - event: 'interactionCreate', - category: 'interaction' + event: 'interactionCreate' }); } - public async exec(...[interaction]: BushClientEvents['interactionCreate']) { + public async exec(...[interaction]: BotClientEvents['interactionCreate']) { if (!interaction) return; if ('customId' in interaction && (interaction as any)['customId'].startsWith('test')) return; void this.client.console.verbose( diff --git a/src/listeners/member-custom/bushBan.ts b/src/listeners/member-custom/bushBan.ts deleted file mode 100644 index 2cde91d..0000000 --- a/src/listeners/member-custom/bushBan.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushBanListener extends BushListener { - public constructor() { - super('bushBan', { - emitter: 'client', - event: 'bushBan', - category: 'member-custom' - }); - } - - 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(colors.Red) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${duration ? 'Temp Ban' : 'Perm Ban'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason.substring(0, 1024) : '[No Reason Provided]'}` } - ); - 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 deleted file mode 100644 index a3af924..0000000 --- a/src/listeners/member-custom/bushBlock.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushBlockListener extends BushListener { - public constructor() { - super('bushBlock', { - emitter: 'client', - event: 'bushBlock', - category: 'member-custom' - }); - } - - 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(colors.Purple) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${duration ? 'Temp Block' : 'Perm Block'}` }, - { name: '**Channel**', value: `<#${channel.id}>` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - - 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 deleted file mode 100644 index ff3e40e..0000000 --- a/src/listeners/member-custom/bushKick.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushKickListener extends BushListener { - public constructor() { - super('bushKick', { - emitter: 'client', - event: 'bushKick', - category: 'member-custom' - }); - } - - 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(colors.Red) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Kick'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/bushLevelUpdate.ts b/src/listeners/member-custom/bushLevelUpdate.ts deleted file mode 100644 index 702f7cc..0000000 --- a/src/listeners/member-custom/bushLevelUpdate.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { BushListener, format, type BushClientEvents } from '#lib'; -import assert from 'assert/strict'; -import { type TextChannel } from 'discord.js'; - -type Args = BushClientEvents['bushLevelUpdate']; - -export default class BushLevelUpdateListener extends BushListener { - public constructor() { - super('bushLevelUpdate', { - emitter: 'client', - event: 'bushLevelUpdate', - category: 'member-custom' - }); - } - - public async exec(...[member, _oldLevel, newLevel, _currentXp, message]: Args) { - void this.sendLevelUpMessages(member, newLevel, message); - void this.assignLevelRoles(member, newLevel, message); - } - - private async sendLevelUpMessages(member: Args[0], newLevel: Args[2], message: Args[4]) { - assert(message.inGuild()); - if (!(await message.guild.hasFeature('sendLevelUpMessages'))) return; - - const channel = ((await message.guild.channels - .fetch((await message.guild.getSetting('levelUpChannel')) ?? message.channelId) - .catch(() => null)) ?? message.channel) as TextChannel; - - const success = await channel - .send(`${format.input(member.user.tag)} leveled up to level ${format.input(`${newLevel}`)}.`) - .catch(() => null); - - if (!success) - await message.guild.error( - 'bushLevelUpdate', - `Could not send level up message for ${member.user.tag} in <#${message.channel.id}>.` - ); - } - - private async assignLevelRoles(member: Args[0], newLevel: Args[2], message: Args[4]) { - assert(message.inGuild()); - const levelRoles = await message.guild.getSetting('levelRoles'); - - if (!Object.keys(levelRoles).length) return; - - const promises = []; - for (let i = 1; i <= newLevel; i++) { - if (levelRoles[i]) { - if (member.roles.cache.has(levelRoles[i])) continue; - else promises.push(member.roles.add(levelRoles[i], `[LevelRoles] Role given for reaching level ${i}`)); - } - } - try { - if (promises.length) await Promise.all(promises); - } catch (e: any) { - await member.guild.error( - 'bushLevelUpdate', - `There was an error adding level roles to ${member.user.tag} upon reaching to level ${newLevel}.\n${ - 'message' in e ? e.message : e - }` - ); - } - } -} diff --git a/src/listeners/member-custom/bushMute.ts b/src/listeners/member-custom/bushMute.ts deleted file mode 100644 index 73f9490..0000000 --- a/src/listeners/member-custom/bushMute.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushMuteListener extends BushListener { - public constructor() { - super('bushMute', { - emitter: 'client', - event: 'bushMute', - category: 'member-custom' - }); - } - - 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(colors.Orange) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${duration ? 'Temp Mute' : 'Perm Mute'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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 deleted file mode 100644 index 1f28811..0000000 --- a/src/listeners/member-custom/bushPunishRole.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushPunishRoleListener extends BushListener { - public constructor() { - super('bushPunishRole', { - emitter: 'client', - event: 'bushPunishRole', - category: 'member-custom' - }); - } - - 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(colors.Yellow) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${duration ? 'Temp Punishment Role' : 'Perm Punishment Role'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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 deleted file mode 100644 index ef1d429..0000000 --- a/src/listeners/member-custom/bushPunishRoleRemove.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushPunishRoleRemoveListener extends BushListener { - public constructor() { - super('bushPunishRoleRemove', { - emitter: 'client', - event: 'bushPunishRoleRemove', - category: 'member-custom' - }); - } - - 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(colors.Green) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Remove Punishment Role'}` }, - { name: '**Role**', value: `${role}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - - return await logChannel.send({ embeds: [logEmbed] }); - } -} diff --git a/src/listeners/member-custom/bushPurge.ts b/src/listeners/member-custom/bushPurge.ts deleted file mode 100644 index 75faaeb..0000000 --- a/src/listeners/member-custom/bushPurge.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { BushListener, colors, emojis, type BushClientEvents } from '#lib'; -import { EmbedBuilder } from 'discord.js'; - -export default class BushPurgeListener extends BushListener { - public constructor() { - super('bushPurge', { - emitter: 'client', - event: 'bushPurge', - category: 'member-custom' - }); - } - - public async exec(...[moderator, guild, channel, messages]: BushClientEvents['bushPurge']) { - const logChannel = await guild.getLogChannel('moderation'); - if (!logChannel) return; - - const mappedMessages = messages.map((m) => ({ - id: m.id, - author: `${m.author.tag} (${m.id})`, - content: m.content, - embeds: m.embeds, - attachments: [...m.attachments.values()] - })); - const haste = await this.client.utils.inspectCleanRedactHaste(mappedMessages); - - const logEmbed = new EmbedBuilder() - .setColor(colors.DarkPurple) - .setTimestamp() - .setFooter({ text: `${messages.size.toLocaleString()} Messages` }) - .setAuthor({ name: moderator.tag, iconURL: moderator.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Purge'}` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Channel**', value: `<#${channel.id}> (${channel.name})` }, - { - name: '**Messages**', - value: `${ - haste.url ? `[haste](${haste.url})${haste.error ? `- ${haste.error}` : ''}` : `${emojis.error} ${haste.error}` - }` - } - ); - return await logChannel.send({ embeds: [logEmbed] }); - } -} diff --git a/src/listeners/member-custom/bushRemoveTimeout.ts b/src/listeners/member-custom/bushRemoveTimeout.ts deleted file mode 100644 index c389538..0000000 --- a/src/listeners/member-custom/bushRemoveTimeout.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushRemoveTimeoutListener extends BushListener { - public constructor() { - super('bushRemoveTimeout', { - emitter: 'client', - event: 'bushRemoveTimeout', - category: 'member-custom' - }); - } - - 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(colors.Green) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Remove Timeout'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/bushTimeout.ts b/src/listeners/member-custom/bushTimeout.ts deleted file mode 100644 index 82169d6..0000000 --- a/src/listeners/member-custom/bushTimeout.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, humanizeDuration, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushTimeoutListener extends BushListener { - public constructor() { - super('bushTimeout', { - emitter: 'client', - event: 'bushTimeout', - category: 'member-custom' - }); - } - - 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(colors.Orange) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Timeout'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, - { 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 deleted file mode 100644 index 40394cd..0000000 --- a/src/listeners/member-custom/bushUnban.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushUnbanListener extends BushListener { - public constructor() { - super('bushUnban', { - emitter: 'client', - event: 'bushUnban', - category: 'member-custom' - }); - } - - 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(colors.Green) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Unban'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/bushUnblock.ts b/src/listeners/member-custom/bushUnblock.ts deleted file mode 100644 index 867d391..0000000 --- a/src/listeners/member-custom/bushUnblock.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushUnblockListener extends BushListener { - public constructor() { - super('bushUnblock', { - emitter: 'client', - event: 'bushUnblock', - category: 'member-custom' - }); - } - - 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(colors.Green) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Unblock'}` }, - { name: '**Channel**', value: `<#${channel.id}>` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/bushUnmute.ts b/src/listeners/member-custom/bushUnmute.ts deleted file mode 100644 index 2ff53b9..0000000 --- a/src/listeners/member-custom/bushUnmute.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushUnmuteListener extends BushListener { - public constructor() { - super('bushUnmute', { - emitter: 'client', - event: 'bushUnmute', - category: 'member-custom' - }); - } - - 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(colors.Green) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: `${'Unmute'}` }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/bushUpdateModlog.ts b/src/listeners/member-custom/bushUpdateModlog.ts deleted file mode 100644 index 1896ede..0000000 --- a/src/listeners/member-custom/bushUpdateModlog.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder } from 'discord.js'; - -export default class BushUpdateModlogListener extends BushListener { - public constructor() { - super('bushUpdateModlog', { - emitter: 'client', - event: 'bushUpdateModlog', - category: 'member-custom' - }); - } - - 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(colors.Blurple) - .setTimestamp() - .setAuthor({ - name: moderator.user.tag, - iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined - }) - .addFields( - { name: '**Action**', value: 'Update Modlog' }, - { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, - { name: '**ModLog Changed**', value: modlogID }, - { name: '**Value Changed**', value: key }, - { - name: '**Old Value**', - value: await this.client.utils.inspectCleanRedactCodeblock(oldModlog, undefined, undefined, 1024) - }, - { - name: '**New Value**', - value: await this.client.utils.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 deleted file mode 100644 index a0be2f9..0000000 --- a/src/listeners/member-custom/bushUpdateSettings.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder } from 'discord.js'; - -export default class BushUpdateSettingsListener extends BushListener { - public constructor() { - super('bushUpdateSettings', { - emitter: 'client', - event: 'bushUpdateSettings', - category: 'member-custom' - }); - } - - public async exec(...[setting, guild, oldSettings, newSettings, moderator]: BushClientEvents['bushUpdateSettings']) { - const logChannel = await guild.getLogChannel('moderation'); - if (!logChannel) return; - - const logEmbed = new EmbedBuilder().setColor(colors.Blurple).setTimestamp(); - - if (moderator) - logEmbed.setAuthor({ - name: moderator.user.tag, - iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined - }); - logEmbed.addFields({ name: '**Action**', value: `${'Update Settings'}` }); - if (moderator) logEmbed.addFields({ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }); - logEmbed.addFields( - { name: '**Setting Changed**', value: setting }, - { name: '**Old Value**', value: await this.client.utils.inspectCleanRedactCodeblock(oldSettings, 'js', undefined, 1024) }, - { name: '**New Value**', value: await this.client.utils.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 deleted file mode 100644 index 822a491..0000000 --- a/src/listeners/member-custom/bushWarn.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; -import { EmbedBuilder, GuildMember } from 'discord.js'; - -export default class BushWarnListener extends BushListener { - public constructor() { - super('bushWarn', { - emitter: 'client', - event: 'bushWarn', - category: 'member-custom' - }); - } - - 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(colors.Yellow) - .setTimestamp() - .setFooter({ text: `CaseID: ${caseID}` }) - .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) - .addFields( - { name: '**Action**', value: 'Warn' }, - { name: '**User**', value: `${user} (${user.tag})` }, - { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, - { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } - ); - 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/customBan.ts b/src/listeners/member-custom/customBan.ts new file mode 100644 index 0000000..5b199bb --- /dev/null +++ b/src/listeners/member-custom/customBan.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, humanizeDuration, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomBanListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Ban, { + emitter: 'client', + event: TanzaniteEvent.Ban + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BotClientEvents[TanzaniteEvent.Ban]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Red) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${duration ? 'Temp Ban' : 'Perm Ban'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason.substring(0, 1024) : '[No Reason Provided]'}` } + ); + 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/customBlock.ts b/src/listeners/member-custom/customBlock.ts new file mode 100644 index 0000000..8faa0b7 --- /dev/null +++ b/src/listeners/member-custom/customBlock.ts @@ -0,0 +1,36 @@ +import { BotListener, colors, humanizeDuration, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomBlockListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Block, { + emitter: 'client', + event: TanzaniteEvent.Block + }); + } + + public async exec( + ...[victim, moderator, guild, reason, caseID, duration, dmSuccess, channel]: BotClientEvents[TanzaniteEvent.Block] + ) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Purple) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${duration ? 'Temp Block' : 'Perm Block'}` }, + { name: '**Channel**', value: `<#${channel.id}>` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + + 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/customKick.ts b/src/listeners/member-custom/customKick.ts new file mode 100644 index 0000000..bf3e2fe --- /dev/null +++ b/src/listeners/member-custom/customKick.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomKickListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Kick, { + emitter: 'client', + event: TanzaniteEvent.Kick + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BotClientEvents[TanzaniteEvent.Kick]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Red) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Kick'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customMute.ts b/src/listeners/member-custom/customMute.ts new file mode 100644 index 0000000..21a24e8 --- /dev/null +++ b/src/listeners/member-custom/customMute.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, humanizeDuration, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomMuteListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Mute, { + emitter: 'client', + event: TanzaniteEvent.Mute + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BotClientEvents[TanzaniteEvent.Mute]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Orange) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${duration ? 'Temp Mute' : 'Perm Mute'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customPurge.ts b/src/listeners/member-custom/customPurge.ts new file mode 100644 index 0000000..956fcb7 --- /dev/null +++ b/src/listeners/member-custom/customPurge.ts @@ -0,0 +1,43 @@ +import { BotListener, colors, emojis, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder } from 'discord.js'; + +export default class CustomPurgeListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Purge, { + emitter: 'client', + event: TanzaniteEvent.Purge + }); + } + + public async exec(...[moderator, guild, channel, messages]: BotClientEvents[TanzaniteEvent.Purge]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + + const mappedMessages = messages.map((m) => ({ + id: m.id, + author: `${m.author.tag} (${m.id})`, + content: m.content, + embeds: m.embeds, + attachments: [...m.attachments.values()] + })); + const haste = await this.client.utils.inspectCleanRedactHaste(mappedMessages); + + const logEmbed = new EmbedBuilder() + .setColor(colors.DarkPurple) + .setTimestamp() + .setFooter({ text: `${messages.size.toLocaleString()} Messages` }) + .setAuthor({ name: moderator.tag, iconURL: moderator.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Purge'}` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Channel**', value: `<#${channel.id}> (${channel.name})` }, + { + name: '**Messages**', + value: `${ + haste.url ? `[haste](${haste.url})${haste.error ? `- ${haste.error}` : ''}` : `${emojis.error} ${haste.error}` + }` + } + ); + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/member-custom/customRemoveTimeout.ts b/src/listeners/member-custom/customRemoveTimeout.ts new file mode 100644 index 0000000..00454bd --- /dev/null +++ b/src/listeners/member-custom/customRemoveTimeout.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomRemoveTimeoutListener extends BotListener { + public constructor() { + super(TanzaniteEvent.RemoveTimeout, { + emitter: 'client', + event: TanzaniteEvent.RemoveTimeout + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BotClientEvents[TanzaniteEvent.RemoveTimeout]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Green) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Remove Timeout'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customTimeout.ts b/src/listeners/member-custom/customTimeout.ts new file mode 100644 index 0000000..6b142ec --- /dev/null +++ b/src/listeners/member-custom/customTimeout.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, humanizeDuration, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomTimeoutListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Timeout, { + emitter: 'client', + event: TanzaniteEvent.Timeout + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, duration, dmSuccess]: BotClientEvents[TanzaniteEvent.Timeout]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Orange) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Timeout'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` }, + { 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/customUnban.ts b/src/listeners/member-custom/customUnban.ts new file mode 100644 index 0000000..aa4cd75 --- /dev/null +++ b/src/listeners/member-custom/customUnban.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomUnbanListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Unban, { + emitter: 'client', + event: TanzaniteEvent.Unban + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BotClientEvents[TanzaniteEvent.Unban]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Green) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Unban'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customUnblock.ts b/src/listeners/member-custom/customUnblock.ts new file mode 100644 index 0000000..a7553d9 --- /dev/null +++ b/src/listeners/member-custom/customUnblock.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomUnblockListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Unblock, { + emitter: 'client', + event: TanzaniteEvent.Unblock + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess, channel]: BotClientEvents[TanzaniteEvent.Unblock]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Green) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Unblock'}` }, + { name: '**Channel**', value: `<#${channel.id}>` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customUnmute.ts b/src/listeners/member-custom/customUnmute.ts new file mode 100644 index 0000000..ef7b22f --- /dev/null +++ b/src/listeners/member-custom/customUnmute.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomUnmuteListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Unmute, { + emitter: 'client', + event: TanzaniteEvent.Unmute + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BotClientEvents[TanzaniteEvent.Unmute]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Green) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Unmute'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/customWarnMember.ts b/src/listeners/member-custom/customWarnMember.ts new file mode 100644 index 0000000..3ca7e08 --- /dev/null +++ b/src/listeners/member-custom/customWarnMember.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class CustomWarnListener extends BotListener { + public constructor() { + super(TanzaniteEvent.Warn, { + emitter: 'client', + event: TanzaniteEvent.Warn + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, dmSuccess]: BotClientEvents[TanzaniteEvent.Warn]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Yellow) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: 'Warn' }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + 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/levelUpdate.ts b/src/listeners/member-custom/levelUpdate.ts new file mode 100644 index 0000000..64dd388 --- /dev/null +++ b/src/listeners/member-custom/levelUpdate.ts @@ -0,0 +1,63 @@ +import { BotListener, format, TanzaniteEvent, type BotClientEvents } from '#lib'; +import assert from 'assert/strict'; +import { type TextChannel } from 'discord.js'; + +type Args = BotClientEvents[TanzaniteEvent.LevelUpdate]; + +export default class LevelUpdateListener extends BotListener { + public constructor() { + super(TanzaniteEvent.LevelUpdate, { + emitter: 'client', + event: TanzaniteEvent.LevelUpdate + }); + } + + public async exec(...[member, _oldLevel, newLevel, _currentXp, message]: Args) { + void this.sendLevelUpMessages(member, newLevel, message); + void this.assignLevelRoles(member, newLevel, message); + } + + private async sendLevelUpMessages(member: Args[0], newLevel: Args[2], message: Args[4]) { + assert(message.inGuild()); + if (!(await message.guild.hasFeature('sendLevelUpMessages'))) return; + + const channel = ((await message.guild.channels + .fetch((await message.guild.getSetting('levelUpChannel')) ?? message.channelId) + .catch(() => null)) ?? message.channel) as TextChannel; + + const success = await channel + .send(`${format.input(member.user.tag)} leveled up to level ${format.input(`${newLevel}`)}.`) + .catch(() => null); + + if (!success) + await message.guild.error( + 'LevelUpdate', + `Could not send level up message for ${member.user.tag} in <#${message.channel.id}>.` + ); + } + + private async assignLevelRoles(member: Args[0], newLevel: Args[2], message: Args[4]) { + assert(message.inGuild()); + const levelRoles = await message.guild.getSetting('levelRoles'); + + if (!Object.keys(levelRoles).length) return; + + const promises = []; + for (let i = 1; i <= newLevel; i++) { + if (levelRoles[i]) { + if (member.roles.cache.has(levelRoles[i])) continue; + else promises.push(member.roles.add(levelRoles[i], `[LevelRoles] Role given for reaching level ${i}`)); + } + } + try { + if (promises.length) await Promise.all(promises); + } catch (e: any) { + await member.guild.error( + 'LevelUpdate', + `There was an error adding level roles to ${member.user.tag} upon reaching to level ${newLevel}.\n${ + 'message' in e ? e.message : e + }` + ); + } + } +} diff --git a/src/listeners/member-custom/massBan.ts b/src/listeners/member-custom/massBan.ts index ca41f29..7a6cd34 100644 --- a/src/listeners/member-custom/massBan.ts +++ b/src/listeners/member-custom/massBan.ts @@ -1,15 +1,14 @@ -import { BanResponse, banResponse, BushListener, colors, emojis, overflowEmbed, type BushClientEvents } from '#lib'; +import { BanResponse, banResponse, BotListener, colors, emojis, overflowEmbed, TanzaniteEvent, type BotClientEvents } from '#lib'; -export default class MassBanListener extends BushListener { +export default class MassBanListener extends BotListener { public constructor() { - super('massBan', { + super(TanzaniteEvent.MassBan, { emitter: 'client', - event: 'massBan', - category: 'member-custom' + event: TanzaniteEvent.MassBan }); } - public async exec(...[moderator, guild, reason, results]: BushClientEvents['massBan']) { + public async exec(...[moderator, guild, reason, results]: BotClientEvents[TanzaniteEvent.MassBan]) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; diff --git a/src/listeners/member-custom/massEvidence.ts b/src/listeners/member-custom/massEvidence.ts index f0f75df..acfa4f7 100644 --- a/src/listeners/member-custom/massEvidence.ts +++ b/src/listeners/member-custom/massEvidence.ts @@ -1,15 +1,14 @@ -import { BushListener, colors, overflowEmbed, type BushClientEvents } from '#lib'; +import { BotListener, colors, overflowEmbed, TanzaniteEvent, type BotClientEvents } from '#lib'; -export default class MassEvidenceListener extends BushListener { +export default class MassEvidenceListener extends BotListener { public constructor() { - super('massEvidence', { + super(TanzaniteEvent.MassEvidence, { emitter: 'client', - event: 'massEvidence', - category: 'member-custom' + event: TanzaniteEvent.MassEvidence }); } - public async exec(...[moderator, guild, evidence, lines]: BushClientEvents['massEvidence']) { + public async exec(...[moderator, guild, evidence, lines]: BotClientEvents[TanzaniteEvent.MassEvidence]) { const logChannel = await guild.getLogChannel('moderation'); if (!logChannel) return; diff --git a/src/listeners/member-custom/punishRole.ts b/src/listeners/member-custom/punishRole.ts new file mode 100644 index 0000000..70a04d7 --- /dev/null +++ b/src/listeners/member-custom/punishRole.ts @@ -0,0 +1,31 @@ +import { BotListener, colors, humanizeDuration, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class PunishRoleListener extends BotListener { + public constructor() { + super(TanzaniteEvent.PunishRoleAdd, { + emitter: 'client', + event: TanzaniteEvent.PunishRoleAdd + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, duration]: BotClientEvents[TanzaniteEvent.PunishRoleAdd]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Yellow) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${duration ? 'Temp Punishment Role' : 'Perm Punishment Role'}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + if (duration) logEmbed.addFields({ name: '**Duration**', value: humanizeDuration(duration) }); + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/member-custom/punishRoleRemove.ts b/src/listeners/member-custom/punishRoleRemove.ts new file mode 100644 index 0000000..f144284 --- /dev/null +++ b/src/listeners/member-custom/punishRoleRemove.ts @@ -0,0 +1,32 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder, GuildMember } from 'discord.js'; + +export default class PunishRoleRemoveListener extends BotListener { + public constructor() { + super(TanzaniteEvent.PunishRoleRemove, { + emitter: 'client', + event: TanzaniteEvent.PunishRoleRemove + }); + } + + public async exec(...[victim, moderator, guild, reason, caseID, role]: BotClientEvents[TanzaniteEvent.PunishRoleRemove]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + const user = victim instanceof GuildMember ? victim.user : victim; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Green) + .setTimestamp() + .setFooter({ text: `CaseID: ${caseID}` }) + .setAuthor({ name: user.tag, iconURL: user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined }) + .addFields( + { name: '**Action**', value: `${'Remove Punishment Role'}` }, + { name: '**Role**', value: `${role}` }, + { name: '**User**', value: `${user} (${user.tag})` }, + { name: '**Moderator**', value: `${moderator} (${moderator.tag})` }, + { name: '**Reason**', value: `${reason ? reason : '[No Reason Provided]'}` } + ); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/member-custom/updateModlog.ts b/src/listeners/member-custom/updateModlog.ts new file mode 100644 index 0000000..f5f910d --- /dev/null +++ b/src/listeners/member-custom/updateModlog.ts @@ -0,0 +1,40 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder } from 'discord.js'; + +export default class UpdateModlogListener extends BotListener { + public constructor() { + super(TanzaniteEvent.UpdateModlog, { + emitter: 'client', + event: TanzaniteEvent.UpdateModlog + }); + } + + public async exec(...[moderator, modlogID, key, oldModlog, newModlog]: BotClientEvents[TanzaniteEvent.UpdateModlog]) { + const logChannel = await moderator.guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new EmbedBuilder() + .setColor(colors.Blurple) + .setTimestamp() + .setAuthor({ + name: moderator.user.tag, + iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined + }) + .addFields( + { name: '**Action**', value: 'Update Modlog' }, + { name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }, + { name: '**ModLog Changed**', value: modlogID }, + { name: '**Value Changed**', value: key }, + { + name: '**Old Value**', + value: await this.client.utils.inspectCleanRedactCodeblock(oldModlog, undefined, undefined, 1024) + }, + { + name: '**New Value**', + value: await this.client.utils.inspectCleanRedactCodeblock(newModlog, undefined, undefined, 1024) + } + ); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/member-custom/updateSettings.ts b/src/listeners/member-custom/updateSettings.ts new file mode 100644 index 0000000..329212a --- /dev/null +++ b/src/listeners/member-custom/updateSettings.ts @@ -0,0 +1,33 @@ +import { BotListener, colors, TanzaniteEvent, type BotClientEvents } from '#lib'; +import { EmbedBuilder } from 'discord.js'; + +export default class UpdateSettingsListener extends BotListener { + public constructor() { + super(TanzaniteEvent.UpdateSettings, { + emitter: 'client', + event: TanzaniteEvent.UpdateSettings + }); + } + + public async exec(...[setting, guild, oldSettings, newSettings, moderator]: BotClientEvents[TanzaniteEvent.UpdateSettings]) { + const logChannel = await guild.getLogChannel('moderation'); + if (!logChannel) return; + + const logEmbed = new EmbedBuilder().setColor(colors.Blurple).setTimestamp(); + + if (moderator) + logEmbed.setAuthor({ + name: moderator.user.tag, + iconURL: moderator.user.avatarURL({ extension: 'png', size: 4096 }) ?? undefined + }); + logEmbed.addFields({ name: '**Action**', value: `${'Update Settings'}` }); + if (moderator) logEmbed.addFields({ name: '**Moderator**', value: `${moderator} (${moderator.user.tag})` }); + logEmbed.addFields( + { name: '**Setting Changed**', value: setting }, + { name: '**Old Value**', value: await this.client.utils.inspectCleanRedactCodeblock(oldSettings, 'js', undefined, 1024) }, + { name: '**New Value**', value: await this.client.utils.inspectCleanRedactCodeblock(newSettings, 'js', undefined, 1024) } + ); + + return await logChannel.send({ embeds: [logEmbed] }); + } +} diff --git a/src/listeners/message/autoPublisher.ts b/src/listeners/message/autoPublisher.ts index a6fb7e0..36dcbe2 100644 --- a/src/listeners/message/autoPublisher.ts +++ b/src/listeners/message/autoPublisher.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BotListener, type BotClientEvents } from '#lib'; import { ChannelType } from 'discord.js'; -export default class autoPublisherListener extends BushListener { +export default class autoPublisherListener extends BotListener { public constructor() { super('autoPublisher', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['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/blacklistedFile.ts b/src/listeners/message/blacklistedFile.ts index f3e082c..31fbe9d 100644 --- a/src/listeners/message/blacklistedFile.ts +++ b/src/listeners/message/blacklistedFile.ts @@ -1,9 +1,9 @@ -// import { BushListener, type BushClientEvents } from '#lib'; +// import { CustomListener, type CustomClientEvents } from '#lib'; // import * as crypto from 'crypto'; // import { ChannelType } from 'discord.js'; // import got from 'got'; -// export default class BlacklistedFileListener extends BushListener { +// export default class BlacklistedFileListener extends CustomListener { // #blacklistedFiles: { hash: string[]; name: string; description: string }[] = [ // { // hash: ['a0f5e30426234bc9d09306ffc9474422'], @@ -61,11 +61,10 @@ // super('blacklistedFile', { // emitter: 'client', // event: 'messageCreate', -// category: 'message' // }); // } -// public async exec(...[message]: BushClientEvents['messageCreate']) { +// public async exec(...[message]: CustomClientEvents['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(/<(?a?):\w+:(?\d+)>/g)]; diff --git a/src/listeners/message/boosterMessage.ts b/src/listeners/message/boosterMessage.ts index 0879ced..43fb04e 100644 --- a/src/listeners/message/boosterMessage.ts +++ b/src/listeners/message/boosterMessage.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BotListener, type BotClientEvents } from '#lib'; import { MessageType } from 'discord.js'; -export default class BoosterMessageListener extends BushListener { +export default class BoosterMessageListener extends BotListener { public constructor() { super('boosterMessage', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['messageCreate']) { if (!message.guild || !(await message.guild?.hasFeature('boosterMessageReact'))) return; if ( [MessageType.GuildBoost, MessageType.GuildBoostTier1, MessageType.GuildBoostTier2, MessageType.GuildBoostTier3].includes( diff --git a/src/listeners/message/directMessage.ts b/src/listeners/message/directMessage.ts index 7278e63..efa5bb6 100644 --- a/src/listeners/message/directMessage.ts +++ b/src/listeners/message/directMessage.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, type BushClientEvents } from '#lib'; +import { BotListener, colors, type BotClientEvents } from '#lib'; import { ChannelType, EmbedBuilder } from 'discord.js'; -export default class DirectMessageListener extends BushListener { +export default class DirectMessageListener extends BotListener { public constructor() { super('directMessage', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['messageCreate']) { if (message.channel.type === ChannelType.DM) { if (!(message.author.id == this.client.user!.id) && message.author.bot) return; if (this.client.cache.global.blacklistedUsers.includes(message.author.id)) return; diff --git a/src/listeners/message/highlight.ts b/src/listeners/message/highlight.ts index d9d3c0b..d5d8304 100644 --- a/src/listeners/message/highlight.ts +++ b/src/listeners/message/highlight.ts @@ -1,15 +1,14 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BotListener, type BotClientEvents } from '#lib'; -export default class HighlightListener extends BushListener { +export default class HighlightListener extends BotListener { public constructor() { super('highlight', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['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 526dac9..5c314a8 100644 --- a/src/listeners/message/level.ts +++ b/src/listeners/message/level.ts @@ -1,17 +1,16 @@ -import { BushListener, Level, type BushCommandHandlerEvents } from '#lib'; +import { BotListener, Level, TanzaniteEvent, type BotCommandHandlerEvents } from '#lib'; import { MessageType } from 'discord.js'; -export default class LevelListener extends BushListener { +export default class LevelListener extends BotListener { #levelCooldowns: Set = new Set(); public constructor() { super('level', { emitter: 'commandHandler', - event: 'messageInvalid', // Using messageInvalid here so commands don't give xp - category: 'message' + event: 'messageInvalid' // Using messageInvalid here so commands don't give xp }); } - public async exec(...[message]: BushCommandHandlerEvents['messageInvalid']) { + public async exec(...[message]: BotCommandHandlerEvents['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; @@ -38,7 +37,7 @@ export default class LevelListener extends BushListener { }); const newLevel = Level.convertXpToLevel(user.xp); if (previousLevel !== newLevel) - this.client.emit('bushLevelUpdate', message.member!, previousLevel, newLevel, user.xp, message); + this.client.emit(TanzaniteEvent.LevelUpdate, message.member!, previousLevel, newLevel, user.xp, message); if (success) void this.client.logger.verbose(`level`, `Gave <<${xpToGive}>> XP to <<${message.author.tag}>> in <<${message.guild}>>.`); this.#levelCooldowns.add(`${message.guildId}-${message.author.id}`); diff --git a/src/listeners/message/quoteCreate.ts b/src/listeners/message/quoteCreate.ts index 166bbb7..9bad9b8 100644 --- a/src/listeners/message/quoteCreate.ts +++ b/src/listeners/message/quoteCreate.ts @@ -1,15 +1,14 @@ -import { BushListener, mappings, type BushClientEvents } from '#lib'; +import { BotListener, mappings, type BotClientEvents } from '#lib'; -export default class QuoteCreateListener extends BushListener { +export default class QuoteCreateListener extends BotListener { public constructor() { super('quoteCreate', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public async exec(...[message]: BushClientEvents['messageCreate']) { + public async exec(...[message]: BotClientEvents['messageCreate']) { if (message.author.id !== mappings.users['IRONM00N'] || !this.client.config.isProduction) return; if (!message.inGuild()) return; diff --git a/src/listeners/message/quoteEdit.ts b/src/listeners/message/quoteEdit.ts index 7da0d95..8422026 100644 --- a/src/listeners/message/quoteEdit.ts +++ b/src/listeners/message/quoteEdit.ts @@ -1,15 +1,14 @@ -// import { BushListener, type BushClientEvents } from '#lib'; +// import { CustomListener, type CustomClientEvents } from '#lib'; -// export default class QuoteEditListener extends BushListener { +// export default class QuoteEditListener extends CustomListener { // public constructor() { // super('quoteEdit', { // emitter: 'client', // event: 'messageUpdate', -// category: 'message' // }); // } -// public async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) { +// public async exec(...[_, newMessage]: CustomClientEvents['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 f5e94de..9c4ac3a 100644 --- a/src/listeners/message/verbose.ts +++ b/src/listeners/message/verbose.ts @@ -1,16 +1,15 @@ -import { BushListener, type BushClientEvents } from '#lib'; +import { BotListener, type BotClientEvents } from '#lib'; import { ChannelType } from 'discord.js'; -export default class MessageVerboseListener extends BushListener { +export default class MessageVerboseListener extends BotListener { public constructor() { super('messageVerbose', { emitter: 'client', - event: 'messageCreate', - category: 'message' + event: 'messageCreate' }); } - public exec(...[message]: BushClientEvents['messageCreate']): void { + public exec(...[message]: BotClientEvents['messageCreate']): void { if (this.client.customReady) { if (message.channel?.type === ChannelType.DM) return; void this.client.console.verbose( diff --git a/src/listeners/other/consoleListener.ts b/src/listeners/other/consoleListener.ts index b9da46e..dc6b66b 100644 --- a/src/listeners/other/consoleListener.ts +++ b/src/listeners/other/consoleListener.ts @@ -1,60 +1,60 @@ -import { BushListener } from '#lib'; -import { exec } from 'child_process'; -import { promisify } from 'util'; +// import { CustomListener } from '#lib'; +// import { exec } from 'child_process'; +// import { promisify } from 'util'; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -/* export default */ class ConsoleListener extends BushListener { - public constructor() { - super('console', { - emitter: 'stdin', - event: 'line' - }); - } +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// /* export default */ class ConsoleListener extends CustomListener { +// public constructor() { +// super('console', { +// emitter: 'stdin', +// event: 'line' +// }); +// } - public async exec(line: string) { - if (line.startsWith('eval ') || line.startsWith('ev ')) { - /* eslint-disable @typescript-eslint/no-unused-vars */ - const sh = promisify(exec), - bot = this.client, - client = this.client, - config = this.client.config, - { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('#lib'), - { - ButtonInteraction, - Collector, - CommandInteraction, - Message, - ActionRow, - Attachment, - ButtonComponent, - MessageCollector, - InteractionCollector, - Embed, - SelectMenuComponent, - ReactionCollector, - Collection - } = await import('discord.js'); - /* eslint-enable @typescript-eslint/no-unused-vars */ - try { - const depth = /--depth (?\d+)/.exec(line)?.groups?.depth ?? undefined; - const hidden = /--hidden/.test(line); - if (depth) line = line.replace(/--depth \d+/, ''); - if (hidden) line = line.replace(/--hidden/, ''); - const input = line.replace('eval ', '').replace('ev ', ''); - const output = await eval(input); - console.dir(output, { - colors: true, - getters: true, - maxArrayLength: Infinity, - maxStringLength: Infinity, - depth: +(depth ?? 2), - showHidden: hidden - }); - } catch (e) { - console.error(e); - } - } else if (line.startsWith('stop')) { - process.exit(0); - } - } -} +// public async exec(line: string) { +// if (line.startsWith('eval ') || line.startsWith('ev ')) { +// /* eslint-disable @typescript-eslint/no-unused-vars */ +// const sh = promisify(exec), +// bot = this.client, +// client = this.client, +// config = this.client.config, +// { ActivePunishment, Global, Guild, Level, ModLog, StickyRole } = await import('#lib'), +// { +// ButtonInteraction, +// Collector, +// CommandInteraction, +// Message, +// ActionRow, +// Attachment, +// ButtonComponent, +// MessageCollector, +// InteractionCollector, +// Embed, +// SelectMenuComponent, +// ReactionCollector, +// Collection +// } = await import('discord.js'); +// /* eslint-enable @typescript-eslint/no-unused-vars */ +// try { +// const depth = /--depth (?\d+)/.exec(line)?.groups?.depth ?? undefined; +// const hidden = /--hidden/.test(line); +// if (depth) line = line.replace(/--depth \d+/, ''); +// if (hidden) line = line.replace(/--hidden/, ''); +// const input = line.replace('eval ', '').replace('ev ', ''); +// const output = await eval(input); +// console.dir(output, { +// colors: true, +// getters: true, +// maxArrayLength: Infinity, +// maxStringLength: Infinity, +// depth: +(depth ?? 2), +// showHidden: hidden +// }); +// } catch (e) { +// console.error(e); +// } +// } else if (line.startsWith('stop')) { +// process.exit(0); +// } +// } +// } diff --git a/src/listeners/other/exit.ts b/src/listeners/other/exit.ts index ac074df..e1c8fee 100644 --- a/src/listeners/other/exit.ts +++ b/src/listeners/other/exit.ts @@ -1,6 +1,6 @@ -import { BushListener } from '#lib'; +import { BotListener } from '#lib'; -export default class ExitListener extends BushListener { +export default class ExitListener extends BotListener { public constructor() { super('exit', { emitter: 'process', diff --git a/src/listeners/other/promiseRejection.ts b/src/listeners/other/promiseRejection.ts index 4ff6c0e..b56cef9 100644 --- a/src/listeners/other/promiseRejection.ts +++ b/src/listeners/other/promiseRejection.ts @@ -1,6 +1,6 @@ -import { BushListener, formatError, generateErrorEmbed } from '#lib'; +import { BotListener, formatError, generateErrorEmbed } from '#lib'; -export default class PromiseRejectionListener extends BushListener { +export default class PromiseRejectionListener extends BotListener { public constructor() { super('promiseRejection', { emitter: 'process', diff --git a/src/listeners/other/uncaughtException.ts b/src/listeners/other/uncaughtException.ts index c976a22..ab1c1b7 100644 --- a/src/listeners/other/uncaughtException.ts +++ b/src/listeners/other/uncaughtException.ts @@ -1,6 +1,6 @@ -import { BushListener, formatError, generateErrorEmbed } from '#lib'; +import { BotListener, formatError, generateErrorEmbed } from '#lib'; -export default class UncaughtExceptionListener extends BushListener { +export default class UncaughtExceptionListener extends BotListener { public constructor() { super('uncaughtException', { emitter: 'process', diff --git a/src/listeners/other/warning.ts b/src/listeners/other/warning.ts index 5cf9764..7fdcd46 100644 --- a/src/listeners/other/warning.ts +++ b/src/listeners/other/warning.ts @@ -1,6 +1,6 @@ -import { BushListener, colors, formatError, generateErrorEmbed } from '#lib'; +import { BotListener, colors, formatError, generateErrorEmbed } from '#lib'; -export default class WarningListener extends BushListener { +export default class WarningListener extends BotListener { public constructor() { super('warning', { emitter: 'process', diff --git a/src/listeners/rest/rateLimit.ts b/src/listeners/rest/rateLimit.ts index 9071416..46e5471 100644 --- a/src/listeners/rest/rateLimit.ts +++ b/src/listeners/rest/rateLimit.ts @@ -1,12 +1,11 @@ -import { BushListener } from '#lib'; +import { BotListener } from '#lib'; import type { RestEvents } from '@discordjs/rest'; -export default class RateLimitedListener extends BushListener { +export default class RateLimitedListener extends BotListener { public constructor() { super('rateLimited', { emitter: 'rest', - event: 'rateLimited', - category: 'rest' + event: 'rateLimited' }); } diff --git a/src/listeners/track-manual-punishments/modlogSyncBan.ts b/src/listeners/track-manual-punishments/modlogSyncBan.ts index 3c0ff34..5ecb8f3 100644 --- a/src/listeners/track-manual-punishments/modlogSyncBan.ts +++ b/src/listeners/track-manual-punishments/modlogSyncBan.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; +import { BotListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BotClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; -export default class ModlogSyncBanListener extends BushListener { +export default class ModlogSyncBanListener extends BotListener { public constructor() { super('modlogSyncBan', { emitter: 'client', - event: 'guildBanAdd', - category: 'guild' + event: 'guildBanAdd' }); } - public async exec(...[ban]: BushClientEvents['guildBanAdd']) { + public async exec(...[ban]: BotClientEvents['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)) { diff --git a/src/listeners/track-manual-punishments/modlogSyncKick.ts b/src/listeners/track-manual-punishments/modlogSyncKick.ts index 7f7e9bc..fc3fab9 100644 --- a/src/listeners/track-manual-punishments/modlogSyncKick.ts +++ b/src/listeners/track-manual-punishments/modlogSyncKick.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; +import { BotListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BotClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; -export default class ModlogSyncKickListener extends BushListener { +export default class ModlogSyncKickListener extends BotListener { public constructor() { super('modlogSyncKick', { emitter: 'client', - event: 'guildMemberRemove', - category: 'guild' + event: 'guildMemberRemove' }); } - public async exec(...[member]: BushClientEvents['guildMemberRemove']) { + public async exec(...[member]: BotClientEvents['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)) { diff --git a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts index 50d1331..6248654 100644 --- a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts +++ b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; +import { BotListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BotClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; -export default class ModlogSyncTimeoutListener extends BushListener { +export default class ModlogSyncTimeoutListener extends BotListener { public constructor() { super('modlogSyncTimeout', { emitter: 'client', - event: 'guildMemberUpdate', - category: 'guild' + event: 'guildMemberUpdate' }); } - public async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[_oldMember, newMember]: BotClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('logManualPunishments'))) return; if (!newMember.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return newMember.guild.error( diff --git a/src/listeners/track-manual-punishments/modlogSyncUnban.ts b/src/listeners/track-manual-punishments/modlogSyncUnban.ts index 8dfd39b..96de018 100644 --- a/src/listeners/track-manual-punishments/modlogSyncUnban.ts +++ b/src/listeners/track-manual-punishments/modlogSyncUnban.ts @@ -1,16 +1,15 @@ -import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; +import { BotListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BotClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; -export default class ModlogSyncUnbanListener extends BushListener { +export default class ModlogSyncUnbanListener extends BotListener { public constructor() { super('modlogSyncUnban', { emitter: 'client', - event: 'guildBanRemove', - category: 'guild' + event: 'guildBanRemove' }); } - public async exec(...[ban]: BushClientEvents['guildBanRemove']) { + public async exec(...[ban]: BotClientEvents['guildBanRemove']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return ban.guild.error( diff --git a/src/listeners/ws/INTERACTION_CREATE.ts b/src/listeners/ws/INTERACTION_CREATE.ts index 67fe56b..250d8b5 100644 --- a/src/listeners/ws/INTERACTION_CREATE.ts +++ b/src/listeners/ws/INTERACTION_CREATE.ts @@ -1,4 +1,4 @@ -import { BushListener, capitalize, colors, emojis, Moderation, PunishmentTypePresent } from '#lib'; +import { BotListener, capitalize, colors, emojis, Moderation, PunishmentTypePresent } from '#lib'; import assert from 'assert/strict'; import { ActionRowBuilder, @@ -21,12 +21,11 @@ import { type APIModalInteractionResponse } from 'discord.js'; -export default class WsInteractionCreateListener extends BushListener { +export default class WsInteractionCreateListener extends BotListener { public constructor() { super('wsInteractionCreate', { emitter: 'ws', - event: GatewayDispatchEvents.InteractionCreate, - category: 'ws' + event: GatewayDispatchEvents.InteractionCreate }); } -- cgit