Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index fa66755..c4c1347 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,71 +1,70 @@
-export const event = 'channelCreate'
+export const event = "channelCreate";
export async function callback(client, channel) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
- let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
- if (audit.executor.id === client.user.id) return;
- let emoji;
- let readableType;
- let displayName;
- switch (channel.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Text";
- displayName = "Text Channel"
- break;
- }
- case 'GUILD_NEWS': {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Announcement";
- displayName = "Announcement Channel"
- break;
- }
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.CREATE";
- readableType = "Voice";
- displayName = "Voice Channel"
- break;
- }
- case 'GUILD_STAGE': {
- emoji = "CHANNEL.VOICE.CREATE";
- readableType = "Stage";
- displayName = "Stage Channel"
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.CREATE";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Channel";
- displayName = "Channel"
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger;
+ const auditLog = await getAuditLog(channel.guild, "CHANNEL_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+ if (audit.executor.id === client.user.id) return;
+ let emoji;
+ let readableType;
+ let displayName;
+ switch (channel.type) {
+ case "GUILD_TEXT": {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Text";
+ displayName = "Text Channel";
+ break;
+ }
+ case "GUILD_NEWS": {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Announcement";
+ displayName = "Announcement Channel";
+ break;
+ }
+ case "GUILD_VOICE": {
+ emoji = "CHANNEL.VOICE.CREATE";
+ readableType = "Voice";
+ displayName = "Voice Channel";
+ break;
+ }
+ case "GUILD_STAGE": {
+ emoji = "CHANNEL.VOICE.CREATE";
+ readableType = "Stage";
+ displayName = "Stage Channel";
+ break;
+ }
+ case "GUILD_CATEGORY": {
+ emoji = "CHANNEL.CATEGORY.CREATE";
+ readableType = "Category";
+ displayName = "Category";
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Channel";
+ displayName = "Channel";
+ }
+ }
+ const data = {
+ meta: {
+ type: "channelCreate",
+ displayName: displayName + " Created",
+ calculateType: "channelUpdate",
+ color: NucleusColors.green,
+ emoji: emoji,
+ timestamp: channel.createdTimestamp
+ },
+ list: {
+ channelId: entry(channel.id, `\`${channel.id}\``),
+ name: entry(channel.name, renderChannel(channel)),
+ type: entry(channel.type, readableType),
+ category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
+ },
+ hidden: {
+ guild: channel.guild.id
}
- let data = {
- meta: {
- type: 'channelCreate',
- displayName: displayName + ' Created',
- calculateType: 'channelUpdate',
- color: NucleusColors.green,
- emoji: emoji,
- timestamp: channel.createdTimestamp
- },
- list: {
- channelId: entry(channel.id, `\`${channel.id}\``),
- name: entry(channel.name, renderChannel(channel)),
- type: entry(channel.type, readableType),
- category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
- },
- hidden: {
- guild: channel.guild.id
- }
- }
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 25c9ce5..c8a72a4 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,73 +1,71 @@
import getEmojiByName from "../utils/getEmojiByName.js";
-export const event = 'channelDelete'
+export const event = "channelDelete";
export async function callback(client, channel) {
- try{
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger;
- let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
- if (audit.executor.id === client.user.id) return;
+ const auditLog = await getAuditLog(channel.guild, "CHANNEL_DELETE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+ if (audit.executor.id === client.user.id) return;
- let emoji;
- let readableType;
- let displayName;
- switch (channel.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.DELETE";
- readableType = "Text";
- displayName = "Text Channel"
- break;
- }
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.DELETE";
- readableType = "Voice";
- displayName = "Voice Channel"
- break;
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.DELETE";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.DELETE";
- readableType = "Channel";
- displayName = "Channel"
- }
- }
- let list = {
- channelId: entry(channel.id, `\`${channel.id}\``),
- name: entry(channel.id, `${channel.name}`),
- topic: null,
- type: entry(channel.type, readableType),
- category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
- nsfw: null,
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor))
- }
- if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
- else delete list.topic;
- if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
- else delete list.nsfw;
+ let emoji;
+ let readableType;
+ let displayName;
+ switch (channel.type) {
+ case "GUILD_TEXT": {
+ emoji = "CHANNEL.TEXT.DELETE";
+ readableType = "Text";
+ displayName = "Text Channel";
+ break;
+ }
+ case "GUILD_VOICE": {
+ emoji = "CHANNEL.VOICE.DELETE";
+ readableType = "Voice";
+ displayName = "Voice Channel";
+ break;
+ }
+ case "GUILD_CATEGORY": {
+ emoji = "CHANNEL.CATEGORY.DELETE";
+ readableType = "Category";
+ displayName = "Category";
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.DELETE";
+ readableType = "Channel";
+ displayName = "Channel";
+ }
+ }
+ const list = {
+ channelId: entry(channel.id, `\`${channel.id}\``),
+ name: entry(channel.id, `${channel.name}`),
+ topic: null,
+ type: entry(channel.type, readableType),
+ category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+ nsfw: null,
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor))
+ };
+ if (channel.topic !== null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace("`", "'")}\n\`\`\``);
+ else delete list.topic;
+ if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
+ else delete list.nsfw;
- let data = {
- meta:{
- type: 'channelDelete',
- displayName: displayName + ' Deleted',
- calculateType: 'channelUpdate',
- color: NucleusColors.red,
- emoji: emoji,
- timestamp: audit.createdTimestamp
- },
- list: list,
- hidden: {
- guild: channel.guild.id
- }
+ const data = {
+ meta:{
+ type: "channelDelete",
+ displayName: displayName + " Deleted",
+ calculateType: "channelUpdate",
+ color: NucleusColors.red,
+ emoji: emoji,
+ timestamp: audit.createdTimestamp
+ },
+ list: list,
+ hidden: {
+ guild: channel.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 568af0b..89692e8 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,135 +1,133 @@
-import humanizeDuration from 'humanize-duration';
-import getEmojiByName from '../utils/getEmojiByName.js';
+import humanizeDuration from "humanize-duration";
+import getEmojiByName from "../utils/getEmojiByName.js";
-export const event = 'channelUpdate';
+export const event = "channelUpdate";
export async function callback(client, oc, nc) {
- try {
- let config = await client.memory.readGuildInfo(nc.guild.id);
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
+ const config = await client.memory.readGuildInfo(nc.guild.id);
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger;
- if (nc.parent && (nc.parent.id === config.tickets.category)) return
+ if (nc.parent && (nc.parent.id === config.tickets.category)) return;
- let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
- if (audit.executor.id === client.user.id) return;
+ const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+ if (audit.executor.id === client.user.id) return;
- let emoji:string;
- let readableType:string;
- let displayName:string ;
- let changes = {
- channelId: entry(nc.id, `\`${nc.id}\``),
- channel: entry(nc.id, renderChannel(nc)),
- edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
+ let emoji:string;
+ let readableType:string;
+ let displayName:string ;
+ const changes = {
+ channelId: entry(nc.id, `\`${nc.id}\``),
+ channel: entry(nc.id, renderChannel(nc)),
+ edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user))
+ };
+ if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+ if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+
+ switch (nc.type) {
+ case "GUILD_TEXT": {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "Text";
+ displayName = "Text Channel";
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+ } else { newTopic = "None"; }
+ const nsfw = ["", ""];
+ nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+ if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+ if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+ [oc.rateLimitPerUser, nc.rateLimitPerUser],
+ `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+ );
+
+ break;
+ }
+ case "GUILD_NEWS": {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "News";
+ displayName = "News Channel";
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+ } else { newTopic = "None"; }
+ if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+ break;
+ }
+ case "GUILD_VOICE": {
+ emoji = "CHANNEL.VOICE.EDIT";
+ readableType = "Voice";
+ displayName = "Voice Channel";
+ if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
+ [oc.rtcRegion, nc.rtcRegion],
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+ );
+ break;
+ }
+ case "GUILD_STAGE": {
+ emoji = "CHANNEL.VOICE.EDIT";
+ readableType = "Stage";
+ displayName = "Stage Channel";
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else oldTopic = `\`\`\`\n${oldTopic.replace("`", "'")}\n\`\`\``;
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace("`", "'").substring(0, 253) + "..."}\n\`\`\``;
+ else newTopic = `\`\`\`\n${newTopic.replace("`", "'")}\n\`\`\``;
+ } else { newTopic = "None"; }
+ if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
+ [oc.rtcRegion, nc.rtcRegion],
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+ );
+ break;
+ }
+ case "GUILD_CATEGORY": {
+ emoji = "CHANNEL.CATEGORY.EDIT";
+ readableType = "Category";
+ displayName = "Category";
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "Channel";
+ displayName = "Channel";
+ }
+ }
+ const t = oc.type.split("_")[1];
+ if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+ if (!(Object.values(changes).length - 4)) return;
+ const data = {
+ meta:{
+ type: "channelUpdate",
+ displayName: displayName + " Edited",
+ calculateType: "channelUpdate",
+ color: NucleusColors.yellow,
+ emoji: emoji,
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: nc.guild.id
}
- if (oc.name !== nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
- if (oc.position !== nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
-
- switch (nc.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "Text";
- displayName = "Text Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- let nsfw = ["", ""]
- nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- if (oc.topic !== nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
- if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
- if (oc.rateLimitPerUser !== nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
- [oc.rateLimitPerUser, nc.rateLimitPerUser],
- `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
- );
-
- break;
- }
- case 'GUILD_NEWS': {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "News";
- displayName = "News Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- if (oc.nsfw !== nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
- break;
- }
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.EDIT";
- readableType = "Voice";
- displayName = "Voice Channel"
- if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
- [oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
- );
- break;
- }
- case 'GUILD_STAGE': {
- emoji = "CHANNEL.VOICE.EDIT";
- readableType = "Stage";
- displayName = "Stage Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- if (oc.bitrate !== nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit !== nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion !== nc.rtcRegion) changes["region"] = entry(
- [oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
- );
- break;
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.EDIT";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "Channel";
- displayName = "Channel"
- }
- }
- let t = oc.type.split("_")[1];
- if (oc.type !== nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
- if (!(Object.values(changes).length - 4)) return
- let data = {
- meta:{
- type: 'channelUpdate',
- displayName: displayName + ' Edited',
- calculateType: 'channelUpdate',
- color: NucleusColors.yellow,
- emoji: emoji,
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: nc.guild.id
- }
- }
- log(data);
- } catch {}
+ };
+ log(data);
}
\ No newline at end of file
diff --git a/src/events/commandError.ts b/src/events/commandError.ts
index 8edb480..2ec6a5d 100644
--- a/src/events/commandError.ts
+++ b/src/events/commandError.ts
@@ -1,6 +1,6 @@
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-export const event = 'commandError'
+export const event = "commandError";
export async function callback(client, interaction, error) {
if (interaction.replied || interaction.deferred) {
@@ -9,13 +9,13 @@
.setDescription(error.message ?? error.toString())
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true})
+ ], ephemeral: true});
} else {
await interaction.reply({embeds: [new EmojiEmbed()
.setTitle("Something went wrong")
.setDescription(error.message ?? error.toString())
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true})
+ ], ephemeral: true});
}
}
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 9e91012..83a30e2 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'emojiCreate'
+export const event = "emojiCreate";
export async function callback(client, emoji) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'emojiCreate',
- displayName: 'Emoji Created',
- calculateType: 'emojiUpdate',
- color: NucleusColors.green,
- emoji: "GUILD.EMOJI.CREATE",
- timestamp: emoji.createdTimestamp
- },
- list: {
- emojiId: entry(emoji.id, `\`${emoji.id}\``),
- emoji: entry(emoji.name, renderEmoji(emoji)),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
- },
- hidden: {
- guild: emoji.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+ const auditLog = await getAuditLog(emoji.guild, "EMOJI_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "emojiCreate",
+ displayName: "Emoji Created",
+ calculateType: "emojiUpdate",
+ color: NucleusColors.green,
+ emoji: "GUILD.EMOJI.CREATE",
+ timestamp: emoji.createdTimestamp
+ },
+ list: {
+ emojiId: entry(emoji.id, `\`${emoji.id}\``),
+ emoji: entry(emoji.name, renderEmoji(emoji)),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+ },
+ hidden: {
+ guild: emoji.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 0c39542..5ed7a87 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'emojiDelete'
+export const event = "emojiDelete";
export async function callback(client, emoji) {
- try{
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'emojiDelete',
- displayName: 'Emoji Deleted',
- calculateType: 'emojiUpdate',
- color: NucleusColors.red,
- emoji: "GUILD.EMOJI.DELETE",
- timestamp: audit.createdTimestamp,
- },
- list: {
- emojiId: entry(emoji.id, `\`${emoji.id}\``),
- emoji: entry(emoji.name, renderEmoji(emoji)),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
- deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
- },
- hidden: {
- guild: emoji.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+ const auditLog = await getAuditLog(emoji.guild, "EMOJI_DELETE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "emojiDelete",
+ displayName: "Emoji Deleted",
+ calculateType: "emojiUpdate",
+ color: NucleusColors.red,
+ emoji: "GUILD.EMOJI.DELETE",
+ timestamp: audit.createdTimestamp
+ },
+ list: {
+ emojiId: entry(emoji.id, `\`${emoji.id}\``),
+ emoji: entry(emoji.name, renderEmoji(emoji)),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+ deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+ },
+ hidden: {
+ guild: emoji.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index a90de9a..d04c6c8 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,37 +1,33 @@
-import getEmojiByName from "../utils/getEmojiByName.js";
-
-export const event = 'emojiUpdate';
+export const event = "emojiUpdate";
export async function callback(client, oe, ne) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger;
- if (oe.name === ne.name) return
- let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
- let audit = auditLog.entries.first();
- if (audit.executor.id === client.user.id) return;
+ if (oe.name === ne.name) return;
+ const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+ const audit = auditLog.entries.first();
+ if (audit.executor.id === client.user.id) return;
- let changes = {
- emojiId: entry(ne.id, `\`${ne.id}\``),
- emoji: entry(ne.id, renderEmoji(ne)),
- edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
- editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
- name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+ const changes = {
+ emojiId: entry(ne.id, `\`${ne.id}\``),
+ emoji: entry(ne.id, renderEmoji(ne)),
+ edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+ editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+ name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+ };
+ const data = {
+ meta:{
+ type: "emojiUpdate",
+ displayName: "Emoji Edited",
+ calculateType: "emojiUpdate",
+ color: NucleusColors.yellow,
+ emoji: "GUILD.EMOJI.EDIT",
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: ne.guild.id
}
- let data = {
- meta:{
- type: 'emojiUpdate',
- displayName: 'Emoji Edited',
- calculateType: 'emojiUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.EMOJI.EDIT",
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: ne.guild.id
- }
- }
- log(data);
- } catch {}
+ };
+ log(data);
}
\ No newline at end of file
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index 06163a9..c5d269b 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,39 +1,37 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
-export const event = 'guildBanAdd';
+export const event = "guildBanAdd";
export async function callback(client, ban) {
- try { await statsChannelRemove(client, ban.user); } catch {}
- try { purgeByUser(ban.user.id, ban.guild); } catch {}
- try {
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
- let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD')
- let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
- if (audit.executor.id === client.user.id) return
- try { await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
- let data = {
- meta: {
- type: 'memberBan',
- displayName: 'Member Banned',
- calculateType: 'guildMemberPunish',
- color: NucleusColors.red,
- emoji: "PUNISH.BAN.RED",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(ban.user.id, `\`${ban.user.id}\``),
- name: entry(ban.user.id, renderUser(ban.user)),
- banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
- accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
- serverMemberCount: ban.guild.memberCount,
- },
- hidden: {
- guild: ban.guild.id
- }
+ await statsChannelRemove(client, ban.user);
+ purgeByUser(ban.user.id, ban.guild);
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+ const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_ADD");
+ const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+ if (audit.executor.id === client.user.id) return;
+ await client.database.history.create("ban", ban.guild.id, ban.user, audit.executor, audit.reason);
+ const data = {
+ meta: {
+ type: "memberBan",
+ displayName: "Member Banned",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+ name: entry(ban.user.id, renderUser(ban.user)),
+ banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
+ serverMemberCount: ban.guild.memberCount
+ },
+ hidden: {
+ guild: ban.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 2a1b6de..352265f 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,38 +1,35 @@
-import humanizeDuration from 'humanize-duration';
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
-export const event = 'guildBanRemove';
+export const event = "guildBanRemove";
export async function callback(client, ban) {
- try { await statsChannelRemove(client, ban.user); } catch {}
- try { purgeByUser(ban.user.id, ban.guild); } catch {}
- try {
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
- let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_REMOVE')
- let audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
- if (audit.executor.id === client.user.id) return
- try { await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason) } catch {}
- let data = {
- meta: {
- type: 'memberUnban',
- displayName: 'Member Unbanned',
- calculateType: 'guildMemberPunish',
- color: NucleusColors.green,
- emoji: "PUNISH.BAN.GREEN",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(ban.user.id, `\`${ban.user.id}\``),
- name: entry(ban.user.id, renderUser(ban.user)),
- unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
- accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
- },
- hidden: {
- guild: ban.guild.id
- }
+ await statsChannelRemove(client, ban.user);
+ purgeByUser(ban.user.id, ban.guild);
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+ const auditLog = await getAuditLog(ban.guild, "MEMBER_BAN_REMOVE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === ban.user.id).first();
+ if (audit.executor.id === client.user.id) return;
+ await client.database.history.create("unban", ban.guild.id, ban.user, audit.executor, audit.reason);
+ const data = {
+ meta: {
+ type: "memberUnban",
+ displayName: "Member Unbanned",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.green,
+ emoji: "PUNISH.BAN.GREEN",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(ban.user.id, `\`${ban.user.id}\``),
+ name: entry(ban.user.id, renderUser(ban.user)),
+ unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt))
+ },
+ hidden: {
+ guild: ban.guild.id
}
- log(data);
- } catch (e) {console.log(e)}
+ };
+ log(data);
}
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index 413e5fb..8f8d0f5 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,12 +1,11 @@
-import { MessageActionRow, MessageButton } from "discord.js";
-import EmojiEmbed from "../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../utils/getEmojiByName.js";
+import type { Guild } from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
import guide from "../reflex/guide.js";
-export const event = 'guildCreate';
+export const event = "guildCreate";
-export async function callback(client, guild) {
- try{
- guide(guild)
- } catch {}
+export async function callback(_client: HaikuClient, guild: Guild) {
+ guide(guild);
}
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index d555647..a7f8c47 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,20 +1,20 @@
-export const event = 'guildMemberUpdate'
+export const event = "guildMemberUpdate";
export async function callback(client, before, after) {
try {
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger
- let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger;
+ const auditLog = await getAuditLog(after.guild, "MEMBER_UPDATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
if (audit.executor.id === client.user.id) return;
if (before.nickname !== after.nickname) {
- try { await client.database.history.create(
+ await client.database.history.create(
"nickname", after.guild.id, after.user, audit.executor,
- null, before.nickname || before.user.username, after.nickname || after.user.username) } catch {}
- let data = {
+ null, before.nickname || before.user.username, after.nickname || after.user.username);
+ const data = {
meta: {
- type: 'memberUpdate',
- displayName: 'Nickname Changed',
- calculateType: 'guildMemberUpdate',
+ type: "memberUpdate",
+ displayName: "Nickname Changed",
+ calculateType: "guildMemberUpdate",
color: NucleusColors.yellow,
emoji: "PUNISH.NICKNAME.YELLOW",
timestamp: new Date().getTime()
@@ -22,25 +22,25 @@
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- before: entry(before.nickname, before.nickname ? before.nickname : '*None*'),
- after: entry(after.nickname, after.nickname ? after.nickname : '*None*'),
+ before: entry(before.nickname, before.nickname ? before.nickname : "*None*"),
+ after: entry(after.nickname, after.nickname ? after.nickname : "*None*"),
changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
changedBy: entry(audit.executor.id, renderUser(audit.executor))
},
hidden: {
guild: after.guild.id
}
- }
+ };
log(data);
} else if (before.communicationDisabledUntilTimestamp < new Date().getTime() && after.communicationDisabledUntil > new Date().getTime()) {
- try { await client.database.history.create(
+ await client.database.history.create(
"mute", after.guild.id, after.user, audit.executor, audit.reason, null, null, null
- )} catch {}
- let data = {
+ );
+ const data = {
meta: {
- type: 'memberMute',
- displayName: 'Muted',
- calculateType: 'guildMemberPunish',
+ type: "memberMute",
+ displayName: "Muted",
+ calculateType: "guildMemberPunish",
color: NucleusColors.yellow,
emoji: "PUNISH.MUTE.YELLOW",
timestamp: new Date().getTime()
@@ -51,12 +51,12 @@
mutedUntil: entry(after.communicationDisabledUntilTimestamp, renderDelta(after.communicationDisabledUntilTimestamp)),
muted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
mutedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(audit.reason, audit.reason ? audit.reason : '\n> *No reason provided*')
+ reason: entry(audit.reason, audit.reason ? audit.reason : "\n> *No reason provided*")
},
hidden: {
guild: after.guild.id
}
- }
+ };
log(data);
client.database.eventScheduler.schedule("naturalUnmute", after.communicationDisabledUntil,
{guild: after.guild.id, user: after.id, expires: after.communicationDisabledUntilTimestamp}
@@ -65,14 +65,14 @@
after.communicationDisabledUntil === null && before.communicationDisabledUntilTimestamp !== null &&
new Date().getTime() >= audit.createdTimestamp
) {
- try { await client.database.history.create(
+ await client.database.history.create(
"unmute", after.guild.id, after.user, audit.executor, null, null, null, null
- )} catch {}
- let data = {
+ );
+ const data = {
meta: {
- type: 'memberUnmute',
- displayName: 'Unmuted',
- calculateType: 'guildMemberPunish',
+ type: "memberUnmute",
+ displayName: "Unmuted",
+ calculateType: "guildMemberPunish",
color: NucleusColors.green,
emoji: "PUNISH.MUTE.GREEN",
timestamp: new Date().getTime()
@@ -86,9 +86,9 @@
hidden: {
guild: after.guild.id
}
- }
+ };
log(data);
client.database.eventScheduler.cancel("naturalUnmute", {guild: after.guild.id, user: after.id, expires: before.communicationDisabledUntilTimestamp});
}
- } catch (e) { console.log(e) }
+ } catch (e) { console.log(e); }
}
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index e27975b..2cb1de8 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,61 +1,59 @@
-import { callback as statsChannelUpdate } from '../reflex/statsChannelUpdate.js';
+import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
-export const event = 'guildUpdate'
+export const event = "guildUpdate";
export async function callback(client, before, after) {
- try { await statsChannelUpdate(client, after.me); } catch(e) { console.log(e)}
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger
- let auditLog = await getAuditLog(after, 'GUILD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
- if (audit.executor.id === client.user.id) return;
- let list = {}
+ await statsChannelUpdate(client, after.me);
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+ const auditLog = await getAuditLog(after, "GUILD_UPDATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const list = {};
- const verificationLevels = {
- NONE: 'Unrestricted',
- LOW: 'Verified email',
- MEDIUM: 'Registered (5 minutes)',
- HIGH: 'Member (10 minutes)',
- VERY_HIGH: 'Verified phone'
+ const verificationLevels = {
+ NONE: "Unrestricted",
+ LOW: "Verified email",
+ MEDIUM: "Registered (5 minutes)",
+ HIGH: "Member (10 minutes)",
+ VERY_HIGH: "Verified phone"
+ };
+
+ const explicitContentFilterLevels = {
+ DISABLED: "Disabled",
+ MEMBERS_WITHOUT_ROLES: "Members without roles",
+ ALL_MEMBERS: "All members"
+ };
+
+ const MFALevels = {
+ NONE: "None",
+ ELEVATED: "Enabled"
+ };
+
+ if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+ if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
+ if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
+ if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
+ if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
+ if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
+ if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
+
+ if (!(Object.keys(list).length)) return;
+ list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+ list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+ const data = {
+ meta: {
+ type: "guildUpdate",
+ displayName: "Guild Edited",
+ calculateType: "guildUpdate",
+ color: NucleusColors.yellow,
+ emoji: "GUILD.YELLOW",
+ timestamp: new Date().getTime()
+ },
+ list: list,
+ hidden: {
+ guild: after.id
}
-
- const explicitContentFilterLevels = {
- DISABLED: 'Disabled',
- MEMBERS_WITHOUT_ROLES: 'Members without roles',
- ALL_MEMBERS: 'All members'
- }
-
- const MFALevels = {
- NONE: 'None',
- ELEVATED: 'Enabled'
- }
-
- if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
- if (before.icon !== after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
- if (before.splash !== after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
- if (before.banner !== after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
- if (before.owner !== after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
- if (before.verificationLevel !== after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
- if (before.explicitContentFilter !== after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
- if (before.mfaLevel !== after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
-
- if (!(Object.keys(list).length)) return;
- list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
- list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
- let data = {
- meta: {
- type: 'guildUpdate',
- displayName: 'Guild Edited',
- calculateType: 'guildUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.YELLOW",
- timestamp: new Date().getTime()
- },
- list: list,
- hidden: {
- guild: after.id
- }
- }
- log(data);
- } catch (e) {}
+ };
+ log(data);
}
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index a4bb8c3..08fcc77 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -1,57 +1,56 @@
-import { callback as roleMenu } from "../actions/roleMenu.js"
+import { callback as roleMenu } from "../actions/roleMenu.js";
import verify from "../reflex/verify.js";
import create from "../actions/tickets/create.js";
import close from "../actions/tickets/delete.js";
import createTranscript from "../premium/createTranscript.js";
import Fuse from "fuse.js";
-import { autocomplete as tagAutocomplete } from "../commands/tag.js"
+import { autocomplete as tagAutocomplete } from "../commands/tag.js";
-export const event = 'interactionCreate';
+export const event = "interactionCreate";
function getAutocomplete(typed: string, options: string[]): object[] {
- 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.slice(0, 25).sort().map(option => ({name: option, value: option}))
- const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed)
- return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}))
+ 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.slice(0, 25).sort().map(option => ({name: option, value: option}));
+ const fuse = new Fuse(options, {useExtendedSearch: true, findAllMatches: true, minMatchCharLength: 0}).search(typed);
+ return fuse.slice(0, 25).map(option => ({name: option.item, value: option.item}));
}
function generateStatsChannelAutocomplete(typed) {
- const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"]
- let autocompletions = []
- const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
- if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
- else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
- return getAutocomplete(typed, autocompletions)
+ const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans"];
+ const autocompletions = [];
+ const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+ if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+ else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+ return getAutocomplete(typed, autocompletions);
}
function generateWelcomeMessageAutocomplete(typed) {
- const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"]
- let autocompletions = []
- const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/)
- if (beforeLastOpenBracket !== null) { for (let replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`) } }
- else { for (let replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`) } }
- return getAutocomplete(typed, autocompletions)
+ const validReplacements = ["serverName", "memberCount", "memberCount:bots", "memberCount:humans", "member:mention", "member:name"];
+ const autocompletions = [];
+ const beforeLastOpenBracket = typed.match(/(.*){[^{}]{0,15}$/);
+ if (beforeLastOpenBracket !== null) { for (const replacement of validReplacements) { autocompletions.push(`${beforeLastOpenBracket[1]} {${replacement}}`); } }
+ else { for (const replacement of validReplacements) { autocompletions.push(`${typed} {${replacement}}`); } }
+ return getAutocomplete(typed, autocompletions);
}
async function interactionCreate(interaction) {
if (interaction.componentType === "BUTTON") {
switch (interaction.customId) {
- case "rolemenu": { return await roleMenu(interaction) }
- case "verifybutton": { return verify(interaction) }
- case "createticket": { return create(interaction) }
- case "closeticket": { return close(interaction) }
- case "createtranscript": { return createTranscript(interaction) }
+ case "rolemenu": { return await roleMenu(interaction); }
+ case "verifybutton": { return verify(interaction); }
+ case "createticket": { return create(interaction); }
+ case "closeticket": { return close(interaction); }
+ case "createtranscript": { return createTranscript(interaction); }
}
- } else if (interaction.componentType === "MESSAGE_COMPONENT") {
} else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
switch (`${interaction.commandName} ${interaction.options.getSubcommandGroup(false)} ${interaction.options.getSubcommand(false)}`) {
- case `tag null null`: { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))) }
- case `settings null stats`: { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))) }
- case `settings null welcome`: { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))) }
+ case "tag null null": { return interaction.respond(getAutocomplete(interaction.options.getString("tag"), (await tagAutocomplete(interaction)))); }
+ case "settings null stats": { return interaction.respond(generateStatsChannelAutocomplete(interaction.options.getString("name"))); }
+ case "settings null welcome": { return interaction.respond(generateWelcomeMessageAutocomplete(interaction.options.getString("message"))); }
}
}
}
export async function callback(client, interaction) {
- await interactionCreate(interaction)
+ await interactionCreate(interaction);
}
\ No newline at end of file
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 5d47bf8..1cbed02 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteCreate";
export async function callback(client, invite) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
- let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'inviteCreate',
- displayName: 'Invite Created',
- calculateType: 'guildUpdate',
- color: NucleusColors.green,
- emoji: "INVITE.CREATE",
- timestamp: invite.createdTimestamp
- },
- list: {
- channel: entry(invite.channel.id, renderChannel(invite.channel)),
- link: entry(invite.url, invite.url),
- expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
- },
- hidden: {
- guild: invite.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+ const auditLog = await getAuditLog(invite.guild, "INVITE_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "inviteCreate",
+ displayName: "Invite Created",
+ calculateType: "guildUpdate",
+ color: NucleusColors.green,
+ emoji: "INVITE.CREATE",
+ timestamp: invite.createdTimestamp
+ },
+ list: {
+ channel: entry(invite.channel.id, renderChannel(invite.channel)),
+ link: entry(invite.url, invite.url),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
+ },
+ hidden: {
+ guild: invite.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index acfc9dd..cbe4d4b 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -1,32 +1,30 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'inviteDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "inviteDelete";
export async function callback(client, invite) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
- let auditLog = await getAuditLog(invite.guild, 'INVITE_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'inviteDelete',
- displayName: 'Invite Deleted',
- calculateType: 'guildUpdate',
- color: NucleusColors.red,
- emoji: "INVITE.DELETE",
- timestamp: new Date().getTime()
- },
- list: {
- channel: entry(invite.channel.id, renderChannel(invite.channel)),
- link: entry(invite.url, invite.url),
- expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
- },
- hidden: {
- guild: invite.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+ const auditLog = await getAuditLog(invite.guild, "INVITE_DELETE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === invite.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "inviteDelete",
+ displayName: "Invite Deleted",
+ calculateType: "guildUpdate",
+ color: NucleusColors.red,
+ emoji: "INVITE.DELETE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ channel: entry(invite.channel.id, renderChannel(invite.channel)),
+ link: entry(invite.url, invite.url),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : "Never"),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: invite.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 109f226..34545fb 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -1,36 +1,33 @@
-import { callback as statsChannelAdd } from '../reflex/statsChannelUpdate.js';
-import { callback as welcome } from '../reflex/welcome.js';
-import log from '../utils/log.js';
-import client from '../utils/client.js';
+import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js";
+import { callback as welcome } from "../reflex/welcome.js";
+import client from "../utils/client.js";
-export const event = 'guildMemberAdd'
+export const event = "guildMemberAdd";
export async function callback(_, member) {
- try { welcome(_, member); } catch {}
- try { statsChannelAdd(_, member, ); } catch {}
- try {
- const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
- try { await client.database.history.create("join", member.guild.id, member.user, null, null) } catch {}
- let data = {
- meta: {
- type: 'memberJoin',
- displayName: 'Member Joined',
- calculateType: 'guildMemberUpdate',
- color: NucleusColors.green,
- emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
- timestamp: member.joinedTimestamp
- },
- list: {
- memberId: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
- }
+ welcome(_, member);
+ statsChannelAdd(_, member );
+ const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ await client.database.history.create("join", member.guild.id, member.user, null, null);
+ const data = {
+ meta: {
+ type: "memberJoin",
+ displayName: "Member Joined",
+ calculateType: "guildMemberUpdate",
+ color: NucleusColors.green,
+ emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".JOIN",
+ timestamp: member.joinedTimestamp
+ },
+ list: {
+ memberId: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount
+ },
+ hidden: {
+ guild: member.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 5dff86f..842a48b 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,72 +1,70 @@
-import { purgeByUser } from '../actions/tickets/delete.js';
-import { callback as statsChannelRemove } from '../reflex/statsChannelUpdate.js';
+import { purgeByUser } from "../actions/tickets/delete.js";
+import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
-export const event = 'guildMemberRemove'
+export const event = "guildMemberRemove";
export async function callback(client, member) {
- try { purgeByUser(member.id, member.guild); } catch {}
- try { await statsChannelRemove(client, member); } catch {}
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
- let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
- let audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
- let type = "leave"
- if (audit) {
- if (audit.executor.id === client.user.id) return
- if (audit.createdAt - 100 >= new Date().getTime()) {
- type = "kick"
- }
+ purgeByUser(member.id, member.guild);
+ await statsChannelRemove(client, member);
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ const auditLog = await getAuditLog(member.guild, "MEMBER_KICK");
+ const audit = auditLog.entries.filter(entry => entry.target.id === member.id).first();
+ let type = "leave";
+ if (audit) {
+ if (audit.executor.id === client.user.id) return;
+ if (audit.createdAt - 100 >= new Date().getTime()) {
+ type = "kick";
}
- let data
- if (type === "kick") {
- try { await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason) } catch {}
- data = {
- meta: {
- type: 'memberKick',
- displayName: 'Member Kicked',
- calculateType: 'guildMemberPunish',
- color: NucleusColors.red,
- emoji: "PUNISH.KICK.RED",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
- reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
- }
+ }
+ let data;
+ if (type === "kick") {
+ await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+ data = {
+ meta: {
+ type: "memberKick",
+ displayName: "Member Kicked",
+ calculateType: "guildMemberPunish",
+ color: NucleusColors.red,
+ emoji: "PUNISH.KICK.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount
+ },
+ hidden: {
+ guild: member.guild.id
}
- } else {
- try { await client.database.history.create("leave", member.guild.id, member.user, null, null) } catch {}
- data = {
- meta: {
- type: 'memberLeave',
- displayName: 'Member Left',
- calculateType: 'guildMemberUpdate',
- color: NucleusColors.red,
- emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
- timestamp: new Date().getTime()
- },
- list: {
- memberId: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
- left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
- }
+ };
+ } else {
+ await client.database.history.create("leave", member.guild.id, member.user, null, null);
+ data = {
+ meta: {
+ type: "memberLeave",
+ displayName: "Member Left",
+ calculateType: "guildMemberUpdate",
+ color: NucleusColors.red,
+ emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ memberId: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedTimestamp, renderDelta(member.joinedAt)),
+ left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount
+ },
+ hidden: {
+ guild: member.guild.id
}
- }
- log(data);
- } catch (e) { console.log(e) }
+ };
+ }
+ log(data);
}
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index cbb1fa2..bbb6a32 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,28 +1,33 @@
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../reflex/scanners.js'
-import logAttachment from '../premium/attachmentLogs.js'
-import createLogException from '../utils/createLogException.js'
-import getEmojiByName from '../utils/getEmojiByName.js';
-import client from '../utils/client.js';
-import {callback as a} from '../reflex/statsChannelUpdate.js'
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import { HaikuClient } from "jshaiku";
+import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
+import logAttachment from "../premium/attachmentLogs.js";
+import createLogException from "../utils/createLogException.js";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import client from "../utils/client.js";
+import {callback as a} from "../reflex/statsChannelUpdate.js";
+import type { Message } from "discord.js";
-export const event = 'messageCreate'
+export const event = "messageCreate";
-export async function callback(_, message) {
+export async function callback(_client: HaikuClient, message: Message) {
if(!message) return;
- if (message.author.bot) return
- if (message.channel.type === 'dm') return
- try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e)}
+ if(!message.guild) return;
+ if (message.author.bot) return;
+ if (message.channel.type === "DM") return;
+ try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e);}
- const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
- let fileNames = await logAttachment(message);
+ const fileNames = await logAttachment(message);
- let content = message.content.toLowerCase() || ''
- let config = await client.memory.readGuildInfo(message.guild.id);
- const filter = getEmojiByName("ICONS.FILTER")
- let attachmentJump = ""
- if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})` }
- let list = {
+ const content = message.content.toLowerCase() || "";
+ const config = await client.memory.readGuildInfo(message.guild.id);
+ const filter = getEmojiByName("ICONS.FILTER");
+ let attachmentJump = "";
+ if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`; }
+ const list = {
messageId: entry(message.id, `\`${message.id}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
sentIn: entry(message.channel.id, renderChannel(message.channel)),
@@ -33,116 +38,115 @@
message.reference ? message.reference.messageId : null,
message.reference ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
)
- }
+ };
if (config.filters.invite.enabled) {
- if (!config.filters.invite.allowed.users.includes(message.author.id) ||
- !config.filters.invite.allowed.channels.includes(message.channel.id) ||
- !message.author.roles.cache.some(role => config.filters.invite.allowed.roles.includes(role.id))
- ) {
+ if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
- createLogException(message.guild.id, message.channel.id, message.id)
+ createLogException(message.guild.id, message.channel.id, message.id);
message.delete();
- let data = {
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted (Automated, Contained Invite)',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted (Automated, Contained Invite)",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
}
if (fileNames.files.length > 0) {
- for (let element of fileNames.files) {
+ for (const element of fileNames.files) {
if(!message) return;
- let url = element.url ? element.url : element.local
+ const url = element.url ? element.url : element.local;
if (url !== undefined) {
if(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
- if (config.filters.images.NSFW && !message.channel.nsfw) {
+ if (config.filters.images.NSFW && !(
+ message.channel.type === "GUILD_PUBLIC_THREAD" ? false : message.channel.nsfw
+ )) {
if (await NSFWCheck(url)) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
if (config.filters.wordFilter.enabled) {
- let text = await TestImage(url)
- let check = TestString(text, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+ const text = await TestImage(url);
+ const check = TestString(text ?? "", config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
if(check !== null) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
if (config.filters.images.size) {
if(url.match(/\.+(webp|png|jpg)$/gi)) {
if(!await SizeCheck(element)) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
@@ -150,150 +154,150 @@
}
if (config.filters.malware) {
if (!MalwareCheck(url)) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
}
- };
+ }
}
if(!message) return;
- let linkDetectionTypes = await LinkCheck(message)
+ const linkDetectionTypes = await LinkCheck(message);
if (linkDetectionTypes.length > 0) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: `Message Deleted`,
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + ` Link filtered as ${linkDetectionTypes[0].toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
if (config.filters.wordFilter.enabled) {
- let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+ const check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
if(check !== null) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'autoModeratorDeleted',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + ` Message contained filtered word\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*'),
+ start: filter + " Message contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
if (config.filters.pings.everyone && message.mentions.everyone) {
- let data = {
+ const data = {
meta: {
- type: 'everyonePing',
- displayName: 'Everyone Pinged',
- calculateType: 'messageMassPing',
+ type: "everyonePing",
+ displayName: "Everyone Pinged",
+ calculateType: "messageMassPing",
color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.EVERYONE',
+ emoji: "MESSAGE.PING.EVERYONE",
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
if (config.filters.pings.roles) {
- for(let role of message.mentions.roles) {
+ for(const roleId in message.mentions.roles) {
if(!message) return;
- if (!config.filters.pings.allowed.roles.includes(role.id)) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ if (!config.filters.pings.allowed.roles.includes(roleId)) {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'rolePing',
- displayName: 'Role Pinged',
- calculateType: 'messageMassPing',
+ type: "rolePing",
+ displayName: "Role Pinged",
+ calculateType: "messageMassPing",
color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.ROLE',
+ emoji: "MESSAGE.PING.ROLE",
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
}
if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
- createLogException(message.guild.id, message.channel.id, message.id)
- await message.delete()
- let data = {
+ createLogException(message.guild.id, message.channel.id, message.id);
+ await message.delete();
+ const data = {
meta: {
- type: 'massPing',
- displayName: `Mass Ping`,
- calculateType: 'messageMassPing',
+ type: "massPing",
+ displayName: "Mass Ping",
+ calculateType: "messageMassPing",
color: NucleusColors.yellow,
- emoji: 'MESSAGE.PING.MASS',
+ emoji: "MESSAGE.PING.MASS",
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: list,
hidden: {
guild: message.channel.guild.id
}
- }
+ };
return log(data);
}
}
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index b139297..473fa52 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,34 +1,34 @@
-export const event = 'messageDelete'
+export const event = "messageDelete";
export async function callback(client, 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
- let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
- let audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger;
+ const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
+ const audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
if (audit) {
if (audit.createdAt - 100 < new Date().getTime()) return;
}
- message.reference = message.reference || {}
- let content = message.cleanContent
- content.replace(`\``, `\\\``)
- if (content.length > 256) content = content.substring(0, 253) + '...'
- let attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []).length
- let attachmentJump = ""
- let config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
- if (config) { attachmentJump = ` [[View attachments]](${config})` }
- let data = {
+ message.reference = message.reference || {};
+ let content = message.cleanContent;
+ content.replace("`", "\\`");
+ if (content.length > 256) content = content.substring(0, 253) + "...";
+ const attachments = message.attachments.size + (message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi) ?? []).length;
+ let attachmentJump = "";
+ const config = (await client.database.guilds.read(message.guild.id)).logging.attachments.saved[message.channel.id + message.id];
+ if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+ const data = {
meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'messageDelete',
+ type: "messageDelete",
+ displayName: "Message Deleted",
+ calculateType: "messageDelete",
color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
+ emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
},
list: {
messageId: entry(message.id, `\`${message.id}\``),
@@ -45,7 +45,7 @@
hidden: {
guild: message.channel.guild.id
}
- }
+ };
log(data);
- } catch(e) { console.log(e) }
+ } catch(e) { console.log(e); }
}
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 9e0e521..148cdb7 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,85 +1,83 @@
-export const event = 'messageUpdate'
+export const event = "messageUpdate";
export async function callback(client, oldMessage, newMessage) {
- try {
- if (newMessage.author.id === client.user.id) return;
- const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
- newMessage.reference = newMessage.reference || {}
- let newContent = newMessage.cleanContent.replaceAll("`", "‘")
- let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
- let attachmentJump = "";
- let config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
- if (config) { attachmentJump = ` [[View attachments]](${config})` }
- if (newContent === oldContent) {
- if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
- let data = {
- meta: {
- type: 'messageAnnounce',
- displayName: 'Message Published',
- calculateType: 'messageAnnounce',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.CREATE',
- timestamp: newMessage.editedTimestamp
- },
- separate: {
- end: `[[Jump to message]](${newMessage.url})`
- },
- list: {
- messageId: entry(newMessage.id, `\`${newMessage.id}\``),
- sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
- sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
- published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
- mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
- attachments: entry(
- renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
- renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
- )
- },
- hidden: {
- guild: newMessage.channel.guild.id
- }
+ if (newMessage.author.id === client.user.id) return;
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger;
+ newMessage.reference = newMessage.reference || {};
+ let newContent = newMessage.cleanContent.replaceAll("`", "‘");
+ let oldContent = oldMessage.cleanContent.replaceAll("`", "‘");
+ let attachmentJump = "";
+ const config = (await client.database.guilds.read(newMessage.guild.id)).logging.attachments.saved[newMessage.channel.id + newMessage.id];
+ if (config) { attachmentJump = ` [[View attachments]](${config})`; }
+ if (newContent === oldContent) {
+ if (!oldMessage.flags.has("CROSSPOSTED") && newMessage.flags.has("CROSSPOSTED")) {
+ const data = {
+ meta: {
+ type: "messageAnnounce",
+ displayName: "Message Published",
+ calculateType: "messageAnnounce",
+ color: NucleusColors.yellow,
+ emoji: "MESSAGE.CREATE",
+ timestamp: newMessage.editedTimestamp
+ },
+ separate: {
+ end: `[[Jump to message]](${newMessage.url})`
+ },
+ list: {
+ messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+ sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+ sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+ published: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+ attachments: entry(
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+ )
+ },
+ hidden: {
+ guild: newMessage.channel.guild.id
}
- return log(data);
- }
- };
- if (!newMessage.editedTimestamp) { return }
- if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
- if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
- let data = {
- meta: {
- type: 'messageUpdate',
- displayName: 'Message Edited',
- calculateType: 'messageUpdate',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.EDIT',
- timestamp: newMessage.editedTimestamp
- },
- separate: {
- start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
- (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
- end: `[[Jump to message]](${newMessage.url})`
- },
- list: {
- messageId: entry(newMessage.id, `\`${newMessage.id}\``),
- sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
- sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
- edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
- mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
- attachments: entry(
- renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
- renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
- ),
- repliedTo: entry(
- newMessage.reference.messageId || null,
- newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
- )
- },
- hidden: {
- guild: newMessage.channel.guild.id
- }
+ };
+ return log(data);
}
- log(data);
- } catch {}
-}
+ }
+ if (!newMessage.editedTimestamp) { return; }
+ if (newContent.length > 256) newContent = newContent.substring(0, 253) + "...";
+ if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + "...";
+ const data = {
+ meta: {
+ type: "messageUpdate",
+ displayName: "Message Edited",
+ calculateType: "messageUpdate",
+ color: NucleusColors.yellow,
+ emoji: "MESSAGE.EDIT",
+ timestamp: newMessage.editedTimestamp
+ },
+ separate: {
+ start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : "**Before:** *Message had no content*\n") +
+ (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : "**After:** *Message had no content*"),
+ end: `[[Jump to message]](${newMessage.url})`
+ },
+ list: {
+ messageId: entry(newMessage.id, `\`${newMessage.id}\``),
+ sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+ sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+ edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+ attachments: entry(
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size) + attachmentJump
+ ),
+ repliedTo: entry(
+ newMessage.reference.messageId || null,
+ newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
+ )
+ },
+ hidden: {
+ guild: newMessage.channel.guild.id
+ }
+ };
+ log(data);
+}
\ No newline at end of file
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 2f159ac..a717242 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,31 +1,29 @@
-export const event = 'roleCreate'
+export const event = "roleCreate";
export async function callback(client, role) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
- if (role.managed) return;
- let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'roleCreate',
- displayName: 'Role Created',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.green,
- emoji: "GUILD.ROLES.CREATE",
- timestamp: role.createdTimestamp
- },
- list: {
- roleId: entry(role.id, `\`${role.id}\``),
- role: entry(role.name, renderRole(role)),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
- },
- hidden: {
- guild: role.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
+ if (role.managed) return;
+ const auditLog = await getAuditLog(role.guild, "ROLE_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "roleCreate",
+ displayName: "Role Created",
+ calculateType: "guildRoleUpdate",
+ color: NucleusColors.green,
+ emoji: "GUILD.ROLES.CREATE",
+ timestamp: role.createdTimestamp
+ },
+ list: {
+ roleId: entry(role.id, `\`${role.id}\``),
+ role: entry(role.name, renderRole(role)),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
+ },
+ hidden: {
+ guild: role.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 3b43a55..ad74584 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -1,38 +1,36 @@
import getEmojiByName from "../utils/getEmojiByName.js";
-export const event = 'roleDelete'
+export const event = "roleDelete";
export async function callback(client, role) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
- if (role.managed) return;
- let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'roleDelete',
- displayName: 'Role Deleted',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.red,
- emoji: "GUILD.ROLES.DELETE",
- timestamp: audit.createdTimestamp,
- },
- list: {
- roleId: entry(role.id, `\`${role.id}\``),
- role: entry(role.name, role.name),
- color: entry(role.hexColor, `\`${role.hexColor}\``),
- showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
- mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
- members: entry(role.members.size, `${role.members.size}`),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
- },
- hidden: {
- guild: role.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger;
+ if (role.managed) return;
+ const auditLog = await getAuditLog(role.guild, "ROLE_DELETE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === role.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "roleDelete",
+ displayName: "Role Deleted",
+ calculateType: "guildRoleUpdate",
+ color: NucleusColors.red,
+ emoji: "GUILD.ROLES.DELETE",
+ timestamp: audit.createdTimestamp
+ },
+ list: {
+ roleId: entry(role.id, `\`${role.id}\``),
+ role: entry(role.name, role.name),
+ color: entry(role.hexColor, `\`${role.hexColor}\``),
+ showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+ mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+ members: entry(role.members.size, `${role.members.size}`),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: role.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 7c03c97..c51a9b3 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -1,49 +1,47 @@
import getEmojiByName from "../utils/getEmojiByName.js";
-export const event = 'roleUpdate';
+export const event = "roleUpdate";
export async function callback(client, or, nr) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
- let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
- let audit = auditLog.entries.first();
- if (audit.executor.id === client.user.id) return;
+ const auditLog = await getAuditLog(nr.guild, "ROLE_UPDATE");
+ const audit = auditLog.entries.first();
+ if (audit.executor.id === client.user.id) return;
- let changes = {
- roleId: entry(nr.id, `\`${nr.id}\``),
- role: entry(nr.id, renderRole(nr)),
- edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user)),
+ const changes = {
+ roleId: entry(nr.id, `\`${nr.id}\``),
+ role: entry(nr.id, renderRole(nr)),
+ edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user))
+ };
+ const mentionable = ["", ""];
+ const hoist = ["", ""];
+ mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+ if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+ if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
+ if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+ if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
+
+ if (Object.keys(changes).length === 4) return;
+
+ const data = {
+ meta:{
+ type: "roleUpdate",
+ displayName: "Role Edited",
+ calculateType: "guildRoleUpdate",
+ color: NucleusColors.yellow,
+ emoji: "GUILD.ROLES.EDIT",
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: nr.guild.id
}
- let mentionable = ["", ""]
- let hoist = ["", ""]
- mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- if (or.name !== nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
- if (or.position !== nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
- if (or.hoist !== nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
- if (or.mentionable !== nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
- if (or.hexColor !== nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
-
- if (Object.keys(changes).length === 4) return
-
- let data = {
- meta:{
- type: 'roleUpdate',
- displayName: 'Role Edited',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.ROLES.EDIT",
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: nr.guild.id
- }
- } // TODO: show perms changed (webpage)
- log(data);
- } catch {}
+ }; // TODO: show perms changed (webpage)
+ log(data);
}
\ No newline at end of file
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 669de32..43f2e9c 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,30 +1,28 @@
-export const event = 'stickerCreate'
+export const event = "stickerCreate";
export async function callback(client, emoji) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'STICKER_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'stickerCreate',
- displayName: 'Sticker Created',
- calculateType: 'stickerUpdate',
- color: NucleusColors.green,
- emoji: "GUILD.EMOJI.CREATE",
- timestamp: emoji.createdTimestamp
- },
- list: {
- stickerId: entry(emoji.id, `\`${emoji.id}\``),
- emoji: entry(emoji.name, `\`:${emoji.name}:\``),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
- },
- hidden: {
- guild: emoji.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+ const auditLog = await getAuditLog(emoji.guild, "STICKER_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "stickerCreate",
+ displayName: "Sticker Created",
+ calculateType: "stickerUpdate",
+ color: NucleusColors.green,
+ emoji: "GUILD.EMOJI.CREATE",
+ timestamp: emoji.createdTimestamp
+ },
+ list: {
+ stickerId: entry(emoji.id, `\`${emoji.id}\``),
+ emoji: entry(emoji.name, `\`:${emoji.name}:\``),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+ },
+ hidden: {
+ guild: emoji.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 0431bda..297e6b0 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,31 +1,29 @@
-export const event = 'stickerDelete'
+export const event = "stickerDelete";
export async function callback(client, emoji) {
- try{
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'STICKER_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'stickerDelete',
- displayName: 'Sticker Deleted',
- calculateType: 'stickerUpdate',
- color: NucleusColors.red,
- emoji: "GUILD.EMOJI.DELETE",
- timestamp: audit.createdTimestamp,
- },
- list: {
- stickerId:entry(emoji.id, `\`${emoji.id}\``),
- sticker: entry(emoji.name, `\`${emoji.name}\``),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
- deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
- },
- hidden: {
- guild: emoji.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+ const auditLog = await getAuditLog(emoji.guild, "STICKER_DELETE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === emoji.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "stickerDelete",
+ displayName: "Sticker Deleted",
+ calculateType: "stickerUpdate",
+ color: NucleusColors.red,
+ emoji: "GUILD.EMOJI.DELETE",
+ timestamp: audit.createdTimestamp
+ },
+ list: {
+ stickerId:entry(emoji.id, `\`${emoji.id}\``),
+ sticker: entry(emoji.name, `\`${emoji.name}\``),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+ deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp))
+ },
+ hidden: {
+ guild: emoji.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 363e072..1bb0fe6 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,34 +1,32 @@
-export const event = 'stickerUpdate';
+export const event = "stickerUpdate";
export async function callback(client, oe, ne) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
- if (oe.name === ne.name) return
- let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
- let audit = auditLog.entries.first();
- if (audit.executor.id === client.user.id) return;
+ if (oe.name === ne.name) return;
+ const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
+ const audit = auditLog.entries.first();
+ if (audit.executor.id === client.user.id) return;
- let changes = {
- stickerId:entry(ne.id, `\`${ne.id}\``),
- edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
- editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
- name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+ const changes = {
+ stickerId:entry(ne.id, `\`${ne.id}\``),
+ edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+ editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+ name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``)
+ };
+ const data = {
+ meta:{
+ type: "stickerUpdate",
+ displayName: "Sticker Edited",
+ calculateType: "stickerUpdate",
+ color: NucleusColors.yellow,
+ emoji: "GUILD.EMOJI.EDIT",
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: ne.guild.id
}
- let data = {
- meta:{
- type: 'stickerUpdate',
- displayName: 'Sticker Edited',
- calculateType: 'stickerUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.EMOJI.EDIT",
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: ne.guild.id
- }
- }
- log(data);
- } catch {}
+ };
+ log(data);
}
\ No newline at end of file
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index ef7246d..d6b9e93 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -1,34 +1,32 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadCreate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadCreate";
export async function callback(client, thread) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
- let auditLog = await getAuditLog(thread.guild, 'THREAD_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
- if (audit.executor.id === client.user.id) return;
- let data = {
- meta: {
- type: 'channelCreate',
- displayName: 'Thread Created',
- calculateType: 'channelUpdate',
- color: NucleusColors.green,
- emoji: "CHANNEL.TEXT.CREATE",
- timestamp: thread.createdTimestamp
- },
- list: {
- threadId:entry(thread.id, `\`${thread.id}\``),
- name: entry(thread.name, renderChannel(thread)),
- 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'),
- autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
- },
- hidden: {
- guild: thread.guild.id
- }
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+ const auditLog = await getAuditLog(thread.guild, "THREAD_CREATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const data = {
+ meta: {
+ type: "channelCreate",
+ displayName: "Thread Created",
+ calculateType: "channelUpdate",
+ color: NucleusColors.green,
+ emoji: "CHANNEL.TEXT.CREATE",
+ timestamp: thread.createdTimestamp
+ },
+ list: {
+ threadId:entry(thread.id, `\`${thread.id}\``),
+ name: entry(thread.name, renderChannel(thread)),
+ 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"),
+ autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
+ },
+ hidden: {
+ guild: thread.guild.id
}
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index 9574826..f3a59e7 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -1,17 +1,16 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadDelete'
+import humanizeDuration from "humanize-duration";
+export const event = "threadDelete";
export async function callback(client, thread) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
- let auditLog = await getAuditLog(thread.guild, 'THREAD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+ const auditLog = await getAuditLog(thread.guild, "THREAD_UPDATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === thread.id).first();
if (audit.executor.id === client.user.id) return;
- let data = {
+ const data = {
meta: {
- type: 'channelDelete',
- displayName: 'Thread Deleted',
- calculateType: 'channelUpdate',
+ type: "channelDelete",
+ displayName: "Thread Deleted",
+ calculateType: "channelUpdate",
color: NucleusColors.red,
emoji: "CHANNEL.TEXT.DELETE",
timestamp: new Date().getTime()
@@ -20,7 +19,7 @@
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'),
+ category: entry(thread.parent.parent ? thread.parent.parent.name : "None", thread.parent.parent ? renderChannel(thread.parent.parent) : "None"),
autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
membersInThread: entry(thread.memberCount, thread.memberCount),
deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
@@ -30,7 +29,6 @@
hidden: {
guild: thread.guild.id
}
- }
+ };
log(data);
- } catch {}
}
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 8550ffe..89a721c 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -1,43 +1,41 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'threadUpdate'
+import humanizeDuration from "humanize-duration";
+export const event = "threadUpdate";
export async function callback(client, before, after) {
- try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger
- let auditLog = await getAuditLog(after.guild, 'THREAD_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
- if (audit.executor.id === client.user.id) return;
- let list = {
- threadId:entry(after.id, `\`${after.id}\``),
- thread: entry(after.name, renderChannel(after)),
- parentChannel: entry(after.parentId, renderChannel(after.parent)),
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
+ const auditLog = await getAuditLog(after.guild, "THREAD_UPDATE");
+ const audit = auditLog.entries.filter(entry => entry.target.id === after.id).first();
+ if (audit.executor.id === client.user.id) return;
+ const list = {
+ threadId:entry(after.id, `\`${after.id}\``),
+ thread: entry(after.name, renderChannel(after)),
+ parentChannel: entry(after.parentId, renderChannel(after.parent))
+ };
+ if (before.name !== after.name) {
+ list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ }
+ if (before.autoArchiveDuration !== after.autoArchiveDuration) {
+ list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
+ }
+ if (before.rateLimitPerUser !== after.rateLimitPerUser) {
+ list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
+ }
+ if (!(Object.keys(list).length - 3)) return;
+ list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()));
+ list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor));
+ const data = {
+ meta: {
+ type: "channelUpdate",
+ displayName: "Thread Edited",
+ calculateType: "channelUpdate",
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: list,
+ hidden: {
+ guild: after.guild.id
}
- if (before.name !== after.name) {
- list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
- }
- if (before.autoArchiveDuration !== after.autoArchiveDuration) {
- list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
- }
- if (before.rateLimitPerUser !== after.rateLimitPerUser) {
- list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
- }
- if (!(Object.keys(list).length - 3)) return;
- list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
- list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
- let data = {
- meta: {
- type: 'channelUpdate',
- displayName: 'Thread Edited',
- calculateType: 'channelUpdate',
- color: NucleusColors.yellow,
- emoji: "CHANNEL.TEXT.EDIT",
- timestamp: new Date().getTime()
- },
- list: list,
- hidden: {
- guild: after.guild.id
- }
- }
- log(data);
- } catch {}
+ };
+ log(data);
}
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 28768b2..a11fa63 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -1,35 +1,38 @@
-import humanizeDuration from 'humanize-duration';
-export const event = 'webhookUpdate'
+import type Discord from "discord.js";
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
+// @ts-ignore
+import type { HaikuClient } from "jshaiku";
+export const event = "webhookUpdate";
-export async function callback(client, channel) {
+export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
- let auditLogCreate = getAuditLog(channel.guild, 'WEBHOOK_CREATE');
- let auditLogUpdate = getAuditLog(channel.guild, 'WEBHOOK_UPDATE');
- let auditLogDelete = getAuditLog(channel.guild, 'WEBHOOK_DELETE');
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+ let auditLogCreate = getAuditLog(channel.guild, "WEBHOOK_CREATE");
+ let auditLogUpdate = getAuditLog(channel.guild, "WEBHOOK_UPDATE");
+ let auditLogDelete = getAuditLog(channel.guild, "WEBHOOK_DELETE");
[auditLogCreate, auditLogUpdate, auditLogDelete] = await Promise.all([auditLogCreate, auditLogUpdate, auditLogDelete]);
- let auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
- let auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
- let auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
+ const auditCreate = auditLogCreate.entries.filter(entry => entry.target.channelId === channel.id).first();
+ const auditUpdate = auditLogUpdate.entries.filter(entry => entry.target.channelId === channel.id).first();
+ const auditDelete = auditLogDelete.entries.filter(entry => entry.target.channelId === channel.id).first();
if (!auditCreate && !auditUpdate && !auditDelete) return;
let audit = auditCreate;
let action = "Create";
- let list = {} as any;
+ let list = {} as {created: { value: string, displayValue: string }, updated: { value: string, displayValue: string }, deleted: { value: string, displayValue: string }};
if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
- let {before, after} = auditUpdate.changes.reduce(
+ const {before, after} = auditUpdate.changes.reduce(
(acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
{before: {}, after: {}}
);
- if (before.name !== after.name) list['name'] = entry([before.name, after.name], `${before.name} -> ${after.name}`)
- if (before.channel_id !== after.channel_id) list['channel'] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + ` -> ` + renderChannel(await client.channels.fetch(after.channel_id)))
+ if (before.name !== after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ if (before.channel_id !== after.channel_id) list["channel"] = entry([before.channel_id, after.channel_id], renderChannel(await client.channels.fetch(before.channel_id)) + " -> " + 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.edited = entry(after.editedTimestamp, renderDelta(new Date().getTime()));
list.editedBy = entry(auditUpdate.executor.id, renderUser(auditUpdate.executor));
audit = auditUpdate;
- action = "Update"
+ action = "Update";
} else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
- let {before, after} = auditDelete.changes.reduce(
+ const {before} = auditDelete.changes.reduce(
(acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
{before: {}, after: {}}
);
@@ -38,12 +41,12 @@
channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
created: entry(auditDelete.target.createdTimestamp, renderDelta(auditDelete.target.createdTimestamp)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user)),
- }
+ deletedBy: entry(auditDelete.executor.id, renderUser((await channel.guild.members.fetch(auditDelete.executor.id)).user))
+ };
audit = auditDelete;
- action = "Delete"
+ action = "Delete";
} else {
- let {before, after} = auditDelete.changes.reduce(
+ const {before} = auditDelete.changes.reduce(
(acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
{before: {}, after: {}}
);
@@ -51,19 +54,19 @@
name: entry(before.name, `${before.name}`),
channel: entry(before.channel_id, renderChannel(await client.channels.fetch(before.channel_id))),
createdBy: entry(auditCreate.executor.id, renderUser((await channel.guild.members.fetch(auditCreate.executor.id)).user)),
- created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- }
+ created: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ };
}
- let cols = {
+ const cols = {
"Create": "green",
"Update": "yellow",
- "Delete": "red",
- }
- let data = {
+ "Delete": "red"
+ };
+ const data = {
meta: {
- type: 'webhook' + action,
+ type: "webhook" + action,
displayName: `Webhook ${action}d`,
- calculateType: 'webhookUpdate',
+ calculateType: "webhookUpdate",
color: NucleusColors[cols[action]],
emoji: "WEBHOOK." + action.toUpperCase(),
timestamp: new Date().getTime()
@@ -72,7 +75,7 @@
hidden: {
guild: channel.guild.id
}
- }
+ };
log(data);
- } catch(e) { console.log(e) }
+ } catch(e) { console.log(e); }
}