Much more typing
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index bfae11a..1908b7f 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -1,11 +1,19 @@
+import type { GuildAuditLogsEntry, ThreadChannel } from "discord.js";
+// @ts-expect-error
import humanizeDuration from "humanize-duration";
+// @ts-expect-error
+import type { HaikuClient } from "jshaiku"
export const event = "threadDelete";
-export async function callback(client, thread) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+export async function callback(client: HaikuClient, thread: ThreadChannel) {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
- const audit = auditLog.entries.filter((entry) => entry.target.id === thread.id).first();
+ 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 data = {
meta: {
type: "channelDelete",
@@ -18,14 +26,11 @@
list: {
threadId: entry(thread.id, `\`${thread.id}\``),
name: entry(thread.name, thread.name),
- parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
- category: entry(
- thread.parent.parent ? thread.parent.parent.name : "None",
- thread.parent.parent ? renderChannel(thread.parent.parent) : "None"
- ),
+ parentChannel: entry(thread.parentId, thread.parent ? renderChannel(thread.parent) : "*None*"),
+ category: category,
autoArchiveDuration: entry(
thread.autoArchiveDuration,
- humanizeDuration(thread.autoArchiveDuration * 60 * 1000, {
+ humanizeDuration((thread.autoArchiveDuration ?? 0) * 60 * 1000, {
round: true
})
),