i have not committed in years
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index 49bd3c3..ac29238 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -1,3 +1,5 @@
+import getEmojiByName from "../utils/getEmojiByName.js";
+
export const event = 'channelDelete'
export async function callback(client, channel) {
@@ -35,6 +37,21 @@
displayName = "Channel"
}
}
+ let list = {
+ id: entry(channel.id, `\`${channel.id}\``),
+ name: entry(channel.id, `${channel.name}`),
+ topic: null,
+ type: entry(channel.type, readableType),
+ category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+ nsfw: null,
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor))
+ }
+ if (channel.topic != null ?? false) list.topic = entry(channel.topic, `\`\`\`\n${channel.topic.replace('`', "'")}\n\`\`\``);
+ else delete list.topic;
+ if (channel.nsfw !== null ?? false) list.nsfw = entry(channel.nsfw, channel.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`);
+ else delete list.nsfw;
let data = {
meta:{
@@ -45,15 +62,7 @@
emoji: emoji,
timestamp: audit.createdTimestamp
},
- list: { // TODO: Add stuff like nsfw, theres loads missing here
- id: entry(channel.id, `\`${channel.id}\``),
- name: entry(channel.id, `${channel.name}`),
- type: entry(channel.type, readableType),
- category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor))
- },
+ list: list,
hidden: {
guild: channel.guild.id
}
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index f5d2f4d..f374edd 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -20,7 +20,7 @@
let changes = {
id: entry(nc.id, `\`${nc.id}\``),
channel: entry(nc.id, renderChannel(nc)),
- edited: entry(nc.createdTimestamp, renderDelta(nc.createdTimestamp)),
+ edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
}
if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
@@ -114,7 +114,7 @@
}
let t = oc.type.split("_")[1];
if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
-
+ if (!(Object.values(changes).length - 4)) return
let data = {
meta:{
type: 'channelUpdate',
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index b437b37..4935b4d 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,56 +1,10 @@
import { MessageActionRow, MessageButton } from "discord.js";
import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
-import getEmojiByName from "../utils/getEmojiByName";
+import getEmojiByName from "../utils/getEmojiByName.js";
+import guide from "../automations/guide.js";
export const event = 'guildCreate';
-export const callback = async (client, guild) => {
- let pages = [
- new generateEmojiEmbed()
- .setTitle("Welcome to Nucleus")
- .setDescription(
- "Thanks for adding Nucleus to your server\n\n" +
- "On the next few pages you can find instructions on getting started, and commands you may want to set up\n\n" +
- "If you need support, have questions or want features, you can let us know in [Clicks](https://discord.gg/bPaNnxe)"
- )
- .setEmoji("NUCLEUS.LOGO")
- .setStatus("Danger"),
- new generateEmojiEmbed()
- ]
- let m = await guild.systemChannel.send({embeds: [
- new generateEmojiEmbed()
- .setTitle("Welcome")
- .setDescription(`One moment...`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOADING")
- ], fetchReply: true });
- let page = 0;
-
- let f = async () => {
-
- }
-
- while (true) {
- // edit interaction with pages[page]
- await m.edit({
- embeds: [pages[page].setFooter({text: `Page ${page + 1}/${pages.length}`})],
- components: [new MessageActionRow().addComponents([
- new MessageButton().setCustomId("left").setEmoji(getEmojiByName("CONTROL.LEFT", "id")).setDisabled(page === 0),
- new MessageButton().setCustomId("right").setEmoji(getEmojiByName("CONTROL.RIGHT", "id")).setDisabled(page === pages.length - 1)
- ])],
- fetchReply: true
- });
- // wait for interaction
- let interaction = await m.awaitMessageComponent({filter:f, componentType: "BUTTON", time: 60000});
- // change page variable accordingly
- if (interaction.component.customId == "left") {
- if (page > 0) page--;
- } else if (interaction.component.customId == "right") {
- if (page < pages.length - 1) page++;
- } else {
- await m.delete()
- break;
- }
- // break if required
- }
-}
\ No newline at end of file
+export async function callback(client, guild) {
+ guide(guild)
+}
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 46d7696..ea461ab 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,10 +1,12 @@
import humanizeDuration from 'humanize-duration';
+import { purgeByUser } from '../automations/tickets/delete.js';
import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
export const event = 'guildMemberRemove'
export async function callback(_, member) {
try { await statsChannelRemove(_, member); } catch {}
+ try { purgeByUser(member.id, member.guild); } catch {} // TODO: add this to ban as well
try {
const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
let data = {
diff --git a/src/events/messageChecks.ts b/src/events/messageChecks.ts
index 71ca965..83cfff1 100644
--- a/src/events/messageChecks.ts
+++ b/src/events/messageChecks.ts
@@ -1,4 +1,4 @@
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString } from '../automations/unscan.js'
+import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../automations/unscan.js'
import readConfig from '../utils/readConfig.js'
import { Message } from 'discord.js'
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 3b7c5c2..ccaacb8 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -16,7 +16,7 @@
timestamp: new Date().getTime()
},
separate: {
- start: `**Message:**\n\`\`\`${content}\`\`\``
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
},
list: {
id: entry(message.id, `\`${message.id}\``),
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index bb74f8d..318b0ef 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -2,11 +2,11 @@
export async function callback(client, oldMessage, newMessage) {
if (newMessage.author.id == client.user.id) return;
- if (!newMessage.content || !oldMessage.content) return;
const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
newMessage.reference = newMessage.reference || {}
- let newContent = newMessage.cleanContent
- let oldContent = oldMessage.cleanContent
+ let newContent = newMessage.cleanContent.replaceAll("`", "‘")
+ let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
+ if (newContent == oldContent) return;
if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
let data = {
@@ -19,7 +19,8 @@
timestamp: newMessage.editedTimestamp
},
separate: {
- start: `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n**After:**\n\`\`\`\n${newContent}\n\`\`\``,
+ 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: {
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 487a45e..76af433 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -2,6 +2,7 @@
export async function callback(client, role) {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
+ if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
if (audit.executor.id == client.user.id) return;
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 0c6d03e..c5cbe63 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,7 +3,8 @@
export const event = 'roleDelete'
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
+ if (role.managed) return;
let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
if (audit.executor.id == client.user.id) return;