Fix a bunch of linter errors
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index c4c1347..7350ebd 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,49 +1,59 @@
export const event = "channelCreate";
export async function callback(client, channel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger;
+ 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();
+ 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";
- }
+ 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: {
@@ -58,9 +68,15 @@
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"),
+ 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))
+ created: entry(
+ channel.createdTimestamp,
+ renderDelta(channel.createdTimestamp)
+ )
},
hidden: {
guild: channel.guild.id
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index c8a72a4..af55205 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -3,58 +3,77 @@
export const event = "channelDelete";
export async function callback(client, channel) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } =
+ channel.client.logger;
const auditLog = await getAuditLog(channel.guild, "CHANNEL_DELETE");
- const audit = auditLog.entries.filter(entry => entry.target.id === channel.id).first();
+ 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";
- }
+ 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"),
+ category: entry(
+ channel.parent ? channel.parent.id : null,
+ channel.parent ? channel.parent.name : "Uncategorised"
+ ),
nsfw: null,
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+ 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\`\`\``);
+ 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`);
+ if (channel.nsfw !== null ?? false)
+ list.nsfw = entry(
+ channel.nsfw,
+ channel.nsfw
+ ? `${getEmojiByName("CONTROL.TICK")} Yes`
+ : `${getEmojiByName("CONTROL.CROSS")} No`
+ );
else delete list.nsfw;
const data = {
- meta:{
+ meta: {
type: "channelDelete",
displayName: displayName + " Deleted",
calculateType: "channelUpdate",
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index 89692e8..6717661 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -5,118 +5,218 @@
export async function callback(client, oc, nc) {
const config = await client.memory.readGuildInfo(nc.guild.id);
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger;
+ 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;
const auditLog = await getAuditLog(nc.guild, "CHANNEL_UPDATE");
- const audit = auditLog.entries.filter(entry => entry.target.id === nc.id).first();
+ 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 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))
+ 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}`);
+ 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)}`
- );
+ 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";
- }
+ 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 (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:{
+ meta: {
type: "channelUpdate",
displayName: displayName + " Edited",
calculateType: "channelUpdate",
@@ -130,4 +230,4 @@
}
};
log(data);
-}
\ No newline at end of file
+}
diff --git a/src/events/commandError.ts b/src/events/commandError.ts
index 2ec6a5d..ce50122 100644
--- a/src/events/commandError.ts
+++ b/src/events/commandError.ts
@@ -4,18 +4,26 @@
export async function callback(client, interaction, error) {
if (interaction.replied || interaction.deferred) {
- await interaction.followUp({embeds: [new EmojiEmbed()
- .setTitle("Something went wrong")
- .setDescription(error.message ?? error.toString())
- .setStatus("Danger")
- .setEmoji("CONTROL.BLOCKCROSS")
- ], ephemeral: true});
+ await interaction.followUp({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Something went wrong")
+ .setDescription(error.message ?? error.toString())
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ 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});
+ await interaction.reply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Something went wrong")
+ .setDescription(error.message ?? error.toString())
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ],
+ ephemeral: true
+ });
}
}
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 83a30e2..53f564c 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,9 +1,19 @@
export const event = "emojiCreate";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === emoji.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -18,7 +28,10 @@
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))
+ created: entry(
+ emoji.createdTimestamp,
+ renderDelta(emoji.createdTimestamp)
+ )
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index 5ed7a87..041b432 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,9 +1,19 @@
export const event = "emojiDelete";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === emoji.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -18,8 +28,14 @@
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))
+ created: entry(
+ emoji.createdTimestamp,
+ renderDelta(emoji.createdTimestamp)
+ ),
+ deleted: entry(
+ audit.createdTimestamp,
+ renderDelta(audit.createdTimestamp)
+ )
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index d04c6c8..34b16de 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -1,7 +1,15 @@
export const event = "emojiUpdate";
export async function callback(client, oe, ne) {
- 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;
const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
@@ -12,11 +20,14 @@
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)),
+ 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:{
+ meta: {
type: "emojiUpdate",
displayName: "Emoji Edited",
calculateType: "emojiUpdate",
@@ -30,4 +41,4 @@
}
};
log(data);
-}
\ No newline at end of file
+}
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index c5d269b..dd723d3 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -6,11 +6,20 @@
export async function callback(client, ban) {
await statsChannelRemove(client, ban.user);
purgeByUser(ban.user.id, ban.guild);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+ 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();
+ 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);
+ await client.database.history.create(
+ "ban",
+ ban.guild.id,
+ ban.user,
+ audit.executor,
+ audit.reason
+ );
const data = {
meta: {
type: "memberBan",
@@ -23,10 +32,19 @@
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())),
+ 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)),
+ 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: {
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 352265f..4c2263d 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -6,11 +6,20 @@
export async function callback(client, ban) {
await statsChannelRemove(client, ban.user);
purgeByUser(ban.user.id, ban.guild);
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger;
+ 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();
+ 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);
+ await client.database.history.create(
+ "unban",
+ ban.guild.id,
+ ban.user,
+ audit.executor,
+ audit.reason
+ );
const data = {
meta: {
type: "memberUnban",
@@ -23,9 +32,15 @@
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())),
+ 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))
+ accountCreated: entry(
+ ban.user.createdAt,
+ renderDelta(ban.user.createdAt)
+ )
},
hidden: {
guild: ban.guild.id
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index 8f8d0f5..5ae4248 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,6 +1,6 @@
import type { Guild } from "discord.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import type { HaikuClient } from "jshaiku";
import guide from "../reflex/guide.js";
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index a7f8c47..4cffe69 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -2,14 +2,29 @@
export async function callback(client, before, after) {
try {
- const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger;
+ 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();
+ 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) {
await client.database.history.create(
- "nickname", after.guild.id, after.user, audit.executor,
- null, before.nickname || before.user.username, after.nickname || after.user.username);
+ "nickname",
+ after.guild.id,
+ after.user,
+ audit.executor,
+ null,
+ before.nickname || before.user.username,
+ after.nickname || after.user.username
+ );
const data = {
meta: {
type: "memberUpdate",
@@ -22,19 +37,41 @@
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*"),
- changed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- changedBy: entry(audit.executor.id, renderUser(audit.executor))
+ 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()) {
+ } else if (
+ before.communicationDisabledUntilTimestamp < new Date().getTime() &&
+ after.communicationDisabledUntil > new Date().getTime()
+ ) {
await client.database.history.create(
- "mute", after.guild.id, after.user, audit.executor, audit.reason, null, null, null
+ "mute",
+ after.guild.id,
+ after.user,
+ audit.executor,
+ audit.reason,
+ null,
+ null,
+ null
);
const data = {
meta: {
@@ -48,25 +85,51 @@
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- 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*")
+ 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*"
+ )
},
hidden: {
guild: after.guild.id
}
};
log(data);
- client.database.eventScheduler.schedule("naturalUnmute", after.communicationDisabledUntil,
- {guild: after.guild.id, user: after.id, expires: after.communicationDisabledUntilTimestamp}
+ client.database.eventScheduler.schedule(
+ "naturalUnmute",
+ after.communicationDisabledUntil,
+ {
+ guild: after.guild.id,
+ user: after.id,
+ expires: after.communicationDisabledUntilTimestamp
+ }
);
} else if (
- after.communicationDisabledUntil === null && before.communicationDisabledUntilTimestamp !== null &&
+ after.communicationDisabledUntil === null &&
+ before.communicationDisabledUntilTimestamp !== null &&
new Date().getTime() >= audit.createdTimestamp
) {
await client.database.history.create(
- "unmute", after.guild.id, after.user, audit.executor, null, null, null, null
+ "unmute",
+ after.guild.id,
+ after.user,
+ audit.executor,
+ null,
+ null,
+ null,
+ null
);
const data = {
meta: {
@@ -80,15 +143,27 @@
list: {
memberId: entry(after.id, `\`${after.id}\``),
name: entry(after.user.id, renderUser(after.user)),
- unmuted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- unmutedBy: entry(audit.executor.id, renderUser(audit.executor))
+ unmuted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
+ unmutedBy: entry(
+ audit.executor.id,
+ renderUser(audit.executor)
+ )
},
hidden: {
guild: after.guild.id
}
};
log(data);
- client.database.eventScheduler.cancel("naturalUnmute", {guild: after.guild.id, user: after.id, expires: before.communicationDisabledUntilTimestamp});
+ 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 2cb1de8..2c87807 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -4,9 +4,12 @@
export async function callback(client, before, after) {
await statsChannelUpdate(client, after.me);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === after.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const list = {};
@@ -29,18 +32,65 @@
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 (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));
+ 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",
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 08fcc77..60b90e3 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -8,49 +8,123 @@
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"];
+ 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}}`); } }
+ 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"];
+ 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}}`); } }
+ 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.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"))); }
+ 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")
+ )
+ );
+ }
}
}
}
export async function callback(client, interaction) {
await interactionCreate(interaction);
-}
\ No newline at end of file
+}
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 1cbed02..5461307 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -2,9 +2,19 @@
export const event = "inviteCreate";
export async function callback(client, invite) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === invite.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -18,9 +28,15 @@
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"),
+ 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))
+ created: entry(
+ invite.createdTimestamp,
+ renderDelta(invite.createdTimestamp)
+ )
},
hidden: {
guild: invite.guild.id
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index cbe4d4b..e5bf241 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -2,9 +2,19 @@
export const event = "inviteDelete";
export async function callback(client, invite) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === invite.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -18,9 +28,15 @@
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"),
+ 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()))
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ )
},
hidden: {
guild: invite.guild.id
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 34545fb..ea0b24d 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -6,9 +6,16 @@
export async function callback(_, member) {
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);
+ 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",
@@ -22,7 +29,10 @@
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)),
+ accountCreated: entry(
+ member.user.createdAt,
+ renderDelta(member.user.createdAt)
+ ),
serverMemberCount: member.guild.memberCount
},
hidden: {
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 842a48b..d170396 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -6,9 +6,12 @@
export async function callback(client, member) {
purgeByUser(member.id, member.guild);
await statsChannelRemove(client, member);
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger;
+ 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();
+ 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;
@@ -18,7 +21,13 @@
}
let data;
if (type === "kick") {
- await client.database.history.create("kick", member.guild.id, member.user, audit.executor, audit.reason);
+ await client.database.history.create(
+ "kick",
+ member.guild.id,
+ member.user,
+ audit.executor,
+ audit.reason
+ );
data = {
meta: {
type: "memberKick",
@@ -32,10 +41,21 @@
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())),
+ 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)),
+ 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: {
@@ -43,7 +63,13 @@
}
};
} else {
- await client.database.history.create("leave", member.guild.id, member.user, null, null);
+ await client.database.history.create(
+ "leave",
+ member.guild.id,
+ member.user,
+ null,
+ null
+ );
data = {
meta: {
type: "memberLeave",
@@ -56,9 +82,18 @@
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)),
+ 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: {
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index bbb6a32..53de4df 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,24 +1,42 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import { HaikuClient } from "jshaiku";
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
+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 { callback as a } from "../reflex/statsChannelUpdate.js";
import type { Message } from "discord.js";
export const event = "messageCreate";
export async function callback(_client: HaikuClient, message: Message) {
- if(!message) return;
- if(!message.guild) return;
+ if (!message) return;
+ 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);}
+ 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;
const fileNames = await logAttachment(message);
@@ -26,36 +44,61 @@
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]})`; }
+ 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)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
mentions: message.mentions.users.size,
- attachments: entry(message.attachments.size, message.attachments.size + attachmentJump),
+ attachments: entry(
+ message.attachments.size,
+ message.attachments.size + attachmentJump
+ ),
repliedTo: entry(
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"
+ 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.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);
+ 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
+ );
message.delete();
const data = {
meta: {
type: "messageDelete",
- displayName: "Message Deleted (Automated, Contained Invite)",
+ displayName:
+ "Message Deleted (Automated, Contained Invite)",
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
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: {
@@ -69,15 +112,26 @@
if (fileNames.files.length > 0) {
for (const element of fileNames.files) {
- if(!message) return;
+ if (!message) return;
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.type === "GUILD_PUBLIC_THREAD" ? false : message.channel.nsfw
- )) {
+ if (
+ /\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(
+ url
+ )
+ ) {
+ 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);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -89,7 +143,12 @@
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: {
@@ -101,9 +160,17 @@
}
if (config.filters.wordFilter.enabled) {
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);
+ 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();
const data = {
meta: {
@@ -115,7 +182,12 @@
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: {
@@ -126,9 +198,13 @@
}
}
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);
+ if (url.match(/\.+(webp|png|jpg)$/gi)) {
+ if (!(await SizeCheck(element))) {
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -140,7 +216,12 @@
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: {
@@ -154,7 +235,11 @@
}
if (config.filters.malware) {
if (!MalwareCheck(url)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -166,7 +251,12 @@
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: {
@@ -179,7 +269,7 @@
}
}
}
- if(!message) return;
+ if (!message) return;
const linkDetectionTypes = await LinkCheck(message);
if (linkDetectionTypes.length > 0) {
@@ -195,7 +285,12 @@
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: {
@@ -206,9 +301,17 @@
}
if (config.filters.wordFilter.enabled) {
- 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);
+ 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();
const data = {
meta: {
@@ -220,7 +323,12 @@
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: {
@@ -242,7 +350,9 @@
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: {
@@ -252,10 +362,14 @@
return log(data);
}
if (config.filters.pings.roles) {
- for(const roleId in message.mentions.roles) {
- if(!message) return;
+ for (const roleId in message.mentions.roles) {
+ if (!message) return;
if (!config.filters.pings.allowed.roles.includes(roleId)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -267,7 +381,9 @@
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: {
@@ -278,7 +394,10 @@
}
}
}
- if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+ 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();
const data = {
@@ -291,7 +410,9 @@
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: {
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 473fa52..4cdbdb2 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -3,10 +3,25 @@
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;
+ 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;
const auditLog = await getAuditLog(message.guild, "MEMBER_BAN_ADD");
- const audit = auditLog.entries.filter(entry => entry.target.id === message.author.id).first();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === message.author.id)
+ .first();
if (audit) {
if (audit.createdAt - 100 < new Date().getTime()) return;
}
@@ -14,10 +29,19 @@
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;
+ 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 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",
@@ -28,18 +52,28 @@
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}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
- sentIn: entry(message.channel.id, renderChannel(message.channel)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ sentIn: entry(
+ message.channel.id,
+ renderChannel(message.channel)
+ ),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ ),
mentions: message.mentions.users.size,
attachments: entry(attachments, attachments + attachmentJump),
repliedTo: entry(
message.reference.messageId || null,
- message.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
+ message.reference.messageId
+ ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})`
+ : "None"
)
},
hidden: {
@@ -47,5 +81,7 @@
}
};
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 148cdb7..c83512c 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,15 +2,29 @@
export async function callback(client, oldMessage, newMessage) {
if (newMessage.author.id === client.user.id) return;
- const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger;
+ 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})`; }
+ 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")) {
+ if (
+ !oldMessage.flags.has("CROSSPOSTED") &&
+ newMessage.flags.has("CROSSPOSTED")
+ ) {
const data = {
meta: {
type: "messageAnnounce",
@@ -25,14 +39,35 @@
},
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),
+ 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
+ renderNumberDelta(
+ oldMessage.attachments.size,
+ newMessage.attachments.size
+ ),
+ renderNumberDelta(
+ oldMessage.attachments.size,
+ newMessage.attachments.size
+ ) + attachmentJump
)
},
hidden: {
@@ -42,9 +77,13 @@
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) + "...";
+ 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",
@@ -55,24 +94,49 @@
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*"),
+ 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),
+ 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
+ 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"
+ newMessage.reference.messageId
+ ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})`
+ : "None"
)
},
hidden: {
@@ -80,4 +144,4 @@
}
};
log(data);
-}
\ No newline at end of file
+}
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index a717242..f0051a0 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,10 +1,20 @@
export const event = "roleCreate";
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === role.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -19,7 +29,10 @@
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))
+ created: entry(
+ role.createdTimestamp,
+ renderDelta(role.createdTimestamp)
+ )
},
hidden: {
guild: role.guild.id
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index ad74584..185ea8e 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,10 +3,13 @@
export const event = "roleDelete";
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === role.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -21,12 +24,28 @@
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`),
+ 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()))
+ created: entry(
+ role.createdTimestamp,
+ renderDelta(role.createdTimestamp)
+ ),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ )
},
hidden: {
guild: role.guild.id
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index c51a9b3..be276e5 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -3,7 +3,15 @@
export const event = "roleUpdate";
export async function callback(client, or, nr) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger;
+ const {
+ getAuditLog,
+ log,
+ NucleusColors,
+ entry,
+ renderDelta,
+ renderUser,
+ renderRole
+ } = client.logger;
const auditLog = await getAuditLog(nr.guild, "ROLE_UPDATE");
const audit = auditLog.entries.first();
@@ -13,24 +21,52 @@
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))
+ 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}\``);
+ 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:{
+ meta: {
type: "roleUpdate",
displayName: "Role Edited",
calculateType: "guildRoleUpdate",
@@ -44,4 +80,4 @@
}
}; // 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 43f2e9c..54de270 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,9 +1,12 @@
export const event = "stickerCreate";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === emoji.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -18,7 +21,10 @@
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))
+ created: entry(
+ emoji.createdTimestamp,
+ renderDelta(emoji.createdTimestamp)
+ )
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 297e6b0..f390b5c 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,9 +1,12 @@
export const event = "stickerDelete";
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = emoji.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === emoji.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -15,11 +18,17 @@
timestamp: audit.createdTimestamp
},
list: {
- stickerId:entry(emoji.id, `\`${emoji.id}\``),
+ 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))
+ created: entry(
+ emoji.createdTimestamp,
+ renderDelta(emoji.createdTimestamp)
+ ),
+ deleted: entry(
+ audit.createdTimestamp,
+ renderDelta(audit.createdTimestamp)
+ )
},
hidden: {
guild: emoji.guild.id
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index 1bb0fe6..46c4d17 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,7 +1,8 @@
export const event = "stickerUpdate";
export async function callback(client, oe, ne) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = client.logger;
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } =
+ client.logger;
if (oe.name === ne.name) return;
const auditLog = await getAuditLog(ne.guild, "EMOJI_UPDATE");
@@ -9,13 +10,16 @@
if (audit.executor.id === client.user.id) return;
const changes = {
- stickerId:entry(ne.id, `\`${ne.id}\``),
+ 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)),
+ 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:{
+ meta: {
type: "stickerUpdate",
displayName: "Sticker Edited",
calculateType: "stickerUpdate",
@@ -29,4 +33,4 @@
}
};
log(data);
-}
\ No newline at end of file
+}
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index d6b9e93..4fdedcb 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -2,9 +2,19 @@
export const event = "threadCreate";
export async function callback(client, thread) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === thread.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -16,13 +26,26 @@
timestamp: thread.createdTimestamp
},
list: {
- threadId:entry(thread.id, `\`${thread.id}\``),
+ 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 })),
+ 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))
+ created: entry(
+ thread.createdTimestamp,
+ renderDelta(thread.createdTimestamp)
+ )
},
hidden: {
guild: thread.guild.id
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index f3a59e7..0077eff 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -2,9 +2,19 @@
export const event = "threadDelete";
export async function callback(client, thread) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger;
+ 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();
+ const audit = auditLog.entries
+ .filter((entry) => entry.target.id === thread.id)
+ .first();
if (audit.executor.id === client.user.id) return;
const data = {
meta: {
@@ -16,15 +26,31 @@
timestamp: new Date().getTime()
},
list: {
- threadId:entry(thread.id, `\`${thread.id}\``),
+ 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"),
- autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
+ 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)),
- created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ created: entry(
+ thread.createdTimestamp,
+ renderDelta(thread.createdTimestamp)
+ ),
+ deleted: entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ )
},
hidden: {
guild: thread.guild.id
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 89a721c..ff36ce0 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -2,27 +2,55 @@
export const event = "threadUpdate";
export async function callback(client, before, after) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger;
+ 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();
+ 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}\``),
+ 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}`);
+ 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 })}`);
+ 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)}`);
+ 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));
+ list.updated = entry(
+ new Date().getTime(),
+ renderDelta(new Date().getTime())
+ );
+ list.updatedBy = entry(audit.executor.id, renderUser(audit.executor));
const data = {
meta: {
type: "channelUpdate",
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index a11fa63..f600247 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -1,66 +1,169 @@
import type Discord from "discord.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import type { HaikuClient } from "jshaiku";
export const event = "webhookUpdate";
-export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
+export async function callback(
+ client: HaikuClient,
+ channel: Discord.GuildChannel
+) {
try {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger;
+ 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]);
- 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();
+ [auditLogCreate, auditLogUpdate, auditLogDelete] = await Promise.all([
+ auditLogCreate,
+ auditLogUpdate,
+ auditLogDelete
+ ]);
+ 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 {created: { value: string, displayValue: string }, updated: { value: string, displayValue: string }, deleted: { value: string, displayValue: string }};
- if (auditUpdate && auditUpdate.createdTimestamp > audit.createdTimestamp) {
- const {before, after} = auditUpdate.changes.reduce(
- (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
- {before: {}, after: {}}
+ let list = {} as {
+ created: { value: string; displayValue: string };
+ updated: { value: string; displayValue: string };
+ deleted: { value: string; displayValue: string };
+ };
+ if (
+ auditUpdate &&
+ auditUpdate.createdTimestamp > audit.createdTimestamp
+ ) {
+ 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 (!(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));
+ 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";
- } else if (auditDelete && auditDelete.createdTimestamp > audit.createdTimestamp) {
- const {before} = auditDelete.changes.reduce(
- (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
- {before: {}, after: {}}
+ } else if (
+ auditDelete &&
+ auditDelete.createdTimestamp > audit.createdTimestamp
+ ) {
+ const { before } = auditDelete.changes.reduce(
+ (acc, change) => {
+ acc.before[change.key] = change.old;
+ acc.after[change.key] = change.new;
+ return acc;
+ },
+ { before: {}, after: {} }
);
list = {
name: entry(before.name, `${before.name}`),
- 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))
+ 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
+ )
+ )
};
audit = auditDelete;
action = "Delete";
} else {
- const {before} = auditDelete.changes.reduce(
- (acc, change) => { acc.before[change.key] = change.old; acc.after[change.key] = change.new; return acc; },
- {before: {}, after: {}}
+ const { before } = auditDelete.changes.reduce(
+ (acc, change) => {
+ acc.before[change.key] = change.old;
+ acc.after[change.key] = change.new;
+ return acc;
+ },
+ { before: {}, after: {} }
);
list = {
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()))
+ 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())
+ )
};
}
const cols = {
- "Create": "green",
- "Update": "yellow",
- "Delete": "red"
+ Create: "green",
+ Update: "yellow",
+ Delete: "red"
};
const data = {
meta: {
@@ -77,5 +180,7 @@
}
};
log(data);
- } catch(e) { console.log(e); }
+ } catch (e) {
+ console.log(e);
+ }
}