Fix various issues pre-switching-to-bun
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index a05389f..9f4c47a 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,4 +1,4 @@
-import type { GuildAuditLogsEntry, GuildBan } from 'discord.js';
+import type { GuildAuditLogsEntry, GuildBan } from "discord.js";
import { purgeByUser } from "../actions/tickets/delete.js";
import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
// @ts-expect-error
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 86d6efe..5f1499d 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,4 +1,4 @@
-import type { GuildAuditLogsEntry, GuildBan } from 'discord.js';
+import type { GuildAuditLogsEntry, GuildBan } from "discord.js";
import { purgeByUser } from "../actions/tickets/delete.js";
// @ts-expect-error
import type { HaikuClient } from "jshaiku";
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index ea9008d..3274727 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,6 +1,6 @@
// @ts-expect-error
import type { HaikuClient } from "jshaiku";
-import type { Guild, GuildAuditLogsEntry } from 'discord.js';
+import type { Guild, GuildAuditLogsEntry } from "discord.js";
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
export const event = "guildUpdate";
@@ -31,8 +31,8 @@
NONE: "None",
ELEVATED: "Enabled"
};
- const beforeOwner = await before.fetchOwner()
- const afterOwner = await after.fetchOwner()
+ const beforeOwner = await before.fetchOwner();
+ const afterOwner = await after.fetchOwner();
if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
if (before.icon !== after.icon)
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 9ee7bee..a00baf8 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -11,7 +11,7 @@
export const event = "interactionCreate";
-function getAutocomplete(typed: string, options: string[]): {name: string, value: string}[] {
+function getAutocomplete(typed: string, options: string[]): { name: string; value: string }[] {
options = options.filter((option) => option.length <= 100); // thanks discord. 6000 character limit on slash command inputs but only 100 for autocomplete.
if (!typed)
return options
@@ -65,8 +65,11 @@
}
async function interactionCreate(interaction: Interaction) {
- if (interaction.type === "MESSAGE_COMPONENT" && (interaction as MessageComponentInteraction).componentType === "BUTTON") {
- const int = (interaction as MessageComponentInteraction)
+ if (
+ interaction.type === "MESSAGE_COMPONENT" &&
+ (interaction as MessageComponentInteraction).componentType === "BUTTON"
+ ) {
+ const int = interaction as MessageComponentInteraction;
switch (int.customId) {
case "rolemenu": {
return await roleMenu(interaction);
@@ -85,24 +88,16 @@
}
}
} else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
- const int = (interaction as AutocompleteInteraction)
- switch (
- `${int.commandName} ${int.options.getSubcommandGroup(
- false
- )} ${int.options.getSubcommand(false)}`
- ) {
+ const int = interaction as AutocompleteInteraction;
+ switch (`${int.commandName} ${int.options.getSubcommandGroup(false)} ${int.options.getSubcommand(false)}`) {
case "tag null null": {
- return int.respond(
- getAutocomplete(int.options.getString("tag") ?? "", await tagAutocomplete(int))
- );
+ return int.respond(getAutocomplete(int.options.getString("tag") ?? "", await tagAutocomplete(int)));
}
case "settings null stats": {
return int.respond(generateStatsChannelAutocomplete(int.options.getString("name") ?? ""));
}
case "settings null welcome": {
- return int.respond(
- generateWelcomeMessageAutocomplete(int.options.getString("message") ?? "")
- );
+ return int.respond(generateWelcomeMessageAutocomplete(int.options.getString("message") ?? ""));
}
}
}
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index fb35b7e..735ec21 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -9,7 +9,9 @@
export async function callback(client: HaikuClient, invite: Invite) {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const auditLog = await getAuditLog(invite.guild, "INVITE_CREATE");
- const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === invite.inviterId).first();
+ const audit = auditLog.entries
+ .filter((entry: GuildAuditLogsEntry) => entry.target!.id === invite.inviterId)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index b07893a..375a693 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -9,7 +9,9 @@
export async function callback(client: HaikuClient, invite: Invite) {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
- const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === invite.inviterId).first();
+ const audit = auditLog.entries
+ .filter((entry: GuildAuditLogsEntry) => entry.target!.id === invite.inviterId)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index f2301e0..0527a60 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -10,7 +10,9 @@
if (client.noLog.includes(`${message.id}/${message.channel.id}/${message.id}`)) return;
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
- const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === message.author.id).first();
+ const audit = auditLog.entries
+ .filter((entry: GuildAuditLogsEntry) => entry.target!.id === message.author.id)
+ .first();
if (audit) {
if (audit.createdAt - 100 < new Date().getTime()) return;
}
@@ -54,7 +56,9 @@
repliedTo: entry(
replyTo,
replyTo
- ? `[[Jump to message]](https://discord.com/channels/${message.guild!.id}/${message.channel.id}/${replyTo.messageId})`
+ ? `[[Jump to message]](https://discord.com/channels/${message.guild!.id}/${
+ message.channel.id
+ }/${replyTo.messageId})`
: "None"
)
},
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 01d6c2c..76bb6f1 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,5 +1,5 @@
// @ts-expect-error
-import type { HaikuClient } from "jshaiku"
+import type { HaikuClient } from "jshaiku";
import type { GuildAuditLogsEntry, Sticker } from "discord.js";
export const event = "stickerDelete";
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index c9b3fab..18dcc80 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,5 +1,5 @@
// @ts-expect-error
-import type { HaikuClient } from "jshaiku"
+import type { HaikuClient } from "jshaiku";
import type { GuildAuditLogsEntry, Sticker } from "discord.js";
export const event = "stickerDelete";
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index c6e3b6e..e2ed1f9 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,5 +1,5 @@
// @ts-expect-error
-import type { HaikuClient } from "jshaiku"
+import type { HaikuClient } from "jshaiku";
import type { Sticker } from "discord.js";
export const event = "stickerUpdate";
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index e8849c9..5d0be0b 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -2,7 +2,7 @@
// @ts-expect-error
import humanizeDuration from "humanize-duration";
// @ts-expect-error
-import type { HaikuClient } from "jshaiku"
+import type { HaikuClient } from "jshaiku";
export const event = "threadCreate";
export async function callback(client: HaikuClient, thread: ThreadChannel) {
@@ -10,10 +10,12 @@
const auditLog = await getAuditLog(thread.guild, "THREAD_CREATE");
const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === thread.id).first();
if (audit.executor.id === client.user.id) return;
- const category = thread.parent ? entry(
- thread.parent.parent ? thread.parent.parent.name : "None",
- thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
- ) : entry(null, "Uncategorised")
+ const category = thread.parent
+ ? entry(
+ thread.parent.parent ? thread.parent.parent.name : "None",
+ thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
+ )
+ : entry(null, "Uncategorised");
const data = {
meta: {
type: "channelCreate",
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 1908b7f..fba3007 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -2,7 +2,7 @@
// @ts-expect-error
import humanizeDuration from "humanize-duration";
// @ts-expect-error
-import type { HaikuClient } from "jshaiku"
+import type { HaikuClient } from "jshaiku";
export const event = "threadDelete";
export async function callback(client: HaikuClient, thread: ThreadChannel) {
@@ -10,10 +10,12 @@
const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === thread.id).first();
if (audit.executor.id === client.user.id) return;
- const category = thread.parent ? entry(
- thread.parent.parent ? thread.parent.parent.name : "None",
- thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
- ) : entry(null, "Uncategorised")
+ const category = thread.parent
+ ? entry(
+ thread.parent.parent ? thread.parent.parent.name : "None",
+ thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
+ )
+ : entry(null, "Uncategorised");
const data = {
meta: {
type: "channelDelete",
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 4df2587..0077330 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -32,7 +32,9 @@
if (before.rateLimitPerUser !== after.rateLimitPerUser) {
list["slowmode"] = entry(
[before.rateLimitPerUser, after.rateLimitPerUser],
- `${humanizeDuration((before.rateLimitPerUser ?? 0) * 1000)} -> ${humanizeDuration((after.rateLimitPerUser ?? 0) * 1000)}`
+ `${humanizeDuration((before.rateLimitPerUser ?? 0) * 1000)} -> ${humanizeDuration(
+ (after.rateLimitPerUser ?? 0) * 1000
+ )}`
);
}
if (!(Object.keys(list).length - 3)) return;
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index c58a340..6187253 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -15,25 +15,34 @@
auditLogUpdate,
auditLogDelete
]);
- const auditCreate = auditLogCreate.entries.filter((entry: GuildAuditLogsEntry | null) => {
- if (entry === null) return false
- return (entry.target! as Webhook).channelId === channel.id}
- ).first();
- const auditUpdate = auditLogUpdate.entries.filter((entry: GuildAuditLogsEntry | null) => {
- if (entry === null) return false
- return (entry.target! as Webhook).channelId === channel.id}
- ).first();
- const auditDelete = auditLogDelete.entries.filter((entry: GuildAuditLogsEntry | null) => {
- if (entry === null) return false
- return (entry.target! as Webhook).channelId === channel.id}
- ).first();
+ const auditCreate = auditLogCreate.entries
+ .filter((entry: GuildAuditLogsEntry | null) => {
+ if (entry === null) return false;
+ return (entry.target! as Webhook).channelId === channel.id;
+ })
+ .first();
+ const auditUpdate = auditLogUpdate.entries
+ .filter((entry: GuildAuditLogsEntry | null) => {
+ if (entry === null) return false;
+ return (entry.target! as Webhook).channelId === channel.id;
+ })
+ .first();
+ const auditDelete = auditLogDelete.entries
+ .filter((entry: GuildAuditLogsEntry | null) => {
+ if (entry === null) return false;
+ return (entry.target! as Webhook).channelId === channel.id;
+ })
+ .first();
if (!auditCreate && !auditUpdate && !auditDelete) return;
let audit = auditCreate;
let action: "Create" | "Update" | "Delete" = "Create";
let list: Record<string, ReturnType<typeof entry> | string> = {};
if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
const { before, after } = auditUpdate.changes.reduce(
- (acc: {before: Record<string, string>, after: Record<string, string>}, change: {key: string, new: string, old: string}) => {
+ (
+ acc: { before: Record<string, string>; after: Record<string, string> },
+ change: { key: string; new: string; old: string }
+ ) => {
acc.before[change.key] = change.old;
acc.after[change.key] = change.new;
return acc;
@@ -50,14 +59,20 @@
renderChannel(await client.channels.fetch(after.channel_id))
);
if (!Object.keys(list).length) return;
- list["created"] = entry(auditUpdate.target.createdTimestamp, renderDelta(auditUpdate.target.createdTimestamp));
+ list["created"] = entry(
+ auditUpdate.target.createdTimestamp,
+ renderDelta(auditUpdate.target.createdTimestamp)
+ );
list["edited"] = entry(after.editedTimestamp, renderDelta(new Date().getTime()));
list["editedBy"] = entry(auditUpdate.executor.id, renderUser(auditUpdate.executor));
audit = auditUpdate;
action = "Update";
} else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
const { before } = auditDelete.changes.reduce(
- (acc: {before: Record<string, string>, after: Record<string, string>}, change: {key: string, new: string, old: string}) => {
+ (
+ acc: { before: Record<string, string>; after: Record<string, string> },
+ change: { key: string; new: string; old: string }
+ ) => {
acc.before[change.key] = change.old;
acc.after[change.key] = change.new;
return acc;
@@ -78,7 +93,10 @@
action = "Delete";
} else {
const { before } = auditDelete.changes.reduce(
- (acc: {before: Record<string, string>, after: Record<string, string>}, change: {key: string, new: string, old: string}) => {
+ (
+ acc: { before: Record<string, string>; after: Record<string, string> },
+ change: { key: string; new: string; old: string }
+ ) => {
acc.before[change.key] = change.old;
acc.after[change.key] = change.new;
return acc;