diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-16 14:32:18 -0400 |
commit | 0e87bbd3940d89defcb04926587b35c8f4d1947f (patch) | |
tree | e50860d4dc25a11d4c3977b583284c4bcad1b077 /src/listeners/track-manual-punishments | |
parent | 661e4c9935aeb8760dafc7ced4bbec6cc356a033 (diff) | |
download | tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.gz tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.bz2 tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.zip |
remove util classes, move config out of src
Diffstat (limited to 'src/listeners/track-manual-punishments')
4 files changed, 20 insertions, 28 deletions
diff --git a/src/listeners/track-manual-punishments/modlogSyncBan.ts b/src/listeners/track-manual-punishments/modlogSyncBan.ts index be937b9..45d6f51 100644 --- a/src/listeners/track-manual-punishments/modlogSyncBan.ts +++ b/src/listeners/track-manual-punishments/modlogSyncBan.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncBanListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncBanListener extends BushListener { }); } - public override async exec(...[ban]: BushClientEvents['guildBanAdd']) { + public async exec(...[ban]: BushClientEvents['guildBanAdd']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.members.me) return; // bot was banned if (!ban.guild.members.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { @@ -21,7 +21,7 @@ export default class ModlogSyncBanListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await ban.guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanAdd })).entries.filter( (entry) => entry.target?.id === ban.user.id @@ -33,9 +33,7 @@ export default class ModlogSyncBanListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -51,7 +49,7 @@ export default class ModlogSyncBanListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncKick.ts b/src/listeners/track-manual-punishments/modlogSyncKick.ts index d136780..d901f5f 100644 --- a/src/listeners/track-manual-punishments/modlogSyncKick.ts +++ b/src/listeners/track-manual-punishments/modlogSyncKick.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncKickListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncKickListener extends BushListener { }); } - public override async exec(...[member]: BushClientEvents['guildMemberRemove']) { + public async exec(...[member]: BushClientEvents['guildMemberRemove']) { if (!(await member.guild.hasFeature('logManualPunishments'))) return; if (!member.guild.members.me) return; // bot was removed from guild if (!member.guild.members.me.permissions.has(PermissionFlagsBits.ViewAuditLog)) { @@ -21,7 +21,7 @@ export default class ModlogSyncKickListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await member.guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick })).entries.filter( (entry) => entry.target?.id === member.user.id @@ -33,9 +33,7 @@ export default class ModlogSyncKickListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -51,7 +49,7 @@ export default class ModlogSyncKickListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Red) + .setColor(colors.Red) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts index adcd7fe..4619edd 100644 --- a/src/listeners/track-manual-punishments/modlogSyncTimeout.ts +++ b/src/listeners/track-manual-punishments/modlogSyncTimeout.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncTimeoutListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { }); } - public override async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { + public async exec(...[_oldMember, newMember]: BushClientEvents['guildMemberUpdate']) { if (!(await newMember.guild.hasFeature('logManualPunishments'))) return; if (!newMember.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return newMember.guild.error( @@ -20,7 +20,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await newMember.guild.fetchAuditLogs({ type: AuditLogEvent.MemberUpdate })).entries.filter( (entry) => entry.target?.id === newMember.user.id @@ -35,9 +35,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { if (!timeOut) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const newTime = <string | null>timeOut.new ? new Date(<string>timeOut.new) : null; @@ -56,7 +54,7 @@ export default class ModlogSyncTimeoutListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors[newTime ? 'Orange' : 'Green']) + .setColor(colors[newTime ? 'Orange' : 'Green']) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ diff --git a/src/listeners/track-manual-punishments/modlogSyncUnban.ts b/src/listeners/track-manual-punishments/modlogSyncUnban.ts index af0b21f..34979a5 100644 --- a/src/listeners/track-manual-punishments/modlogSyncUnban.ts +++ b/src/listeners/track-manual-punishments/modlogSyncUnban.ts @@ -1,4 +1,4 @@ -import { BushListener, Moderation, ModLogType, Time, type BushClientEvents } from '#lib'; +import { BushListener, colors, humanizeDuration, Moderation, ModLogType, sleep, Time, type BushClientEvents } from '#lib'; import { AuditLogEvent, EmbedBuilder, PermissionFlagsBits } from 'discord.js'; export default class ModlogSyncUnbanListener extends BushListener { @@ -10,7 +10,7 @@ export default class ModlogSyncUnbanListener extends BushListener { }); } - public override async exec(...[ban]: BushClientEvents['guildBanRemove']) { + public async exec(...[ban]: BushClientEvents['guildBanRemove']) { if (!(await ban.guild.hasFeature('logManualPunishments'))) return; if (!ban.guild.members.me!.permissions.has(PermissionFlagsBits.ViewAuditLog)) { return ban.guild.error( @@ -20,7 +20,7 @@ export default class ModlogSyncUnbanListener extends BushListener { } const now = new Date(); - await util.sleep(500 * Time.Millisecond); // wait for audit log entry + await sleep(500 * Time.Millisecond); // wait for audit log entry const logs = (await ban.guild.fetchAuditLogs({ type: AuditLogEvent.MemberBanRemove })).entries.filter( (entry) => entry.target?.id === ban.user.id @@ -32,9 +32,7 @@ export default class ModlogSyncUnbanListener extends BushListener { if (!first.executor || first.executor?.bot) return; if (Math.abs(first.createdAt.getTime() - now.getTime()) > Time.Minute) { - throw new Error( - `Time is off by over a minute: ${util.humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}` - ); + throw new Error(`Time is off by over a minute: ${humanizeDuration(Math.abs(first.createdAt.getTime() - now.getTime()))}`); } const { log } = await Moderation.createModLogEntry({ @@ -50,7 +48,7 @@ export default class ModlogSyncUnbanListener extends BushListener { if (!logChannel) return; const logEmbed = new EmbedBuilder() - .setColor(util.colors.Orange) + .setColor(colors.Orange) .setTimestamp() .setFooter({ text: `CaseID: ${log.id}` }) .setAuthor({ |