Much more typing
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 3a72876..f2301e0 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,17 +1,20 @@
+// @ts-expect-error
+import type { HaikuClient } from "jshaiku";
+import type { GuildAuditLogsEntry, Message } from "discord.js";
+
export const event = "messageDelete";
-export async function callback(client, message) {
+export async function callback(client: HaikuClient, message: Message) {
try {
if (message.author.id === client.user.id) return;
- if (client.noLog.includes(`${message.guild.id}/${message.channel.id}/${message.id}`)) return;
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } =
- message.channel.client.logger;
+ 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) => 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;
}
- message.reference = message.reference || {};
+ const replyTo = message.reference;
let content = message.cleanContent;
content.replace("`", "\\`");
if (content.length > 256) content = content.substring(0, 253) + "...";
@@ -23,7 +26,7 @@
) ?? []
).length;
let attachmentJump = "";
- const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[
+ const config = (await client.database.guilds.read(message.guild!.id)).logging.attachments.saved[
message.channel.id + message.id
];
if (config) {
@@ -49,14 +52,14 @@
mentions: message.mentions.users.size,
attachments: entry(attachments, attachments + attachmentJump),
repliedTo: entry(
- message.reference.messageId || null,
- message.reference.messageId
- ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})`
+ replyTo,
+ replyTo
+ ? `[[Jump to message]](https://discord.com/channels/${message.guild!.id}/${message.channel.id}/${replyTo.messageId})`
: "None"
)
},
hidden: {
- guild: message.channel.guild.id
+ guild: message.guild!.id
}
};
log(data);