few changes
diff --git a/src/api/index.ts b/src/api/index.ts
new file mode 100644
index 0000000..bd15679
--- /dev/null
+++ b/src/api/index.ts
@@ -0,0 +1,70 @@
+import { HaikuClient } from 'jshaiku';
+import express from 'express';
+import bodyParser from 'body-parser';
+import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
+
+const jsonParser = bodyParser.json();
+const app = express();
+const port = 10000;
+
+const runServer = (client: HaikuClient) => {
+ app.get('/', (req, res) => {
+ res.send(client.ws.ping);
+ });
+
+ app.post('/verify/:code', jsonParser, async function (req, res) {
+ const code = req.params.code;
+ const secret = req.body.secret;
+ if (secret === client.config.verifySecret) {
+ let guild = await client.guilds.fetch(client.verify[code].gID);
+ if (!guild) { return res.status(404) }
+ let member = await guild.members.fetch(client.verify[code].uID);
+ if (!member) { return res.status(404) }
+ if (member.roles.cache.has(client.verify[code].rID)) { return res.status(200) }
+ await member.roles.add(client.verify[code].rID);
+
+ let interaction = client.verify[code].interaction;
+ if (interaction) {
+ interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Verification complete`)
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ ], components: []});
+ }
+ res.status(200).send();
+ } else {
+ res.status(403).send();
+ }
+ });
+
+ app.patch('/verify/:code', (req, res) => {
+ const code = req.params.code;
+ try {
+ let interaction = client.verify[code].interaction;
+ if (interaction) {
+ interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Verify was opened in another tab or window, please complete the CAPTCHA there to continue`)
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ ]});
+ }
+ } catch {}
+ res.status(200).send();
+ })
+
+ app.get('/verify/:code', jsonParser, function (req, res) {
+ const code = req.params.code;
+ if (client.verify[code]) {
+ let data = structuredClone(client.verify[code])
+ delete data.interaction;
+ return res.status(200).send(data);
+ }
+ return res.status(404).send();
+ })
+
+ app.listen(port);
+}
+
+export default runServer;
\ No newline at end of file
diff --git a/src/automations/createModActionTicket.ts b/src/automations/createModActionTicket.ts
index a4d549c..4de2924 100644
--- a/src/automations/createModActionTicket.ts
+++ b/src/automations/createModActionTicket.ts
@@ -1,6 +1,7 @@
-import Discord from 'discord.js';
+import Discord, { MessageActionRow, MessageButton } from 'discord.js';
import readConfig from '../utils/readConfig.js'
-import generateEmojiEmbed from '../utils/generateEmojiEmbed.js'
+import generateEmojiEmbed from '../utils/generateEmojiEmbed.js';
+import getEmojiByName from "../utils/getEmojiByName.js";
export async function create(guild: Discord.Guild, member: Discord.User, client) {
let config = await readConfig(guild.id);
@@ -52,7 +53,12 @@
)
.setStatus("Success")
.setEmoji("GUILD.TICKET.OPEN")
- ]})
+ ], components: [new MessageActionRow().addComponents([new MessageButton()
+ .setLabel("Close")
+ .setStyle("DANGER")
+ .setCustomId("closeticket")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])]})
let data = {
meta:{
type: 'ticketCreate',
diff --git a/src/automations/guide.ts b/src/automations/guide.ts
index 66c9eb0..e3cfa25 100644
--- a/src/automations/guide.ts
+++ b/src/automations/guide.ts
@@ -3,8 +3,8 @@
import getEmojiByName from "../utils/getEmojiByName.js";
export default async (guild, interaction?) => {
- let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
- c = c ? c : guild.channels.cache.find(ch => ch.type === "GUILD_TEXT" && ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") && ch.permissionsFor(guild.me).has("EMBED_LINKS"));
+ let c = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
+ c = c ? c : guild.channels.cache.find(ch => ch.type === "GUILD_TEXT" && ch.permissionsFor(guild.roles.everyone).has("SEND_MESSAGES") && ch.permissionsFor(guild.me).has("EMBED_LINKS"));
let pages = [
new generateEmojiEmbed()
.setTitle("Welcome to Nucleus")
@@ -73,7 +73,7 @@
.setEmoji("NUCLEUS.LOGO")
.setStatus("Danger")
]
- let m;
+ let m;
if (interaction) {
m = await interaction.reply({embeds: [
new generateEmojiEmbed()
@@ -90,7 +90,7 @@
.setStatus("Danger")
.setEmoji("NUCLEUS.LOADING")
], fetchReply: true });
- }
+ }
let page = 0;
let f = async (component) => {
diff --git a/src/automations/roleMenu.ts b/src/automations/roleMenu.ts
index 2412c70..c7073c5 100644
--- a/src/automations/roleMenu.ts
+++ b/src/automations/roleMenu.ts
@@ -58,7 +58,7 @@
new MessageButton()
.setLabel("Online")
.setStyle("LINK")
- .setURL(`https://clicksminuteper.net/nuclues/rolemenu?code=${code}`),
+ .setURL(`https://clicks.codes/nuclues/rolemenu?code=${code}`),
new MessageButton()
.setLabel("Manual")
.setStyle("PRIMARY")
diff --git a/src/automations/unscan.ts b/src/automations/unscan.ts
index 743374b..b5c5ffb 100644
--- a/src/automations/unscan.ts
+++ b/src/automations/unscan.ts
@@ -40,11 +40,11 @@
export async function SizeCheck(element): Promise<boolean> {
if (element.height == undefined || element.width == undefined) return true
if (element.height < 20 || element.width < 20) return false
- return true
+ return true
}
export async function MalwareCheck(element): Promise<boolean> {
- try {
+ try {
//@ts-ignore
return (await scan.testMalware(element)).safe
} catch {
diff --git a/src/automations/verify.ts b/src/automations/verify.ts
index 80087a4..a60ed07 100644
--- a/src/automations/verify.ts
+++ b/src/automations/verify.ts
@@ -28,7 +28,7 @@
.setEmoji("NUCLEUS.LOADING")
]});
try {
- let status = await fetch(`https://clicksminuteper.net`).then(res => res.status);
+ let status = await fetch(`https://clicks.codes`).then(res => res.status);
if (status != 200) {
return await interaction.editReply({embeds: [new generateEmojiEmbed()
.setTitle("Verify")
@@ -45,9 +45,9 @@
.setEmoji("CONTROL.BLOCKCROSS")
], components: [new Discord.MessageActionRow().addComponents([
new Discord.MessageButton()
- .setLabel("Open webpage")
+ .setLabel("Check webpage")
.setStyle("LINK")
- .setURL("https://clicksminuteper.net/"),
+ .setURL("https://clicks.codes/"),
new Discord.MessageButton()
.setLabel("Support")
.setStyle("LINK")
@@ -111,10 +111,12 @@
verify[code] = {
uID: interaction.member.user.id,
gID: interaction.guild.id,
+ rID: config.verify.role,
rName: (await interaction.guild.roles.fetch(config.verify.role)).name,
mCount: interaction.guild.memberCount,
gName: interaction.guild.name,
- guildIcon: interaction.guild.iconURL({format: "png"})
+ gIcon: interaction.guild.iconURL({format: "png"}),
+ interaction: interaction
}
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setTitle("Verify")
@@ -124,6 +126,7 @@
], components: [new Discord.MessageActionRow().addComponents([new Discord.MessageButton()
.setLabel("Verify")
.setStyle("LINK")
- .setURL(`https://clicksminuteper.net/nucleus/verify?code=${code}`)
+ // .setURL(`https://clicks.codes/nucleus/verify?code=${code}`)
+ .setURL(`https://insulation-coin-hoping-nevertheless.trycloudflare.com/nucleus/verify?code=${code}`)
])]});
-}
\ No newline at end of file
+}
diff --git a/src/automations/welcome.ts b/src/automations/welcome.ts
index 09e03d3..84a87ec 100644
--- a/src/automations/welcome.ts
+++ b/src/automations/welcome.ts
@@ -3,7 +3,7 @@
import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
export async function callback(_, member) {
- if (member.bot) return
+ if (member.bot) return
let config = await readConfig(member.guild.id);
if (!config.welcome.enabled) return
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index e94035e..8da4f1c 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -4,7 +4,8 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js'
+import readConfig from '../../utils/readConfig.js';
+import addPlurals from "../../utils/plurals.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -27,7 +28,7 @@
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
- + `${interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0} day${interaction.options.getInteger("delete") === 1 || interaction.options.getInteger("delete") === null ? "s" : ""} of messages will be deleted\n\n` // TODO:[s addition]
+ + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
+ `Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
@@ -57,10 +58,37 @@
}
} catch {}
try {
- (interaction.options.getMember("user") as GuildMember).ban({
+ let member = (interaction.options.getMember("user") as GuildMember)
+ let reason = interaction.options.getString("reason") ?? "No reason provided"
+ member.ban({
days: Number(interaction.options.getInteger("delete") ?? 0),
- reason: interaction.options.getString("reason") ?? "No reason provided"
+ reason: reason
})
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderDelta } = interaction.user.client.logger
+ let data = {
+ meta: {
+ type: 'memberBan',
+ displayName: 'Member Banned',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(member.user.id, `\`${member.user.id}\``),
+ name: entry(member.user.id, renderUser(member.user)),
+ banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ bannedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: interaction.guild.memberCount,
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, member.user.client);
} catch {
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.BAN.RED")
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 34a1571..b6ab653 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -1,4 +1,5 @@
import { CommandInteraction, GuildMember, MessageActionRow, MessageButton } from "discord.js";
+import humanizeDuration from 'humanize-duration';
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -56,6 +57,35 @@
} catch {}
try {
(interaction.options.getMember("user") as GuildMember).kick(interaction.options.getString("reason") ?? "No reason provided.")
+ let member = (interaction.options.getMember("user") as GuildMember)
+ let reason = interaction.options.getString("reason") ?? null
+ // @ts-ignore
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
+ let data = {
+ meta: {
+ type: 'memberKick',
+ displayName: 'Member Kicked',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.red,
+ emoji: "PUNISH.KICK.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ kickedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ reason: entry(reason, reason ? `\n> ${reason}` : "*No reason provided.*"),
+ timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedTimestamp, { round: true })),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount,
+ },
+ hidden: {
+ guild: member.guild.id
+ }
+ }
+ log(data, member.client);
} catch {
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.KICK.RED")
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 165d906..3d6d912 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -21,7 +21,6 @@
.addStringOption(option => option.setName("reason").setDescription("The reason for the mute").setRequired(false))
.addStringOption(option => option.setName("notify").setDescription("If the user should get a message when they are muted | Default yes").setRequired(false)
.addChoices([["Yes", "yes"], ["No", "no"]]))
- // TODO: notify the user when the mute is lifted
const callback = async (interaction: CommandInteraction) => {
// @ts-ignore
@@ -34,6 +33,10 @@
minutes: interaction.options.getInteger("minutes") || 0,
seconds: interaction.options.getInteger("seconds") || 0
}
+ let config = await readConfig(interaction.guild.id)
+ let serverSettingsDescription = (config.moderation.mute.timeout ? "given a timeout" : "")
+ if (config.moderation.mute.role) serverSettingsDescription += (serverSettingsDescription ? " and " : "") + `given the <@&${config.moderation.mute.role}> role`
+
let muteTime = (time.days * 24 * 60 * 60) + (time.hours * 60 * 60) + (time.minutes * 60) + time.seconds
if (muteTime == 0) {
let m = await interaction.reply({embeds: [
@@ -126,6 +129,7 @@
"time": `${humanizeDuration(muteTime * 1000, {round: true})}`,
"reason": `\n> ${reason ? reason : "*No reason provided*"}`
})
+ + `The user will be ` + serverSettingsDescription + "\n"
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ `Are you sure you want to mute <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
@@ -157,7 +161,12 @@
}
} catch {}
try {
- (interaction.options.getMember("user") as GuildMember).timeout(muteTime * 1000, interaction.options.getString("reason") || "No reason provided")
+ if (config.moderation.mute.timeout) {
+ (interaction.options.getMember("user") as GuildMember).timeout(muteTime * 1000, interaction.options.getString("reason") || "No reason provided")
+ }
+ if (config.moderation.mute.role) {
+ (interaction.options.getMember("user") as GuildMember).roles.add(config.moderation.mute.role)
+ }
} catch {
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.MUTE.RED")
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 9584055..72b2524 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -45,8 +45,8 @@
embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
- .setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}` +
- (interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : ".") + "\n\n" +
+ .setDescription(`Your nickname was ${interaction.options.getString("name") ? "changed" : "cleared"} in ${interaction.guild.name}.` +
+ (interaction.options.getString("name") ? ` it is now: ${interaction.options.getString("name")}` : "") + "\n\n" +
(confirmation.buttonClicked ? `You can appeal this in this ticket: <#${confirmation.response}>` : ``))
.setStatus("Danger")
]
@@ -55,7 +55,33 @@
}
} catch {}
try {
- (interaction.options.getMember("user") as GuildMember).setNickname(interaction.options.getString("name") ?? null, "Nucleus Nickname command")
+ let member = (interaction.options.getMember("user") as GuildMember)
+ let before = member.nickname
+ let nickname = interaction.options.getString("name")
+ member.setNickname(nickname ?? null, "Nucleus Nickname command")
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = interaction.client.logger
+ let data = {
+ meta: {
+ type: 'memberUpdate',
+ displayName: 'Member Updated',
+ calculateType: 'guildMemberUpdate',
+ color: NucleusColors.yellow,
+ emoji: "PUNISH.NICKNAME.YELLOW",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(member.id, `\`${member.id}\``),
+ before: entry(before, before ? before : '*None*'),
+ after: entry(nickname, nickname ? nickname : '*None*'),
+ updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ updatedBy: entry(interaction.user.id, renderUser(interaction.user))
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.client);
} catch {
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
@@ -99,6 +125,8 @@
if ((interaction.member as GuildMember).id == interaction.guild.ownerId) return true
// Check if the user has manage_nicknames permission
if (! (interaction.member as GuildMember).permissions.has("MANAGE_NICKNAMES")) throw "You do not have the `manage_nicknames` permission";
+ // Allow changing your own nickname
+ if (member == apply) return true
// Check if the user is below on the role list
if (! (memberPos > applyPos)) throw "You do not have a role higher than that member"
// Allow change
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index 29c228f..a1c8fe3 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -107,13 +107,15 @@
let amount;
try { amount = parseInt(component.customId); } catch { break; }
let messages;
- (interaction.channel as TextChannel).messages.fetch({limit: amount}).then(async (ms) => {
+ await (interaction.channel as TextChannel).messages.fetch({limit: amount}).then(async (ms) => {
if (user) {
ms = ms.filter(m => m.author.id === user.id)
}
messages = await (channel as TextChannel).bulkDelete(ms, true);
})
- deleted = deleted.concat(messages.map(m => m))
+ if (messages) {
+ deleted = deleted.concat(messages.map(m => m))
+ }
}
if (deleted.length === 0) return await interaction.editReply({
embeds: [
@@ -127,6 +129,28 @@
})
let attachmentObject;
try {
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderChannel } = interaction.user.client.logger
+ let data = {
+ meta: {
+ type: 'channelPurge',
+ displayName: 'Channel Purged',
+ calculateType: 'messageDelete',
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ messagesCleared: entry(deleted.length, deleted.length),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.user.client);
let out = ""
deleted.reverse().forEach(message => {
out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
@@ -177,7 +201,7 @@
.setEmoji("CHANNEL.PURGE.RED")
.setTitle("Purge")
.setDescription(keyValueList({
- "channel": `<#${channel.id}> (${(channel as GuildChannel).name})` + ("[This channel]"),
+ "channel": `<#${channel.id}>`,
"amount": interaction.options.getInteger("amount").toString(),
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
}))
@@ -206,6 +230,28 @@
}
let attachmentObject;
try {
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderChannel } = interaction.user.client.logger
+ let data = {
+ meta: {
+ type: 'channelPurge',
+ displayName: 'Channel Purged',
+ calculateType: 'messageDelete',
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(interaction.user.id, `\`${interaction.user.id}\``),
+ purgedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ channel: entry(interaction.channel.id, renderChannel(interaction.channel)),
+ messagesCleared: entry(messages.size, messages.size),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.user.client);
let out = ""
messages.reverse().forEach(message => {
out += `${message.author.username}#${message.author.discriminator} (${message.author.id}) [${new Date(message.createdTimestamp).toISOString()}]\n`
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 44d425a..2b9643d 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -4,7 +4,8 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
-import readConfig from '../../utils/readConfig.js'
+import readConfig from '../../utils/readConfig.js';
+import addPlurals from '../../utils/plurals.js';
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -27,7 +28,7 @@
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n`
- + `${interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0} day${interaction.options.getInteger("delete") === 1 || interaction.options.getInteger("delete") === null ? "s" : ""} of messages will be deleted\n\n` // TODO:[s addition]
+ + `${addPlurals(interaction.options.getInteger("delete") ? interaction.options.getInteger("delete") : 0, "day")} of messages will be deleted\n\n`
+ `Are you sure you want to softban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
diff --git a/src/commands/mod/unban.ts b/src/commands/mod/unban.ts
index 3ffc001..f96a7bd 100644
--- a/src/commands/mod/unban.ts
+++ b/src/commands/mod/unban.ts
@@ -1,18 +1,102 @@
-import { CommandInteraction } from "discord.js";
+import { CommandInteraction, GuildMember, User } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import keyValueList from "../../utils/generateKeyValueList.js";
+import confirmationMessage from "../../utils/confirmationMessage.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("unban")
.setDescription("Unbans a user")
+ .addStringOption(option => option.setName("user").setDescription("The user to unban (Username or ID)").setRequired(true))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("This command is not yet finished [mod/unban]");
+const callback = async (interaction: CommandInteraction) => { // TODO: User search
+ let bans = await interaction.guild.bans.fetch()
+ let user = interaction.options.getString("user")
+ let resolved = bans.find(ban => ban.user.id == user)
+ if (!resolved) resolved = bans.find(ban => ban.user.username.toLowerCase() == user.toLowerCase())
+ if (!resolved) resolved = bans.find(ban => ban.user.tag.toLowerCase() == user.toLowerCase())
+ if (!resolved) {
+ return interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("Unban")
+ .setDescription(`Could not find any user called \`${user}\``)
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setStatus("Danger")
+ ], ephemeral: true})
+ }
+ // TODO:[Modals] Replace this with a modal
+ let confirmation = await new confirmationMessage(interaction)
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setTitle("Unban")
+ .setDescription(keyValueList({
+ "user": `${resolved.user.username} [<@${resolved.user.id}>]`,
+ })
+ + `Are you sure you want to unban <@${resolved.user.id}>?`)
+ .setColor("Danger")
+ .send()
+ if (confirmation.success) {
+ try {
+ await interaction.guild.members.unban(resolved.user as User, "Unban");
+ let member = (resolved.user as User)
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderDelta } = interaction.user.client.logger
+ let data = {
+ meta: {
+ type: 'memberUnban',
+ displayName: 'Member Unbanned',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.green,
+ emoji: "PUNISH.BAN.GREEN",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member)),
+ unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unbannedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ accountCreated: entry(member.createdAt, renderDelta(member.createdAt)),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, member.client);
+ } catch {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.RED")
+ .setTitle(`Unban`)
+ .setDescription("Something went wrong and the user was not unbanned")
+ .setStatus("Danger")
+ ], components: []})
+ }
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji(`PUNISH.UNBAN.GREEN`)
+ .setTitle(`Unban`)
+ .setDescription("The member was unbanned")
+ .setStatus("Success")
+ ], components: []})
+ } else {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setEmoji("PUNISH.UNBAN.GREEN")
+ .setTitle(`Unban`)
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ ], components: []})
+ }
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
+ let member = (interaction.member as GuildMember)
+ let me = (interaction.guild.me as GuildMember)
+ // Check if Nucleus can unban members
+ if (! interaction.guild.me.permissions.has("BAN_MEMBERS")) throw "I do not have the `ban_members` permission";
+ // Allow the owner to unban anyone
+ if ((interaction.member as GuildMember).id == interaction.guild.ownerId) return true
+ // Check if the user has ban_members permission
+ if (! (interaction.member as GuildMember).permissions.has("BAN_MEMBERS")) throw "You do not have the `ban_members` permission";
+ // Allow unban
+ return true
}
export { command, callback, check };
\ No newline at end of file
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 36338dc..0512020 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -11,9 +11,9 @@
.addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
const callback = async (interaction: CommandInteraction) => {
- // @ts-ignore
+ // @ts-ignore
const { renderUser } = interaction.client.logger
- let suggestion = interaction.options.getString("suggestion");
+ let suggestion = interaction.options.getString("suggestion");
let confirmation = await new confirmationMessage(interaction)
.setEmoji("ICONS.OPP.ADD")
.setTitle("Suggest")
@@ -23,14 +23,14 @@
.send()
if (confirmation.success) {
await (interaction.client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
- embeds: [
- new generateEmojiEmbed()
- .setTitle(`Suggestion`)
- .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
- .setStatus("Danger")
- .setEmoji("NUCLEUS.LOGO")
- ]
- })
+ embeds: [
+ new generateEmojiEmbed()
+ .setTitle(`Suggestion`)
+ .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOGO")
+ ]
+ })
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji("ICONS.ADD")
.setTitle(`Suggest`)
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index da6a37a..ebbef82 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -5,6 +5,7 @@
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
import readConfig from "../../utils/readConfig.js";
+import addPlural from "../../utils/plurals.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -45,7 +46,7 @@
default: index == track,
label: option.name,
value: index.toString(),
- description: option.track.length == 0 ? "No" : option.track.length + " role" + (option.track.length == 1 ? "" : "s"), // TODO[s addition]
+ description: option.track.length == 0 ? "No" : addPlural(option.track.length, "role"),
emoji: interaction.client.emojis.resolve(getEmojiByName("TRACKS.SINGLE." + (hasRoleInTrack ? "ACTIVE" : "INACTIVE"), "id"))
})
})).setCustomId("select").setMaxValues(1)
diff --git a/src/config/emojis.json b/src/config/emojis.json
index 4c60cab..eeb98b5 100644
--- a/src/config/emojis.json
+++ b/src/config/emojis.json
@@ -38,6 +38,7 @@
"UP": "963409197293273108",
"DOWN": "963409199549796352",
"DOWNLOAD": "947959513032585236",
+ "TICKET": "973253514488860683",
"PILL": {
"TICK": "753314339082993832",
"CROSS": "753314339389309100"
@@ -136,7 +137,11 @@
"GREEN": "947421674364629022",
"YELLOW": "729764053941223476"
},
- "UNBAN": "729263536840114216",
+ "UNBAN": {
+ "GREEN": "729263536840114216",
+ "YELLOW": "972511620343414794",
+ "RED": "972511610885255259"
+ },
"MUTE": {
"RED": "947555098974883910",
"GREEN": "947555107980066866",
diff --git a/src/config/main.json b/src/config/main.json
index 14a32a7..5a8d77f 100644
--- a/src/config/main.json
+++ b/src/config/main.json
@@ -7,5 +7,6 @@
"owners": [
"317731855317336067",
"438733159748599813"
- ]
+ ],
+ "verifySecret": "1tLLN9wLLnWdgtq8GuOZxoTASgCrKPDhIKA56wL9JXu4SkKNgV03tEkUbM5Xk9f8S1YPlCtKG1EhS6igdKqV2xu3lnW25vJdIvnp"
}
\ No newline at end of file
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index f7ec756..883efd9 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -3,69 +3,71 @@
export const event = 'channelCreate'
export async function callback(client, channel) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
- let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
- if (audit.executor.id == client.user.id) return;
- let emoji;
- let readableType;
- let displayName;
- switch (channel.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Text";
- displayName = "Text Channel"
- break;
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = channel.client.logger
+ let auditLog = await getAuditLog(channel.guild, 'CHANNEL_CREATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let emoji;
+ let readableType;
+ let displayName;
+ switch (channel.type) {
+ case 'GUILD_TEXT': {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Text";
+ displayName = "Text Channel"
+ break;
+ }
+ case 'GUILD_NEWS': {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Announcement";
+ displayName = "Announcement Channel"
+ break;
+ }
+ case 'GUILD_VOICE': {
+ emoji = "CHANNEL.VOICE.CREATE";
+ readableType = "Voice";
+ displayName = "Voice Channel"
+ break;
+ }
+ case 'GUILD_STAGE': {
+ emoji = "CHANNEL.VOICE.CREATE";
+ readableType = "Stage";
+ displayName = "Stage Channel"
+ }
+ case 'GUILD_CATEGORY': {
+ emoji = "CHANNEL.CATEGORY.CREATE";
+ readableType = "Category";
+ displayName = "Category"
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.CREATE";
+ readableType = "Channel";
+ displayName = "Channel"
+ }
}
- case 'GUILD_NEWS': {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Announcement";
- displayName = "Announcement Channel"
- break;
+ let data = {
+ meta: {
+ type: 'channelCreate',
+ displayName: displayName + ' Created',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.green,
+ emoji: emoji,
+ timestamp: channel.createdTimestamp
+ },
+ list: {
+ id: entry(channel.id, `\`${channel.id}\``),
+ name: entry(channel.name, renderChannel(channel)),
+ type: entry(channel.type, readableType),
+ category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
+ },
+ hidden: {
+ guild: channel.guild.id
+ }
}
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.CREATE";
- readableType = "Voice";
- displayName = "Voice Channel"
- break;
- }
- case 'GUILD_STAGE': {
- emoji = "CHANNEL.VOICE.CREATE";
- readableType = "Stage";
- displayName = "Stage Channel"
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.CREATE";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.CREATE";
- readableType = "Channel";
- displayName = "Channel"
- }
- }
- let data = {
- meta: {
- type: 'channelCreate',
- displayName: displayName + ' Created',
- calculateType: 'channelUpdate',
- color: NucleusColors.green,
- emoji: emoji,
- timestamp: channel.createdTimestamp
- },
- list: {
- id: entry(channel.id, `\`${channel.id}\``),
- name: entry(channel.name, renderChannel(channel)),
- type: entry(channel.type, readableType),
- category: entry(channel.parent ? channel.parent.id : null, channel.parent ? channel.parent.name : "Uncategorised"),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(channel.createdTimestamp, renderDelta(channel.createdTimestamp))
- },
- hidden: {
- guild: channel.guild.id
- }
- }
- log(data, channel.client);
+ log(data, channel.client);
+ } catch {}
}
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index ac29238..e8c888a 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -3,69 +3,71 @@
export const event = 'channelDelete'
export async function callback(client, channel) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
+ try{
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser } = channel.client.logger
- let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
- if (audit.executor.id == client.user.id) return;
+ let auditLog = await getAuditLog(channel.guild, 'CHANNEL_DELETE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == channel.id).first();
+ if (audit.executor.id == client.user.id) return;
- let emoji;
- let readableType;
- let displayName;
- switch (channel.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.DELETE";
- readableType = "Text";
- displayName = "Text Channel"
- break;
- }
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.DELETE";
- readableType = "Voice";
- displayName = "Voice Channel"
- break;
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.DELETE";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.DELETE";
- readableType = "Channel";
- displayName = "Channel"
- }
- }
- let list = {
- 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 emoji;
+ let readableType;
+ let displayName;
+ switch (channel.type) {
+ case 'GUILD_TEXT': {
+ emoji = "CHANNEL.TEXT.DELETE";
+ readableType = "Text";
+ displayName = "Text Channel"
+ break;
+ }
+ case 'GUILD_VOICE': {
+ emoji = "CHANNEL.VOICE.DELETE";
+ readableType = "Voice";
+ displayName = "Voice Channel"
+ break;
+ }
+ case 'GUILD_CATEGORY': {
+ emoji = "CHANNEL.CATEGORY.DELETE";
+ readableType = "Category";
+ displayName = "Category"
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.DELETE";
+ readableType = "Channel";
+ displayName = "Channel"
+ }
+ }
+ let list = {
+ 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:{
- type: 'channelDelete',
- displayName: displayName + ' Deleted',
- calculateType: 'channelUpdate',
- color: NucleusColors.red,
- emoji: emoji,
- timestamp: audit.createdTimestamp
- },
- list: list,
- hidden: {
- guild: channel.guild.id
- }
- }
- log(data, channel.client);
+ let data = {
+ meta:{
+ type: 'channelDelete',
+ displayName: displayName + ' Deleted',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.red,
+ emoji: emoji,
+ timestamp: audit.createdTimestamp
+ },
+ list: list,
+ hidden: {
+ guild: channel.guild.id
+ }
+ }
+ log(data, channel.client);
+ } catch {}
}
diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts
index f374edd..25b7375 100644
--- a/src/events/channelUpdate.ts
+++ b/src/events/channelUpdate.ts
@@ -1,133 +1,135 @@
import humanizeDuration from 'humanize-duration';
-import readConfig from '../utils/readConfig.js'
import getEmojiByName from '../utils/getEmojiByName.js';
export const event = 'channelUpdate';
export async function callback(client, oc, nc) {
- let config = await readConfig(nc.guild.id);
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
+ try {
+ let config = await client.memory.readGuildInfo(nc.guild.id);
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderChannel } = client.logger
- if (nc.parent && (nc.parent.id == config.tickets.category)) return
+ if (nc.parent && (nc.parent.id == config.tickets.category)) return
- let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
- if (audit.executor.id == client.user.id) return;
+ let auditLog = await getAuditLog(nc.guild, 'CHANNEL_UPDATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == nc.id).first();
+ if (audit.executor.id == client.user.id) return;
- let emoji:string;
- let readableType:string;
- let displayName:string ;
- let changes = {
- id: entry(nc.id, `\`${nc.id}\``),
- channel: entry(nc.id, renderChannel(nc)),
- edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
- }
- if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
- if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
+ let emoji:string;
+ let readableType:string;
+ let displayName:string ;
+ let changes = {
+ id: entry(nc.id, `\`${nc.id}\``),
+ channel: entry(nc.id, renderChannel(nc)),
+ edited: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ editedBy: entry(audit.executor.id, renderUser((await nc.guild.members.fetch(audit.executor.id)).user)),
+ }
+ if (oc.name != nc.name) changes["name"] = entry([oc.name, nc.name], `${oc.name} -> ${nc.name}`);
+ if (oc.position != nc.position) changes["position"] = entry([oc.position, nc.position], `${oc.position} -> ${nc.position}`);
- switch (nc.type) {
- case 'GUILD_TEXT': {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "Text";
- displayName = "Text Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- let nsfw = ["", ""]
- nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
- if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
- if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
- if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
- [oc.rateLimitPerUser, nc.rateLimitPerUser],
- `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
- );
- break;
- }
- case 'GUILD_NEWS': {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "News";
- displayName = "News Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
- break;
- }
- case 'GUILD_VOICE': {
- emoji = "CHANNEL.VOICE.EDIT";
- readableType = "Voice";
- displayName = "Voice Channel"
- if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
- [oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
- );
- break;
- }
- case 'GUILD_STAGE': {
- emoji = "CHANNEL.VOICE.EDIT";
- readableType = "Stage";
- displayName = "Stage Channel"
- let oldTopic = oc.topic, newTopic = nc.topic;
- if (oldTopic) {
- if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
- } else { oldTopic = "None"; }
- if (newTopic) {
- if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
- else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
- } else { newTopic = "None"; }
- if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
- if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
- if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
- [oc.rtcRegion, nc.rtcRegion],
- `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
- );
- break;
- }
- case 'GUILD_CATEGORY': {
- emoji = "CHANNEL.CATEGORY.EDIT";
- readableType = "Category";
- displayName = "Category"
- break;
- }
- default: {
- emoji = "CHANNEL.TEXT.EDIT";
- readableType = "Channel";
- displayName = "Channel"
- }
- }
- let t = oc.type.split("_")[1];
- if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
- if (!(Object.values(changes).length - 4)) return
- let data = {
- meta:{
- type: 'channelUpdate',
- displayName: displayName + ' Edited',
- calculateType: 'channelUpdate',
- color: NucleusColors.yellow,
- emoji: emoji,
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: nc.guild.id
- }
- }
- log(data, client);
+ switch (nc.type) {
+ case 'GUILD_TEXT': {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "Text";
+ displayName = "Text Channel"
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+ } else { newTopic = "None"; }
+ let nsfw = ["", ""]
+ nsfw[0] = oc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ nsfw[1] = nc.nsfw ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`;
+ if (oc.topic != nc.topic) changes["description"] = entry([oc.topic, nc.topic], `\nBefore: ${oldTopic}\nAfter: ${newTopic}`);
+ if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${nsfw[0]} -> ${nsfw[1]}`);
+ if (oc.rateLimitPerUser != nc.rateLimitPerUser) changes["rateLimitPerUser"] = entry(
+ [oc.rateLimitPerUser, nc.rateLimitPerUser],
+ `${humanizeDuration(oc.rateLimitPerUser * 1000)} -> ${humanizeDuration(nc.rateLimitPerUser * 1000)}`
+ );
+
+ break;
+ }
+ case 'GUILD_NEWS': {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "News";
+ displayName = "News Channel"
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+ } else { newTopic = "None"; }
+ if (oc.nsfw != nc.nsfw) changes["nsfw"] = entry([oc.nsfw, nc.nsfw], `${oc.nsfw ? "On" : "Off"} -> ${nc.nsfw ? "On" : "Off"}`);
+ break;
+ }
+ case 'GUILD_VOICE': {
+ emoji = "CHANNEL.VOICE.EDIT";
+ readableType = "Voice";
+ displayName = "Voice Channel"
+ if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+ [oc.rtcRegion, nc.rtcRegion],
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+ );
+ break;
+ }
+ case 'GUILD_STAGE': {
+ emoji = "CHANNEL.VOICE.EDIT";
+ readableType = "Stage";
+ displayName = "Stage Channel"
+ let oldTopic = oc.topic, newTopic = nc.topic;
+ if (oldTopic) {
+ if (oldTopic.length > 256) oldTopic = `\`\`\`\n${oldTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else oldTopic = `\`\`\`\n${oldTopic.replace('`', "'")}\n\`\`\``
+ } else { oldTopic = "None"; }
+ if (newTopic) {
+ if (newTopic.length > 256) newTopic = `\`\`\`\n${newTopic.replace('`', "'").substring(0, 253) + '...'}\n\`\`\``
+ else newTopic = `\`\`\`\n${newTopic.replace('`', "'")}\n\`\`\``
+ } else { newTopic = "None"; }
+ if (oc.bitrate != nc.bitrate) changes["bitrate"] = entry([oc.bitrate, nc.bitrate], `${oc.bitrate} -> ${nc.bitrate}`);
+ if (oc.userLimit != nc.userLimit) changes["maxUsers"] = entry([oc.userLimit, nc.userLimit], `${oc.userLimit ? oc.userLimit : "Unlimited"} -> ${nc.userLimit}`);
+ if (oc.rtcRegion != nc.rtcRegion) changes["region"] = entry(
+ [oc.rtcRegion, nc.rtcRegion],
+ `${oc.rtcRegion || "Automatic"} -> ${nc.rtcRegion || "Automatic"}`
+ );
+ break;
+ }
+ case 'GUILD_CATEGORY': {
+ emoji = "CHANNEL.CATEGORY.EDIT";
+ readableType = "Category";
+ displayName = "Category"
+ break;
+ }
+ default: {
+ emoji = "CHANNEL.TEXT.EDIT";
+ readableType = "Channel";
+ displayName = "Channel"
+ }
+ }
+ let t = oc.type.split("_")[1];
+ if (oc.type != nc.type) changes["type"] = entry([oc.type, nc.type], `${t[0] + t.splice(1).toLowerCase()} -> ${readableType}`);
+ if (!(Object.values(changes).length - 4)) return
+ let data = {
+ meta:{
+ type: 'channelUpdate',
+ displayName: displayName + ' Edited',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.yellow,
+ emoji: emoji,
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: nc.guild.id
+ }
+ }
+ log(data, client);
+ } catch {}
}
\ No newline at end of file
diff --git a/src/events/emojiCreate.ts b/src/events/emojiCreate.ts
index 3320267..c1ed3c5 100644
--- a/src/events/emojiCreate.ts
+++ b/src/events/emojiCreate.ts
@@ -1,28 +1,30 @@
export const event = 'emojiCreate'
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
- let data = {
- meta: {
- type: 'emojiCreate',
- displayName: 'Emoji Created',
- calculateType: 'emojiUpdate',
- color: NucleusColors.green,
- emoji: "GUILD.EMOJI.CREATE",
- timestamp: emoji.createdTimestamp
- },
- list: {
- id: entry(emoji.id, `\`${emoji.id}\``),
- emoji: entry(emoji.name, renderEmoji(emoji)),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
- },
- hidden: {
- guild: emoji.guild.id
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
+ let auditLog = await getAuditLog(emoji.guild, 'EMOJI_CREATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'emojiCreate',
+ displayName: 'Emoji Created',
+ calculateType: 'emojiUpdate',
+ color: NucleusColors.green,
+ emoji: "GUILD.EMOJI.CREATE",
+ timestamp: emoji.createdTimestamp
+ },
+ list: {
+ id: entry(emoji.id, `\`${emoji.id}\``),
+ emoji: entry(emoji.name, renderEmoji(emoji)),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp))
+ },
+ hidden: {
+ guild: emoji.guild.id
+ }
}
- }
- log(data, client);
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/emojiDelete.ts b/src/events/emojiDelete.ts
index d31b9c6..59bed1e 100644
--- a/src/events/emojiDelete.ts
+++ b/src/events/emojiDelete.ts
@@ -1,29 +1,31 @@
export const event = 'emojiDelete'
export async function callback(client, emoji) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
- let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
- if (audit.executor.id == client.user.id) return;
- let data = {
- meta: {
- type: 'emojiDelete',
- displayName: 'Emoji Deleted',
- calculateType: 'emojiUpdate',
- color: NucleusColors.red,
- emoji: "GUILD.EMOJI.DELETE",
- timestamp: audit.createdTimestamp,
- },
- list: {
- id: entry(emoji.id, `\`${emoji.id}\``),
- emoji: entry(emoji.name, renderEmoji(emoji)),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
- deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
- },
- hidden: {
- guild: emoji.guild.id
+ try{
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderEmoji } = emoji.client.logger
+ let auditLog = await getAuditLog(emoji.guild, 'EMOJI_DELETE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == emoji.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'emojiDelete',
+ displayName: 'Emoji Deleted',
+ calculateType: 'emojiUpdate',
+ color: NucleusColors.red,
+ emoji: "GUILD.EMOJI.DELETE",
+ timestamp: audit.createdTimestamp,
+ },
+ list: {
+ id: entry(emoji.id, `\`${emoji.id}\``),
+ emoji: entry(emoji.name, renderEmoji(emoji)),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(emoji.createdTimestamp, renderDelta(emoji.createdTimestamp)),
+ deleted: entry(audit.createdTimestamp, renderDelta(audit.createdTimestamp)),
+ },
+ hidden: {
+ guild: emoji.guild.id
+ }
}
- }
- log(data, client);
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/emojiUpdate.ts b/src/events/emojiUpdate.ts
index 2566fed..2171b18 100644
--- a/src/events/emojiUpdate.ts
+++ b/src/events/emojiUpdate.ts
@@ -3,33 +3,35 @@
export const event = 'emojiUpdate';
export async function callback(client, oe, ne) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderEmoji } = client.logger
- if (oe.name == ne.name) return
- let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
- let audit = auditLog.entries.first();
- if (audit.executor.id == client.user.id) return;
+ if (oe.name == ne.name) return
+ let auditLog = await getAuditLog(ne.guild, 'EMOJI_UPDATE');
+ let audit = auditLog.entries.first();
+ if (audit.executor.id == client.user.id) return;
- let changes = {
- id: entry(ne.id, `\`${ne.id}\``),
- emoji: entry(ne.id, renderEmoji(ne)),
- edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
- editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
- name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
- }
- let data = {
- meta:{
- type: 'emojiUpdate',
- displayName: 'Emoji Edited',
- calculateType: 'emojiUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.EMOJI.EDIT",
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: ne.guild.id
- }
- }
- log(data, client);
+ let changes = {
+ id: entry(ne.id, `\`${ne.id}\``),
+ emoji: entry(ne.id, renderEmoji(ne)),
+ edited: entry(ne.createdTimestamp, renderDelta(ne.createdTimestamp)),
+ editedBy: entry(audit.executor.id, renderUser((await ne.guild.members.fetch(audit.executor.id)).user)),
+ name: entry([oe.name, ne.name], `\`:${oe.name}:\` -> \`:${ne.name}:\``),
+ }
+ let data = {
+ meta:{
+ type: 'emojiUpdate',
+ displayName: 'Emoji Edited',
+ calculateType: 'emojiUpdate',
+ color: NucleusColors.yellow,
+ emoji: "GUILD.EMOJI.EDIT",
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: ne.guild.id
+ }
+ }
+ log(data, client);
+ } catch {}
}
\ No newline at end of file
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
new file mode 100644
index 0000000..4209788
--- /dev/null
+++ b/src/events/guildBanAdd.ts
@@ -0,0 +1,39 @@
+import { purgeByUser } from '../automations/tickets/delete.js';
+import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
+
+export const event = 'guildBanAdd';
+
+export async function callback(client, ban) {
+ try { await statsChannelRemove(client, ban.user); } catch {}
+ try { purgeByUser(ban.user.id, ban.guild); } catch {}
+ try {
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
+ let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_ADD')
+ let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
+ if (audit.executor.id == client.user.id) return
+ console.log(ban.reason)
+ let data = {
+ meta: {
+ type: 'memberBan',
+ displayName: 'Member Banned',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.red,
+ emoji: "PUNISH.BAN.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(ban.user.id, `\`${ban.user.id}\``),
+ name: entry(ban.user.id, renderUser(ban.user)),
+ banned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ bannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
+ serverMemberCount: ban.guild.memberCount,
+ },
+ hidden: {
+ guild: ban.guild.id
+ }
+ }
+ log(data, ban.user.client);
+ } catch {}
+}
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
new file mode 100644
index 0000000..11661f7
--- /dev/null
+++ b/src/events/guildBanRemove.ts
@@ -0,0 +1,37 @@
+import humanizeDuration from 'humanize-duration';
+import { purgeByUser } from '../automations/tickets/delete.js';
+import { callback as statsChannelRemove } from '../automations/statsChannelRemove.js';
+
+export const event = 'guildBanRemove';
+
+export async function callback(client, ban) {
+ try { await statsChannelRemove(client, ban.user); } catch {}
+ try { purgeByUser(ban.user.id, ban.guild); } catch {}
+ try {
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = ban.user.client.logger
+ let auditLog = await getAuditLog(ban.guild, 'MEMBER_BAN_REMOVE')
+ let audit = auditLog.entries.filter(entry => entry.target.id == ban.user.id).first();
+ if (audit.executor.id == client.user.id) return
+ let data = {
+ meta: {
+ type: 'memberUnban',
+ displayName: 'Member Unbanned',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.green,
+ emoji: "PUNISH.BAN.GREEN",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(ban.user.id, `\`${ban.user.id}\``),
+ name: entry(ban.user.id, renderUser(ban.user)),
+ unbanned: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ unbannedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ accountCreated: entry(ban.user.createdAt, renderDelta(ban.user.createdAt)),
+ },
+ hidden: {
+ guild: ban.guild.id
+ }
+ }
+ log(data, ban.user.client);
+ } catch (e) {console.log(e)}
+}
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index 4935b4d..0222c7c 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -6,5 +6,7 @@
export const event = 'guildCreate';
export async function callback(client, guild) {
- guide(guild)
+ try{
+ guide(guild)
+ } catch {}
}
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
new file mode 100644
index 0000000..a1601bb
--- /dev/null
+++ b/src/events/guildMemberUpdate.ts
@@ -0,0 +1,36 @@
+import { callback as statsChannelAdd } from '../automations/statsChannelAdd.js';
+import { callback as welcome } from '../automations/welcome.js';
+import log from '../utils/log.js';
+export const event = 'guildMemberUpdate'
+
+export async function callback(client, before, after) {
+ try {
+ const { log, NucleusColors, entry, renderUser, renderDelta, getAuditLog } = after.client.logger
+ if (before.nickname != after.nickname) {
+ let auditLog = await getAuditLog(after.guild, 'MEMBER_UPDATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'memberUpdate',
+ displayName: 'Nickname Changed',
+ calculateType: 'guildMemberUpdate',
+ color: NucleusColors.yellow,
+ emoji: "PUNISH.NICKNAME.YELLOW",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(after.id, `\`${after.id}\``),
+ before: entry(before.nickname, before.nickname ? before.nickname : '*None*'),
+ after: entry(after.nickname, after.nickname ? after.nickname : '*None*'),
+ updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ updatedBy: entry(audit.executor.id, renderUser(audit.executor))
+ },
+ hidden: {
+ guild: after.guild.id
+ }
+ }
+ log(data, after.client);
+ }
+ } catch (e) { console.log(e) }
+}
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
new file mode 100644
index 0000000..400cfe4
--- /dev/null
+++ b/src/events/guildUpdate.ts
@@ -0,0 +1,58 @@
+export const event = 'guildUpdate'
+
+export async function callback(client, before, after) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = after.client.logger
+ let auditLog = await getAuditLog(after, 'GUILD_UPDATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let list = {}
+
+ const verificationLevels = {
+ NONE: 'Unrestricted',
+ LOW: 'Verified email',
+ MEDIUM: 'Registered (5 minutes)',
+ HIGH: 'Member (10 minutes)',
+ VERY_HIGH: 'Verified phone'
+ }
+
+ const explicitContentFilterLevels = {
+ DISABLED: 'Disabled',
+ MEMBERS_WITHOUT_ROLES: 'Members without roles',
+ ALL_MEMBERS: 'All members'
+ }
+
+ const MFALevels = {
+ NONE: 'None',
+ ELEVATED: 'Enabled'
+ }
+
+ if (before.name != after.name) list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ if (before.icon != after.icon) list["icon"] = entry([before.icon, after.icon], `[Before](${before.iconURL()}) -> [After](${after.iconURL()})`);
+ if (before.splash != after.splash) list["splash"] = entry([before.splash, after.splash], `[Before](${before.splashURL()}) -> [After](${after.splashURL()})`);
+ if (before.banner != after.banner) list["banner"] = entry([before.banner, after.banner], `[Before](${before.bannerURL()}) -> [After](${after.bannerURL()})`);
+ if (before.owner != after.owner) list["owner"] = entry([before.owner, after.owner], `${renderUser(before.owner.user)} -> ${renderUser(after.owner.user)}`);
+ if (before.verificationLevel != after.verificationLevel) list["verificationLevel"] = entry([verificationLevels[before.verificationLevel], verificationLevels[after.verificationLevel]], `${verificationLevels[before.verificationLevel]} -> ${verificationLevels[after.verificationLevel]}`);
+ if (before.explicitContentFilter != after.explicitContentFilter) list["explicitContentFilter"] = entry([explicitContentFilterLevels[before.explicitContentFilter], explicitContentFilterLevels[after.explicitContentFilter]], `${explicitContentFilterLevels[before.explicitContentFilter]} -> ${explicitContentFilterLevels[after.explicitContentFilter]}`);
+ if (before.mfaLevel != after.mfaLevel) list["2 factor authentication"] = entry([MFALevels[before.mfaLevel], MFALevels[after.mfaLevel]], `${MFALevels[before.mfaLevel]} -> ${MFALevels[after.mfaLevel]}`);
+
+ if (!(Object.keys(list).length)) return;
+ list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
+ let data = {
+ meta: {
+ type: 'guildUpdate',
+ displayName: 'Guild Edited',
+ calculateType: 'guildUpdate',
+ color: NucleusColors.yellow,
+ emoji: "GUILD.YELLOW",
+ timestamp: new Date().getTime()
+ },
+ list: list,
+ hidden: {
+ guild: after.id
+ }
+ }
+ log(data, after.client);
+ } catch (e) {}
+}
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
new file mode 100644
index 0000000..bdfeede
--- /dev/null
+++ b/src/events/inviteCreate.ts
@@ -0,0 +1,32 @@
+import humanizeDuration from 'humanize-duration';
+export const event = 'inviteCreate'
+
+export async function callback(client, invite) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
+ let auditLog = await getAuditLog(invite.guild, 'INVITE_CREATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'inviteCreate',
+ displayName: 'Invite Created',
+ calculateType: 'guildUpdate',
+ color: NucleusColors.green,
+ emoji: "INVITE.CREATE",
+ timestamp: invite.createdTimestamp
+ },
+ list: {
+ channel: entry(invite.channel.id, renderChannel(invite.channel)),
+ link: entry(invite.url, invite.url),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(invite.createdTimestamp, renderDelta(invite.createdTimestamp))
+ },
+ hidden: {
+ guild: invite.guild.id
+ }
+ }
+ log(data, invite.client);
+ } catch {}
+}
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
new file mode 100644
index 0000000..dec234f
--- /dev/null
+++ b/src/events/inviteDelete.ts
@@ -0,0 +1,32 @@
+import humanizeDuration from 'humanize-duration';
+export const event = 'inviteDelete'
+
+export async function callback(client, invite) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = invite.client.logger
+ let auditLog = await getAuditLog(invite.guild, 'INVITE_DELETE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == invite.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'inviteDelete',
+ displayName: 'Invite Deleted',
+ calculateType: 'guildUpdate',
+ color: NucleusColors.red,
+ emoji: "INVITE.DELETE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ channel: entry(invite.channel.id, renderChannel(invite.channel)),
+ link: entry(invite.url, invite.url),
+ expires: entry(invite.maxAge, invite.maxAge ? humanizeDuration(invite.maxAge * 1000) : 'Never'),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: invite.guild.id
+ }
+ }
+ log(data, invite.client);
+ } catch {}
+}
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index ea461ab..22b7cd3 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -4,31 +4,67 @@
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
+export async function callback(client, member) {
+ try { await statsChannelRemove(client, member); } catch {}
+ try { purgeByUser(member.id, member.guild); } catch {}
try {
- const { log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
- let data = {
- meta: {
- type: 'memberLeave',
- displayName: 'Member Left',
- calculateType: 'guildMemberUpdate',
- color: NucleusColors.red,
- emoji: "MEMBER" + (member.user.bot ? ".BOT" : "") + ".LEAVE",
- timestamp: new Date().getTime()
- },
- list: {
- id: entry(member.id, `\`${member.id}\``),
- name: entry(member.id, renderUser(member.user)),
- joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
- left: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
- accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
- serverMemberCount: member.guild.memberCount,
- },
- hidden: {
- guild: member.guild.id
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = member.client.logger
+ let auditLog = await getAuditLog(member.guild, 'MEMBER_KICK');
+ let audit = auditLog.entries.filter(entry => entry.target.id == member.id).first();
+ let type = "kick"
+ if (audit) {
+ if (audit.createdAt - 100 < new Date().getTime()) {
+ type = "leave"
+ } else if (audit.executor.id == client.user.id) return
+ }
+ let data
+ if (type == "kick") {
+ data = {
+ meta: {
+ type: 'memberKick',
+ displayName: 'Member Kicked',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.red,
+ emoji: "PUNISH.KICK.RED",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: entry(member.id, `\`${member.id}\``),
+ name: entry(member.id, renderUser(member.user)),
+ joined: entry(member.joinedAt, renderDelta(member.joinedAt)),
+ kicked: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ kickedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ reason: entry(audit.reason, audit.reason ? `\n> ${audit.reason}` : "*No reason provided.*"),
+ timeInServer: entry(new Date().getTime() - member.joinedAt, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount,
+ },
+ hidden: {
+ guild: member.guild.id
+ }
+ }
+ } else {
+ data = {
+ meta: {
+ type: 'memberLeave',
+ displayName: 'Member Left',
+ calculateType: 'guildMemberUpdate',
+ color: NucleusColors.red,
+ emoji: "MEMBER." + (member.bot ? "BOT." : "") + "LEAVE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: 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())),
+ timeInServer: entry(new Date().getTime() - member.joinedTimestamp, humanizeDuration(new Date().getTime() - member.joinedAt, { round: true })),
+ accountCreated: entry(member.user.createdAt, renderDelta(member.user.createdAt)),
+ serverMemberCount: member.guild.memberCount,
+ },
+ hidden: {
+ guild: member.guild.id
+ }
}
}
log(data, member.client);
diff --git a/src/events/messageChecks.ts b/src/events/messageChecks.ts
index 83cfff1..4e99c61 100644
--- a/src/events/messageChecks.ts
+++ b/src/events/messageChecks.ts
@@ -1,101 +1,100 @@
import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from '../automations/unscan.js'
-import readConfig from '../utils/readConfig.js'
import { Message } from 'discord.js'
export const event = 'messageCreate'
-export async function callback(_, message) {
- if (message.author.bot) return
- if (message.channel.type === 'dm') return
+export async function callback(client, message) {
+ if (message.author.bot) return
+ if (message.channel.type === 'dm') return
- let content = message.content.toLowerCase() || ''
- let config = await readConfig(message.guild.id);
+ let content = message.content.toLowerCase() || ''
+ let config = await client.memory.readGuildInfo(message.guild.id);
- if (config.filters.invite.enabled) {
- if (!config.filters.invite.allowed.users.includes(message.author.id) ||
- !config.filters.invite.allowed.channels.includes(message.channel.id) ||
- !message.author.roles.cache.some(role => config.filters.invite.allowed.roles.includes(role.id))
- ) {
- if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
- message.delete();
- return toLog(message, 'invite', content.match(/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/))
- }
- }
- }
+ if (config.filters.invite.enabled) {
+ if (!config.filters.invite.allowed.users.includes(message.author.id) ||
+ !config.filters.invite.allowed.channels.includes(message.channel.id) ||
+ !message.author.roles.cache.some(role => config.filters.invite.allowed.roles.includes(role.id))
+ ) {
+ if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
+ message.delete();
+ return toLog(message, 'invite', content.match(/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/))
+ }
+ }
+ }
- let attachments = message.attachments.map(element => element)
- attachments = [...attachments, ...content.match(
- /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi
- ) ?? []].filter(element => (element.url ? element.url : element))
- if (attachments.length > 0) {
- attachments.forEach(async element => {
- if(!message) return;
- let url = element.url ? element.url : element
- if (url != undefined) {
- if(/\.+(webp|png|jpg|jpeg|bmp)/.test(url)) {
- if (config.filters.images.NSFW && !message.channel.nsfw) {
- if (await NSFWCheck(url)) {
- await message.delete()
- return toLog(message, 'NSFW', url)
- }
- }
- if (config.filters.images.size) {
- if(!url.match(/\.+(webp|png|jpg)$/gi)) return
- if(!await SizeCheck(element)) {
- await message.delete()
- return toLog(message, 'size', url)
- }
- }
- }
- if (config.filters.malware) {
- if (!MalwareCheck(url)) {
- await message.delete()
- return toLog(message, 'malware', url)
- }
- }
- }
- });
- }
- if(!message) return;
+ let attachments = message.attachments.map(element => element)
+ attachments = [...attachments, ...content.match(
+ /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi
+ ) ?? []].filter(element => (element.url ? element.url : element))
+ if (attachments.length > 0) {
+ attachments.forEach(async element => {
+ if(!message) return;
+ let url = element.url ? element.url : element
+ if (url != undefined) {
+ if(/\.+(webp|png|jpg|jpeg|bmp)/.test(url)) {
+ if (config.filters.images.NSFW && !message.channel.nsfw) {
+ if (await NSFWCheck(url)) {
+ await message.delete()
+ return toLog(message, 'NSFW', url)
+ }
+ }
+ if (config.filters.images.size) {
+ if(!url.match(/\.+(webp|png|jpg)$/gi)) return
+ if(!await SizeCheck(element)) {
+ await message.delete()
+ return toLog(message, 'size', url)
+ }
+ }
+ }
+ if (config.filters.malware) {
+ if (!MalwareCheck(url)) {
+ await message.delete()
+ return toLog(message, 'malware', url)
+ }
+ }
+ }
+ });
+ }
+ if(!message) return;
- if (await LinkCheck(message)) {
- await message.delete()
- return toLog(message, 'link')
- }
+ if (await LinkCheck(message)) {
+ await message.delete()
+ return toLog(message, 'link')
+ }
- if (config.filters.wordFilter.enabled) {
- let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
- if(check != "none") {
- await message.delete()
- return toLog(message, 'wordFilter', content)
- }
- }
+ if (config.filters.wordFilter.enabled) {
+ let check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict)
+ if(check != "none") {
+ await message.delete()
+ return toLog(message, 'wordFilter', content)
+ }
+ }
- if (!config.filters.pings.allowed.users.includes(message.author.id) ||
- !config.filters.pings.allowed.channels.includes(message.channel.id) ||
- !message.author.roles.cache.some(role => config.filters.pings.allowed.roles.includes(role.id))
- ) {
- if (config.filters.pings.everyone && message.mentions.everyone) {
- message.delete();
- return toLog(message, 'mention everyone')
- }
- if (config.filters.pings.roles) {
- for(let role of message.mentions.roles) {
- if(!message) return;
- if (!config.filters.pings.allowed.roles.includes(role.id)) {
- message.delete();
- return toLog(message, 'mention role')
- }
- }
- }
- if(!message) return;
- if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
- message.delete();
- return toLog(message, 'Mass Pings')
- }
- }
+ if (!config.filters.pings.allowed.users.includes(message.author.id) ||
+ !config.filters.pings.allowed.channels.includes(message.channel.id) ||
+ !message.author.roles.cache.some(role => config.filters.pings.allowed.roles.includes(role.id))
+ ) {
+ if (config.filters.pings.everyone && message.mentions.everyone) {
+ message.delete();
+ return toLog(message, 'mention everyone')
+ }
+ if (config.filters.pings.roles) {
+ for(let role of message.mentions.roles) {
+ if(!message) return;
+ if (!config.filters.pings.allowed.roles.includes(role.id)) {
+ message.delete();
+ return toLog(message, 'mention role')
+ }
+ }
+ }
+ if(!message) return;
+ if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+ message.delete();
+ return toLog(message, 'Mass Pings')
+ }
+ }
}
async function toLog(message: Message, reason: string, data?: any) {
- // log(message.guild.id, {type: reason, data: data})
+ // log(message.guild.id, {type: reason, data: data})
}
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index ccaacb8..f0f5e00 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,38 +1,45 @@
export const event = 'messageDelete'
export async function callback(client, message) {
- if (message.author.id == client.user.id) return;
- const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
- message.reference = message.reference || {}
- let content = message.cleanContent
- if (content.length > 256) content = content.substring(0, 253) + '...'
- let data = {
- meta: {
- type: 'messageDelete',
- displayName: 'Message Deleted',
- calculateType: 'messageDelete',
- color: NucleusColors.red,
- emoji: 'MESSAGE.DELETE',
- timestamp: new Date().getTime()
- },
- separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
- },
- list: {
- id: 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(message.createdTimestamp), renderDelta(new Date(message.createdTimestamp))),
- mentions: message.mentions.users.size,
- attachments: message.attachments.size,
- 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"
- )
- },
- hidden: {
- guild: message.channel.guild.id
+ try {
+ if (message.author.id == client.user.id) return;
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = message.channel.client.logger
+ let auditLog = await getAuditLog(message.guild, 'MEMBER_BAN_ADD')
+ let audit = auditLog.entries.filter(entry => entry.target.id == message.author.id).first();
+ if (audit) {
+ if (audit.createdAt - 100 < new Date().getTime()) return;
}
- }
- log(data, client);
+ message.reference = message.reference || {}
+ let content = message.cleanContent
+ if (content.length > 256) content = content.substring(0, 253) + '...'
+ let data = {
+ meta: {
+ type: 'messageDelete',
+ displayName: 'Message Deleted',
+ calculateType: 'messageDelete',
+ color: NucleusColors.red,
+ emoji: 'MESSAGE.DELETE',
+ timestamp: new Date().getTime()
+ },
+ separate: {
+ start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : '**Message:** *Message had no content*',
+ },
+ list: {
+ id: 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: message.attachments.size,
+ 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"
+ )
+ },
+ hidden: {
+ guild: message.channel.guild.id
+ }
+ }
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 318b0ef..ec713a2 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,44 +1,46 @@
export const event = 'messageUpdate'
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
- newMessage.reference = newMessage.reference || {}
- 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 = {
- meta: {
- type: 'messageUpdate',
- displayName: 'Message Edited',
- calculateType: 'messageUpdate',
- color: NucleusColors.yellow,
- emoji: 'MESSAGE.EDIT',
- timestamp: newMessage.editedTimestamp
- },
- separate: {
- start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
- (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
- end: `[[Jump to message]](${newMessage.url})`
- },
- list: {
- id: entry(newMessage.id, `\`${newMessage.id}\``),
- sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
- sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
- sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
- edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
- mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
- attachments: renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
- repliedTo: entry(
- newMessage.reference.messageId || null,
- newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
- )
- },
- hidden: {
- guild: newMessage.channel.guild.id
+ try {
+ if (newMessage.author.id == client.user.id) return;
+ const { log, NucleusColors, entry, renderUser, renderDelta, renderNumberDelta, renderChannel } = newMessage.channel.client.logger
+ newMessage.reference = newMessage.reference || {}
+ let newContent = newMessage.cleanContent.replaceAll("`", "‘")
+ let oldContent = oldMessage.cleanContent.replaceAll("`", "‘")
+ if (newContent == oldContent) return;
+ if (newContent.length > 256) newContent = newContent.substring(0, 253) + '...'
+ if (oldContent.length > 256) oldContent = oldContent.substring(0, 253) + '...'
+ let data = {
+ meta: {
+ type: 'messageUpdate',
+ displayName: 'Message Edited',
+ calculateType: 'messageUpdate',
+ color: NucleusColors.yellow,
+ emoji: 'MESSAGE.EDIT',
+ timestamp: newMessage.editedTimestamp
+ },
+ separate: {
+ start: (oldContent ? `**Before:**\n\`\`\`\n${oldContent}\n\`\`\`\n` : '**Before:** *Message had no content*\n') +
+ (newContent ? `**After:**\n\`\`\`\n${newContent}\n\`\`\`` : '**After:** *Message had no content*'),
+ end: `[[Jump to message]](${newMessage.url})`
+ },
+ list: {
+ id: entry(newMessage.id, `\`${newMessage.id}\``),
+ sentBy: entry(newMessage.author.id, renderUser(newMessage.author)),
+ sentIn: entry(newMessage.channel.id, renderChannel(newMessage.channel)),
+ sent: entry(new Date(newMessage.createdTimestamp), renderDelta(new Date(newMessage.createdTimestamp))),
+ edited: entry(new Date(newMessage.editedTimestamp), renderDelta(new Date(newMessage.editedTimestamp))),
+ mentions: renderNumberDelta(oldMessage.mentions.users.size, newMessage.mentions.users.size),
+ attachments: renderNumberDelta(oldMessage.attachments.size, newMessage.attachments.size),
+ repliedTo: entry(
+ newMessage.reference.messageId || null,
+ newMessage.reference.messageId ? `[[Jump to message]](https://discord.com/channels/${newMessage.guild.id}/${newMessage.channel.id}/${newMessage.reference.messageId})` : "None"
+ )
+ },
+ hidden: {
+ guild: newMessage.channel.guild.id
+ }
}
- }
- log(data, client);
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index 76af433..2664790 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,29 +1,31 @@
export const event = 'roleCreate'
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;
- let data = {
- meta: {
- type: 'roleCreate',
- displayName: 'Role Created',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.green,
- emoji: "GUILD.ROLES.CREATE",
- timestamp: role.createdTimestamp
- },
- list: {
- id: entry(role.id, `\`${role.id}\``),
- role: entry(role.name, renderRole(role)),
- createdBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
- },
- hidden: {
- guild: role.guild.id
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderRole } = role.client.logger
+ if (role.managed) return;
+ let auditLog = await getAuditLog(role.guild, 'ROLE_CREATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'roleCreate',
+ displayName: 'Role Created',
+ calculateType: 'guildRoleUpdate',
+ color: NucleusColors.green,
+ emoji: "GUILD.ROLES.CREATE",
+ timestamp: role.createdTimestamp
+ },
+ list: {
+ id: entry(role.id, `\`${role.id}\``),
+ role: entry(role.name, renderRole(role)),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp))
+ },
+ hidden: {
+ guild: role.guild.id
+ }
}
- }
- log(data, client);
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index c5cbe63..6edfeed 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -3,34 +3,36 @@
export const event = 'roleDelete'
export async function callback(client, role) {
- const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
- if (role.managed) return;
- let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
- let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
- if (audit.executor.id == client.user.id) return;
- let data = {
- meta: {
- type: 'roleDelete',
- displayName: 'Role Deleted',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.red,
- emoji: "GUILD.ROLES.DELETE",
- timestamp: audit.createdTimestamp,
- },
- list: {
- id: entry(role.id, `\`${role.id}\``),
- role: entry(role.name, role.name),
- color: entry(role.hexColor, `\`${role.hexColor}\``),
- showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
- mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
- members: entry(role.members.size, `${role.members.size}`),
- deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
- created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
- deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
- },
- hidden: {
- guild: role.guild.id
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta } = role.client.logger
+ if (role.managed) return;
+ let auditLog = await getAuditLog(role.guild, 'ROLE_DELETE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == role.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'roleDelete',
+ displayName: 'Role Deleted',
+ calculateType: 'guildRoleUpdate',
+ color: NucleusColors.red,
+ emoji: "GUILD.ROLES.DELETE",
+ timestamp: audit.createdTimestamp,
+ },
+ list: {
+ id: entry(role.id, `\`${role.id}\``),
+ role: entry(role.name, role.name),
+ color: entry(role.hexColor, `\`${role.hexColor}\``),
+ showInMemberList: entry(role.hoist, role.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+ mentionable: entry(role.mentionable, role.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`),
+ members: entry(role.members.size, `${role.members.size}`),
+ deletedBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(role.createdTimestamp, renderDelta(role.createdTimestamp)),
+ deleted: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: role.guild.id
+ }
}
- }
- log(data, client);
+ log(data, client);
+ } catch {}
}
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 28afe0e..faf3237 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -3,43 +3,45 @@
export const event = 'roleUpdate';
export async function callback(client, or, nr) {
- const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderDelta, renderUser, renderRole } = client.logger
- let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
- let audit = auditLog.entries.first();
- if (audit.executor.id == client.user.id) return;
+ let auditLog = await getAuditLog(nr.guild, 'ROLE_UPDATE');
+ let audit = auditLog.entries.first();
+ if (audit.executor.id == client.user.id) return;
- let changes = {
- id: entry(nr.id, `\`${nr.id}\``),
- role: entry(nr.id, renderRole(nr)),
- edited: entry(nr.createdTimestamp, renderDelta(nr.createdTimestamp)),
- editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user)),
- }
- let mentionable = ["", ""]
- let hoist = ["", ""]
- mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
- if (or.name != nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
- if (or.position != nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
- if (or.hoist != nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
- if (or.mentionable != nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
- if (or.hexColor != nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
+ let changes = {
+ id: entry(nr.id, `\`${nr.id}\``),
+ role: entry(nr.id, renderRole(nr)),
+ edited: entry(nr.createdTimestamp, renderDelta(nr.createdTimestamp)),
+ editedBy: entry(audit.executor.id, renderUser((await nr.guild.members.fetch(audit.executor.id)).user)),
+ }
+ let mentionable = ["", ""]
+ let hoist = ["", ""]
+ mentionable[0] = or.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
+ mentionable[1] = nr.mentionable ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
+ hoist[0] = or.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
+ hoist[1] = nr.hoist ? `${getEmojiByName("CONTROL.TICK")} Yes` : `${getEmojiByName("CONTROL.CROSS")} No`
+ if (or.name != nr.name) changes["name"] = entry([or.name, nr.name], `${or.name} -> ${nr.name}`);
+ if (or.position != nr.position) changes["position"] = entry([or.position, nr.position], `${or.position} -> ${nr.position}`);
+ if (or.hoist != nr.hoist) changes["showInMemberList"] = entry([or.hoist, nr.hoist], `${hoist[0]} -> ${hoist[1]}`);
+ if (or.mentionable != nr.mentionable) changes["mentionable"] = entry([or.mentionable, nr.mentionable], `${mentionable[0]} -> ${mentionable[1]}`);
+ if (or.hexColor != nr.hexColor) changes["color"] = entry([or.hexColor, nr.hexColor], `\`${or.hexColor}\` -> \`${nr.hexColor}\``);
- let data = {
- meta:{
- type: 'roleUpdate',
- displayName: 'Role Edited',
- calculateType: 'guildRoleUpdate',
- color: NucleusColors.yellow,
- emoji: "GUILD.ROLES.EDIT",
- timestamp: audit.createdTimestamp
- },
- list: changes,
- hidden: {
- guild: nr.guild.id
- }
- }
- log(data, client);
+ let data = {
+ meta:{
+ type: 'roleUpdate',
+ displayName: 'Role Edited',
+ calculateType: 'guildRoleUpdate',
+ color: NucleusColors.yellow,
+ emoji: "GUILD.ROLES.EDIT",
+ timestamp: audit.createdTimestamp
+ },
+ list: changes,
+ hidden: {
+ guild: nr.guild.id
+ }
+ }
+ log(data, client);
+ } catch {}
}
\ No newline at end of file
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
new file mode 100644
index 0000000..77e9dea
--- /dev/null
+++ b/src/events/threadCreate.ts
@@ -0,0 +1,34 @@
+import humanizeDuration from 'humanize-duration';
+export const event = 'threadCreate'
+
+export async function callback(client, thread) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
+ let auditLog = await getAuditLog(thread.guild, 'THREAD_CREATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'channelCreate',
+ displayName: 'Thread Created',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.green,
+ emoji: "CHANNEL.TEXT.CREATE",
+ timestamp: thread.createdTimestamp
+ },
+ list: {
+ id: entry(thread.id, `\`${thread.id}\``),
+ name: entry(thread.name, renderChannel(thread)),
+ parentChannel: entry(thread.parentId, renderChannel(thread.parent)),
+ category: entry(thread.parent.parent ? thread.parent.parent.name : 'None', thread.parent.parent ? renderChannel(thread.parent.parent) : 'None'),
+ autoArchiveDuration: entry(thread.autoArchiveDuration, humanizeDuration(thread.autoArchiveDuration * 60 * 1000, { round: true })),
+ createdBy: entry(audit.executor.id, renderUser(audit.executor)),
+ created: entry(thread.createdTimestamp, renderDelta(thread.createdTimestamp))
+ },
+ hidden: {
+ guild: thread.guild.id
+ }
+ }
+ log(data, thread.client);
+ } catch {}
+}
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
new file mode 100644
index 0000000..7bf8537
--- /dev/null
+++ b/src/events/threadDelete.ts
@@ -0,0 +1,36 @@
+import humanizeDuration from 'humanize-duration';
+export const event = 'threadDelete'
+
+export async function callback(client, thread) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = thread.client.logger
+ let auditLog = await getAuditLog(thread.guild, 'THREAD_UPDATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == thread.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let data = {
+ meta: {
+ type: 'channelDelete',
+ displayName: 'Thread Deleted',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.red,
+ emoji: "CHANNEL.TEXT.DELETE",
+ timestamp: new Date().getTime()
+ },
+ list: {
+ id: 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 })),
+ 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()))
+ },
+ hidden: {
+ guild: thread.guild.id
+ }
+ }
+ log(data, thread.client);
+ } catch {}
+}
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
new file mode 100644
index 0000000..4067eba
--- /dev/null
+++ b/src/events/threadUpdate.ts
@@ -0,0 +1,43 @@
+import humanizeDuration from 'humanize-duration';
+export const event = 'threadUpdate'
+
+export async function callback(client, before, after) {
+ try {
+ const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = after.client.logger
+ let auditLog = await getAuditLog(after.guild, 'THREAD_UPDATE');
+ let audit = auditLog.entries.filter(entry => entry.target.id == after.id).first();
+ if (audit.executor.id == client.user.id) return;
+ let list = {
+ id: entry(after.id, `\`${after.id}\``),
+ thread: entry(after.name, renderChannel(after)),
+ parentChannel: entry(after.parentId, renderChannel(after.parent)),
+ }
+ if (before.name != after.name) {
+ list["name"] = entry([before.name, after.name], `${before.name} -> ${after.name}`);
+ }
+ if (before.autoArchiveDuration != after.autoArchiveDuration) {
+ list["autoArchiveDuration"] = entry([before.autoArchiveDuration, after.autoArchiveDuration], `${humanizeDuration(before.autoArchiveDuration * 60 * 1000, { round: true })} -> ${humanizeDuration(after.autoArchiveDuration * 60 * 1000, { round: true })}`);
+ }
+ if (before.rateLimitPerUser != after.rateLimitPerUser) {
+ list["slowmode"] = entry([before.rateLimitPerUser, after.rateLimitPerUser], `${humanizeDuration(before.rateLimitPerUser * 1000)} -> ${humanizeDuration(after.rateLimitPerUser * 1000)}`);
+ }
+ if (!(Object.keys(list).length - 3)) return;
+ list["updated"] = entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ list["updatedBy"] = entry(audit.executor.id, renderUser(audit.executor))
+ let data = {
+ meta: {
+ type: 'channelUpdate',
+ displayName: 'Thread Edited',
+ calculateType: 'channelUpdate',
+ color: NucleusColors.yellow,
+ emoji: "CHANNEL.TEXT.EDIT",
+ timestamp: new Date().getTime()
+ },
+ list: list,
+ hidden: {
+ guild: after.guild.id
+ }
+ }
+ log(data, after.client);
+ } catch {}
+}
diff --git a/src/events:TODO/channelPinsUpdate.ts b/src/events:TODO/channelPinsUpdate.ts
deleted file mode 100644
index 8a86b6d..0000000
--- a/src/events:TODO/channelPinsUpdate.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import log from '../utils/log.js'
-import * as JsonDiff from 'json-diff'
-
-export const name = ''
-export const once = false
-export async function execute(channel) {
- let pins = (await channel.messages.fetchPinned()).map(m => m.id);
- let oldPins = require(`../data/guilds/${channel.guild.id}/pins.json`);
-
- let data = JsonDiff.diff(oldPins, pins, {full: true});
-
- addLog(channel.guild.id, data)
-}
diff --git a/src/events:TODO/guildBanAdd.ts b/src/events:TODO/guildBanAdd.ts
deleted file mode 100644
index c165805..0000000
--- a/src/events:TODO/guildBanAdd.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import log from '../utils/log.js'
-
-export const name = 'guildBanAdd'
-export const once = false
-export async function execute(ban) {
- let logs = await ban.guild.fetchAuditLogs({'type': 'MEMBER_BAN_CREATE'});
- let log = logs.entries.find(log => log.target.id === ban.user.id)
-
- let data = {
- id: ban.user.id,
- username: ban.user.username,
- reason: ban.reason,
- bannedAt: log.createdTimestamp,
- bannedBy: log.executor.id
- }
-
- log(ban.guild.id, data);
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildBanRemove.ts b/src/events:TODO/guildBanRemove.ts
deleted file mode 100644
index 614f0f5..0000000
--- a/src/events:TODO/guildBanRemove.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-module.exports = {
- name:'guilidBanRemove',
- once:false,
- async execute(ban) {
- let logs = await ban.guild.fetchAuditLogs({'type': 'MEMBER_BAN_REMOVE'});
- let log = logs.entries.find(log => log.target.id === ban.user.id);
-
- let data = {
- id: ban.user.id,
- username: ban.user.username,
- reason: ban.reason,
- unbannedAt: log.createdTimestamp,
- unbannedBy: log.executor.id
- }
-
- addLog(ban.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildDelete.ts b/src/events:TODO/guildDelete.ts
deleted file mode 100644
index 107a6db..0000000
--- a/src/events:TODO/guildDelete.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- name:'guildDelete',
- once:false,
- async execute(guild) {
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildIntegrationsUpdate.ts b/src/events:TODO/guildIntegrationsUpdate.ts
deleted file mode 100644
index 863b67a..0000000
--- a/src/events:TODO/guildIntegrationsUpdate.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'guildIntegrationsUpdate',
- once:false,
- async execute(args) {
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildMemberAvailable.ts b/src/events:TODO/guildMemberAvailable.ts
deleted file mode 100644
index 92c2c80..0000000
--- a/src/events:TODO/guildMemberAvailable.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-module.exports = {
- name:'guildMemberAvailable',
- once:false,
- async execute(args) {
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildMemberUpdate.ts b/src/events:TODO/guildMemberUpdate.ts
deleted file mode 100644
index 238bf3c..0000000
--- a/src/events:TODO/guildMemberUpdate.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-
-module.exports = {
- name:'guildMemberUpdate',
- once:false,
- async execute(oldMember, newMember) {
-
- let oMem = {
- id: oldMember.id,
- username: oldMember.user.username,
- nick: oldMember.nickname,
- roles: oldMember.roles.cache.map(r => r.id),
- displayAvatarUrl: oldMember.displayAvatarUrl,
- communicationDisabledUntil: oldMember.communicationDisabledUntilTimestamp
- }
-
- let nMem = {
- id: newMember.id,
- username: newMember.user.username,
- nick: newMember.nickname,
- roles: newMember.roles.cache.map(r => r.id),
- displayAvatarUrl: newMember.displayAvatarUrl,
- communicationDisabledUntil: newMember.communicationDisabledUntilTimestamp
- }
-
- let data = JsonDiff.diff(oMem, nMem, {full: true});
-
- addLog(newMember.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildScheduledEventCreate.ts b/src/events:TODO/guildScheduledEventCreate.ts
deleted file mode 100644
index 489dd2f..0000000
--- a/src/events:TODO/guildScheduledEventCreate.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'guildScheduledEventCreate',
- once:false,
- async execute(event) {
- let data = {
- id: event.id,
- name: event.name,
- description: event.description,
- channel: event.channel.id,
- time: {
- start: event.scheduledStartTimestamp,
- end: event.scheduledEndTimestamp
- },
- date: event.date,
- createdBy: event.creator.id,
- createdAt: event.createdTimestamp,
- privacyLevel: event.privacyLevel
- }
-
- addLog(event.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildScheduledEventDelete.ts b/src/events:TODO/guildScheduledEventDelete.ts
deleted file mode 100644
index a3e85db..0000000
--- a/src/events:TODO/guildScheduledEventDelete.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'guildScheduledEventDelete',
- once:false,
- async execute(event) {
-
- let logs = await event.guild.fetchAuditLogs({'type': 'GUILD_SCHEDULED_EVENT_DELETE'});
- let log = logs.entries.find(log => log.target.id === event.id);
-
- let data = {
- id: event.id,
- name: event.name,
- deletedAt: log.createdTimestamp,
- deletedBy: log.executor.id
- }
-
- addLog(event.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildScheduledEventUpdate.ts b/src/events:TODO/guildScheduledEventUpdate.ts
deleted file mode 100644
index cc37a73..0000000
--- a/src/events:TODO/guildScheduledEventUpdate.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-
-module.exports = {
- name:'guildScheduledEventUpdate',
- once:false,
- async execute(oldEvent, newEvent) {
- let oe = {
- id: oldEvent.id,
- name: oldEvent.name,
- description: oldEvent.description,
- channel: oldEvent.channel ? oldEvent.channel.id : null,
- time: {
- start: oldEvent.scheduledStartTimestamp,
- end: oldEvent.scheduledEndTimestamp
- },
- date: oldEvent.date,
- privacyLevel: oldEvent.privacyLevel,
- entityType: oldEvent.entityType,
- entityMetadata: oldEvent.entityMetadata,
- status: oldEvent.status
- }
- let ne = {
- id: newEvent.id,
- name: newEvent.name,
- description: newEvent.description,
- channel: newEvent.channel ? newEvent.channel.id : null,
- time: {
- start: newEvent.scheduledStartTimestamp,
- end: newEvent.scheduledEndTimestamp
- },
- date: newEvent.date,
- privacyLevel: newEvent.privacyLevel,
- entityType: newEvent.entityType,
- entityMetadata: newEvent.entityMetadata,
- status: newEvent.status
- }
-
- let data = JsonDiff.diff(oe, ne, {full: true});
-
- addLog(newEvent.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildScheduledEventUserAdd.ts b/src/events:TODO/guildScheduledEventUserAdd.ts
deleted file mode 100644
index caadd25..0000000
--- a/src/events:TODO/guildScheduledEventUserAdd.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'guildScheduledEventUserAdd',
- once:false,
- async execute(event, member) {
- let data = {
- event: {
- id: event.id,
- name: event.name,
- },
- user: {
- id: member.id,
- username: member.username,
- joinedEventAt: Date.now()
- }
- }
- addLog(event.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildScheduledEventUserRemove.ts b/src/events:TODO/guildScheduledEventUserRemove.ts
deleted file mode 100644
index 9977709..0000000
--- a/src/events:TODO/guildScheduledEventUserRemove.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'guildScheduledEventUserRemove',
- once:false,
- async execute(event, member) {
- let data = {
- event: {
- id: event.id,
- name: event.name,
- },
- user: {
- id: member.id,
- username: member.username,
- leftEventAt: Date.now()
- }
- }
- addLog(event.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/guildUpdate.ts b/src/events:TODO/guildUpdate.ts
deleted file mode 100644
index 2e93f5b..0000000
--- a/src/events:TODO/guildUpdate.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-
-module.exports = {
- name:'guildUpdate',
- once:false,
- async execute(oldGuild, newGuild) {
-
- if(!newGuild.available) {
- return addLog(newGuild.id, {id:newGuild.id,unavailable:true});
- }
-
- let og = {
- afkChannel: oldGuild.afkChannel ? oldGuild.afkChannel.id : null,
- afkTimeout: oldGuild.afkTimeout,
- available: oldGuild.available,
- banner: oldGuild.banner,
- description: oldGuild.description,
- discoverySplash: oldGuild.discoverySplash,
- explicitContentFilter: oldGuild.explicitContentFilter,
- features: oldGuild.features,
- icon: oldGuild.icon,
- id: oldGuild.id,
- large: oldGuild.large,
- maximumBitrate: oldGuild.maximumBitrate,
- maximumMembers: oldGuild.maximumMembers,
- mfaLevel: oldGuild.mfaLevel,
- name: oldGuild.name,
- nsfwLevel: oldGuild.nsfwLevel,
- ownerid: oldGuild.ownerId,
- partnered: oldGuild.partnered,
- preferredLocale: oldGuild.preferredLocale,
- premiumProgressBarEnabled: oldGuild.premiumProgressBarEnabled,
- premiumSubscriptionCount: oldGuild.premiumSubscriptionCount,
- premiumTier: oldGuild.premiumTier,
- publicUpdatesChannel: oldGuild.publicUpdatesChannel ? oldGuild.publicUpdatesChannel.id : null,
- rulesChannel: oldGuild.rulesChannel ? oldGuild.rulesChannel.id : null,
- splash: oldGuild.splash,
- systemChannel: oldGuild.systemChannel ? oldGuild.systemChannel.id : null,
- vanityURLCode: oldGuild.vanityURLCode,
- verificationLevel: oldGuild.verificationLevel,
- verified: oldGuild.verified,
- widgetChannel: oldGuild.widgetChannel ? oldGuild.widgetChannel.id : null,
- widgetEnabled: oldGuild.widgetEnabled,
- }
- let ng = {
- afkChannel: newGuild.afkChannel ? newGuild.afkChannel.id : null,
- afkTimeout: newGuild.afkTimeout,
- available: newGuild.available,
- banner: newGuild.banner,
- description: newGuild.description,
- discoverySplash: newGuild.discoverySplash,
- explicitContentFilter: newGuild.explicitContentFilter,
- features: newGuild.features,
- icon: newGuild.icon,
- id: newGuild.id,
- large: newGuild.large,
- maximumBitrate: newGuild.maximumBitrate,
- maximumMembers: newGuild.maximumMembers,
- mfaLevel: newGuild.mfaLevel,
- name: newGuild.name,
- nsfwLevel: newGuild.nsfwLevel,
- ownerid: newGuild.ownerId,
- partnered: newGuild.partnered,
- preferredLocale: newGuild.preferredLocale,
- premiumProgressBarEnabled: newGuild.premiumProgressBarEnabled,
- premiumSubscriptionCount: newGuild.premiumSubscriptionCount,
- premiumTier: newGuild.premiumTier,
- publicUpdatesChannel: newGuild.publicUpdatesChannel ? newGuild.publicUpdatesChannel.id : null,
- rulesChannel: newGuild.rulesChannel ? newGuild.rulesChannel.id : null,
- splash: newGuild.splash,
- systemChannel: newGuild.systemChannel ? newGuild.systemChannel.id : null,
- vanityURLCode: newGuild.vanityURLCode,
- verificationLevel: newGuild.verificationLevel,
- verified: newGuild.verified,
- widgetChannel: newGuild.widgetChannel ? newGuild.widgetChannel.id : null,
- widgetEnabled: newGuild.widgetEnabled,
- }
-
- let data = JsonDiff.diff(og, ng, {full:true});
- addLog(newGuild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/inviteCreate.ts b/src/events:TODO/inviteCreate.ts
deleted file mode 100644
index 596bf58..0000000
--- a/src/events:TODO/inviteCreate.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'inviteCreate',
- once:false,
- async execute(invite) {
-
- const i = await invite.guild.invites.fetch(invite.code)
-
- let data = {
- channel: invite.channel.id,
- code: invite.code,
- createdAt: invite.createdTimestamp,
- expiresAt: invite.expiresTimestamp,
- createdBy: invite.inviter.id,
- maxUsage: i.maxUses,
- maxAge: i.maxAge
- }
-
- addLog(invite.guild.id, data)
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/inviteDelete.ts b/src/events:TODO/inviteDelete.ts
deleted file mode 100644
index 609ce6f..0000000
--- a/src/events:TODO/inviteDelete.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'inviteDelete',
- once:false,
- async execute(invite) {
-
- let logs = await invite.guild.fetchAuditLogs({type: 'INVITE_DELETE'});
- let entry = logs.entries.find(e => e.target.code === invite.code);
-
- let data = {
- channel: invite.channel.id,
- code: invite.code,
- deletedAt: invite.deletedTimestamp,
- deletedBy: entry.executor.id
- }
-
- addLog(invite.guild.id, data)
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageCreate.ts b/src/events:TODO/messageCreate.ts
deleted file mode 100644
index 46e8795..0000000
--- a/src/events:TODO/messageCreate.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageCreate',
- once:false,
- async execute(message) {
-
- const guildConfig = require(`../data/guilds/${message.guild.id}/config.json`);
- if(guildConfig.images.enabled) {
-
- }
- if(guildConfig.wordFilter.enabled) {
- for(word of guildConfig.wordFilter.words.strict) {
- if(message.content.toLowerCase().includes(word)) {
- message.delete();
- // message.channel.send(`${message.author} has been warned for using a banned word.`);
- break;
- }
- }
- for(word of message.content.split(' ')) {
- if(guildConfig.wordFilter.words.soft.includes(word)) {
- message.delete();
- // message.channel.send(`${message.author} has been warned for using a banned word.`);
- break;
- }
- }
-
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageDeleteBulk.ts b/src/events:TODO/messageDeleteBulk.ts
deleted file mode 100644
index 92d9134..0000000
--- a/src/events:TODO/messageDeleteBulk.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageDeleteBulk',
- once:false,
- async execute(messages) {
-
- let logs = await messages.first().guild.fetchAuditLogs({type: 'MESSAGE_DELETE_BULK'});
- let entry = logs.entries.first();
-
- let data = {
- messages:messages.map(message=>{
- return {
- id:message.id,
- channel:message.channel.id,
- content:message.content
- }
- }),
- deletedBy:entry.executor.id,
- deletedAt:entry.createdAt
- }
-
- addLog(messages.first().guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageReactionAdd.ts b/src/events:TODO/messageReactionAdd.ts
deleted file mode 100644
index c59a16f..0000000
--- a/src/events:TODO/messageReactionAdd.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageReactionAdd',
- once:false,
- async execute(messageReaction, user) {
- let data = {
- messageReaction: {
- messageID: messageReaction.message.id,
- reactionEmoji: {
- name: messageReaction.emoji.name,
- id: messageReaction.emoji.id
- },
- addedAt: Date.now()
- },
- user: {
- id: user.id,
- username: user.username
- }
- }
-
- addLog(messageReaction.message.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageReactionRemove.ts b/src/events:TODO/messageReactionRemove.ts
deleted file mode 100644
index 685ad37..0000000
--- a/src/events:TODO/messageReactionRemove.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageReactionRemove',
- once:false,
- async execute(messageReaction, user) {
- let data = {
- messageReaction: {
- messageID: messageReaction.message.id,
- reactionEmoji: {
- name: messageReaction.emoji.name,
- id: messageReaction.emoji.id
- },
- removedAt: Date.now()
- },
- user: {
- id: user.id,
- username: user.username
- }
- }
-
- addLog(messageReaction.message.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageReactionRemoveAll.ts b/src/events:TODO/messageReactionRemoveAll.ts
deleted file mode 100644
index e4254da..0000000
--- a/src/events:TODO/messageReactionRemoveAll.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageReactionRemoveAll',
- once:false,
- async execute(message, reactions) {
- let data = {
- messageID: message.id,
- reactions: reactions.map(r => {
- return {
- name: r.emoji.name,
- id: r.emoji.id
- }
- }),
- removedAt: Date.now()
- }
-
- addLog(message.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/messageReactionRemoveEmoji.ts b/src/events:TODO/messageReactionRemoveEmoji.ts
deleted file mode 100644
index 9a709f8..0000000
--- a/src/events:TODO/messageReactionRemoveEmoji.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'messageReactionRemoveEmoji',
- once:false,
- async execute(messageReaction) {
- let data = {
- name: messageReaction.emoji.name,
- id: messageReaction.emoji.id,
- removedAt: Date.now()
- }
-
- addLog(messageReaction.message.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stageInstanceCreate.ts b/src/events:TODO/stageInstanceCreate.ts
deleted file mode 100644
index 1f56418..0000000
--- a/src/events:TODO/stageInstanceCreate.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'stageInstanceCreate',
- once:false,
- async execute(stageInstance) {
- let data = {
- id: stageInstance.id,
- channel: stageInstance.channel.id,
- channelName: stageInstance.channel.name,
- createdAt: stageInstance.createdTimestamp,
- topic: stageInstance.topic,
- discoverable: !stageInstance.discoverableDisabled,
- privacy: stageInstance.privacyLevel
- }
-
- addLog(role.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stageInstanceDelete.ts b/src/events:TODO/stageInstanceDelete.ts
deleted file mode 100644
index e8e0e78..0000000
--- a/src/events:TODO/stageInstanceDelete.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-
-module.exports = {
- name:'stageInstanceDelete',
- once:false,
- async execute(stageInstance) {
-
- let logs = await stageInstance.guild.fetchAuditLogs({type: 'STAGE_INSTANCE_DELETE'});
- let entry = logs.entries.find(e => e.target.id === stageInstance.id);
-
- let data = {
- id: stageInstance.id,
- channel: stageInstance.channel.id,
- channelName: stageInstance.channel.name,
- deletedAt: entry.createdTimestamp,
- deletedBy: entry.deletedBy,
- topic: stageInstance.topic,
- discoverable: !stageInstance.discoverableDisabled,
- privacy: stageInstance.privacyLevel
- }
-
- addLog(role.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stageInstanceUpdate.ts b/src/events:TODO/stageInstanceUpdate.ts
deleted file mode 100644
index e516915..0000000
--- a/src/events:TODO/stageInstanceUpdate.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-
-module.exports = {
- name:'stageInstanceUpdate',
- once:false,
- async execute(oldStage, newStage) {
- let os = {
- id: oldStage.id,
- channel: oldStage.channel.id,
- channelName: oldStage.channel.name,
- topic: oldStage.topic,
- discoverable: !oldStage.discoverableDisabled,
- privacy: oldStage.privacyLevel
- }
-
- let ns = {
- id: newStage.id,
- channel: newStage.channel.id,
- channelName: newStage.channel.name,
- topic: newStage.topic,
- discoverable: !newStage.discoverableDisabled,
- privacy: newStage.privacyLevel
- }
-
- let data = JsonDiff.diff(os, ns, {full: true});
-
- addLog(role.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stickerCreate.ts b/src/events:TODO/stickerCreate.ts
deleted file mode 100644
index c968c2a..0000000
--- a/src/events:TODO/stickerCreate.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-module.exports = {
- name:'stickerCreate',
- once:false,
- async execute(sticker) {
- let data = {
- id: sticker.id,
- createdAt: sticker.createdTimestamp,
- description: sticker.description,
- name: sticker.name,
- type: sticker.type,
- tags: sticker.tags,
- createdBy: sticker.user.id
- }
-
- addLog(role.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stickerDelete.ts b/src/events:TODO/stickerDelete.ts
deleted file mode 100644
index 67654f3..0000000
--- a/src/events:TODO/stickerDelete.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-module.exports = {
- name:'stickerDelete',
- once:false,
- async execute(sticker) {
-
- let logs = await sticker.guild.fetchAuditLogs({type: 'STICKER_DELETE'});
- let entry = logs.entries.find(e => e.target.id === sticker.id);
-
- let data = {
- id: sticker.id,
- deletedAt: entry.createdTimestamp,
- description: sticker.description,
- name: sticker.name,
- type: sticker.type,
- tags: sticker.tags,
- deletedBy: entry.executor.id
- }
-
- addLog(role.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/stickerUpdate.ts b/src/events:TODO/stickerUpdate.ts
deleted file mode 100644
index 33e4cdf..0000000
--- a/src/events:TODO/stickerUpdate.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'stickerUpdate',
- once:false,
- async execute(oldSticker, newSticker) {
- let os = {
- id: sticker.id,
- description: sticker.description,
- name: sticker.name,
- type: sticker.type,
- tags: sticker.tags,
- }
-
- let ns = {
- id: sticker.id,
- description: sticker.description,
- name: sticker.name,
- type: sticker.type,
- tags: sticker.tags,
- }
-
- let data = JsonDiff.diff(os, ns, {full: true});
-
- addLog(role.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/threadCreate.ts b/src/events:TODO/threadCreate.ts
deleted file mode 100644
index 63c29a4..0000000
--- a/src/events:TODO/threadCreate.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-module.exports = {
- name:'threadCreate',
- once:false,
- async execute(thread) {
-
- let data = {
- autoArchiveDuration: thread.autoArchiveDuration,
- id: thread.id,
- locked: thread.locked,
- name: thread.name,
- parentChannel: thread.parent.id,
- slowmode: thread.rateLimitPerUser,
- type: thread.type,
- createdAt: thread.createdTimestamp,
- createdBy: thread.ownerId
- }
-
- addLog(thread.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/threadDelete.ts b/src/events:TODO/threadDelete.ts
deleted file mode 100644
index 43cba66..0000000
--- a/src/events:TODO/threadDelete.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-module.exports = {
- name:'threadDelete',
- once:false,
- async execute(thread) {
-
- let logs = await thread.guild.fetchAuditLogs({type: 'THREAD_DELETE'});
- let entry = logs.entries.find(e => e.target.id === thread.id);
-
- let data = {
- autoArchiveDuration: thread.autoArchiveDuration,
- id: thread.id,
- locked: thread.locked,
- name: thread.name,
- parentChannel: thread.parent.id,
- slowmode: thread.rateLimitPerUser,
- type: thread.type,
- deletedAt: entry.createdTimestamp,
- deletedBy: entry.executor.id
- }
-
- addLog(thread.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/threadMembersUpdate.ts b/src/events:TODO/threadMembersUpdate.ts
deleted file mode 100644
index fab4ef5..0000000
--- a/src/events:TODO/threadMembersUpdate.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'threadMembersUpdate',
- once:false,
- async execute(oldMembers, newMembers) {
-
- let om = oldMembers.map(m => m.id);
- let nm = newMembers.map(m => m.id);
- let data = JsonDiff.diff(om, nm);
-
- addLog(newMembers.first().guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/threadUpdate.ts b/src/events:TODO/threadUpdate.ts
deleted file mode 100644
index cfaed14..0000000
--- a/src/events:TODO/threadUpdate.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'threadUpdate',
- once:false,
- async execute(oldThread, newThread) {
- let ot = {
- autoArchiveDuration: oldThread.autoArchiveDuration,
- id: oldThread.id,
- locked: oldThread.locked,
- name: oldThread.name,
- parentChannel: oldThread.parent.id,
- slowmode: oldThread.rateLimitPerUser,
- type: oldThread.type,
- }
- let nt = {
- autoArchiveDuration: newThread.autoArchiveDuration,
- id: newThread.id,
- locked: newThread.locked,
- name: newThread.name,
- parentChannel: newThread.parent.id,
- slowmode: newThread.rateLimitPerUser,
- type: newThread.type,
- }
-
- let data = JsonDiff.diff(ot, nt, {full: true});
-
- addLog(newThread.guild.id, data);
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/userUpdate.ts b/src/events:TODO/userUpdate.ts
deleted file mode 100644
index a6735c8..0000000
--- a/src/events:TODO/userUpdate.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'userUpdate',
- once:false,
- async execute(args) {
-
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/voiceStateUpdate.ts b/src/events:TODO/voiceStateUpdate.ts
deleted file mode 100644
index 3754f0c..0000000
--- a/src/events:TODO/voiceStateUpdate.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'voiceStateUpdate',
- once:false,
- async execute(oldState, newState) {
- let os = {
- channel:oldState.channel ? oldState.channel.id : null,
- serverDeaf:oldState.serverDeaf,
- serverMute:oldState.serverMute,
- selfDeaf:oldState.selfDeaf,
- selfMute:oldState.selfMute,
- selfVideo:oldState.selfVideo,
- streaming:oldState.streaming,
- id:oldState.id,
- requestToSpeakTimestamp:oldState.requestToSpeakTimestamp
- }
-
- let ns = {
- channel:newState.channel ? newState.channel.id : null,
- serverDeaf:newState.serverDeaf,
- serverMute:newState.serverMute,
- selfDeaf:newState.selfDeaf,
- selfMute:newState.selfMute,
- selfVideo:newState.selfVideo,
- streaming:newState.streaming,
- id:newState.id,
- requestToSpeakTimestamp:newState.requestToSpeakTimestamp
- }
-
- let data = JsonDiff.diff(os, ns, {full: true});
-
- addLog(oldState.guild.id, data);
- }
-}
\ No newline at end of file
diff --git a/src/events:TODO/webhookUpdate.ts b/src/events:TODO/webhookUpdate.ts
deleted file mode 100644
index 56affc4..0000000
--- a/src/events:TODO/webhookUpdate.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-const {addLog} = require('../scripts/addLogs');
-const JsonDiff = require('json-diff');
-module.exports = {
- name:'webhookUpdate',
- once:false,
- async execute(args) {
-
- }
-}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 3b735cb..306c5ee 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -2,15 +2,22 @@
import { Intents } from 'discord.js';
import config from './config/main.json' assert {type: 'json'};
import { Logger } from './utils/log.js';
+import runServer from './api/index.js';
+import Memory from './utils/memory.js';
+
const client = new HaikuClient({
intents: new Intents(32767).bitfield, // This is a way of specifying all intents w/o having to type them out
}, config);
await client.registerCommandsIn("./commands");
await client.registerEventsIn("./events");
+client.on("ready", () => {
+ runServer(client);
+});
client.logger = new Logger()
client.verify = {}
client.roleMenu = {}
+client.memory = new Memory()
await client.login();
\ No newline at end of file
diff --git a/src/utils/calculate.ts b/src/utils/calculate.ts
index 174c401..26c231c 100644
--- a/src/utils/calculate.ts
+++ b/src/utils/calculate.ts
@@ -59,8 +59,8 @@
}
export {
- toHexInteger,
- toHexArray,
+ toHexInteger,
+ toHexArray,
tickets,
logs
}
\ No newline at end of file
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index fc8b76c..f5c322b 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -65,7 +65,7 @@
.setLabel(this.customButtonTitle)
.setStyle("SECONDARY")
.setDisabled(this.customButtonDisabled)
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) // TODO: add an emoji
+ .setEmoji(getEmojiByName("CONTROL.TICKET", "id"))
] : []))
],
ephemeral: true,
@@ -81,7 +81,7 @@
try {
component = await (m as Message).awaitMessageComponent({filter: (m) => m.user.id === this.interaction.user.id, time: 2.5 * 60 * 1000});
} catch (e) {
- return {success: false, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse}; // TODO: Check the type of the error; change the error message here
+ return {success: false, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse};
}
if (component.customId === "yes") {
component.deferUpdate();
diff --git a/src/utils/generateConfig.ts b/src/utils/generateConfig.ts
index 6dc4e52..39b28b0 100644
--- a/src/utils/generateConfig.ts
+++ b/src/utils/generateConfig.ts
@@ -48,43 +48,43 @@
messageType: "embed",
},
filters: {
- images: {
- NSFW: true,
- size: true
- },
- malware: true,
- wordFilter: {
- enabled: true,
- words: {
- strict: [],
- loose: []
- },
- allowed: {
- users: [],
- roles: [],
- channels: []
- }
- },
- invite: {
- enabled: true,
- allowed: {
- users: [],
- channels: [],
- roles: []
- }
- },
- pings: {
- mass: 5,
- everyone: true,
- roles: true,
- allowed: {
- roles: [],
- rolesToMention: [],
- users: [],
- channels: []
- }
- }
- },
+ images: {
+ NSFW: true,
+ size: true
+ },
+ malware: true,
+ wordFilter: {
+ enabled: true,
+ words: {
+ strict: [],
+ loose: []
+ },
+ allowed: {
+ users: [],
+ roles: [],
+ channels: []
+ }
+ },
+ invite: {
+ enabled: true,
+ allowed: {
+ users: [],
+ channels: [],
+ roles: []
+ }
+ },
+ pings: {
+ mass: 5,
+ everyone: true,
+ roles: true,
+ allowed: {
+ roles: [],
+ rolesToMention: [],
+ users: [],
+ channels: []
+ }
+ }
+ },
tags: {}
}));
}
diff --git a/src/utils/log.ts b/src/utils/log.ts
index 14e9750..238b6f4 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -10,80 +10,82 @@
export class Logger {
- renderUser(user: Discord.User | string) {
- if (typeof user == 'string') return `${user} [<@${user}>]`;
- return `${user.username} [<@${user.id}>]`;
- }
- renderTime(t: number) {
- t = Math.floor(t /= 1000)
- return `<t:${t}:D> at <t:${t}:T>`;
- }
- renderDelta(t: number) {
- t = Math.floor(t /= 1000)
- return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
- }
- renderNumberDelta(num1, num2) {
- let delta = num2 - num1;
- return `${num1} -> ${num2} (${delta > 0 ? '+' : ''}${delta})`;
- }
- entry(value, displayValue) {
- return { value: value, displayValue: displayValue }
- }
- renderChannel(channel: Discord.GuildChannel) {
- return `${channel.name} [<#${channel.id}>]`;
- }
- renderRole(role: Discord.Role) {
- return `${role.name} [<@&${role.id}>]`;
- }
- renderEmoji(emoji: Discord.GuildEmoji) {
- return `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
- }
+ renderUser(user: Discord.User | string) {
+ if (typeof user == 'string') return `${user} [<@${user}>]`;
+ return `${user.username} [<@${user.id}>]`;
+ }
+ renderTime(t: number) {
+ t = Math.floor(t /= 1000)
+ return `<t:${t}:D> at <t:${t}:T>`;
+ }
+ renderDelta(t: number) {
+ t = Math.floor(t /= 1000)
+ return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
+ }
+ renderNumberDelta(num1, num2) {
+ let delta = num2 - num1;
+ return `${num1} -> ${num2} (${delta > 0 ? '+' : ''}${delta})`;
+ }
+ entry(value, displayValue) {
+ return { value: value, displayValue: displayValue }
+ }
+ renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel | Discord.NewsChannel) {
+ return `${channel.name} [<#${channel.id}>]`;
+ }
+ renderRole(role: Discord.Role) {
+ return `${role.name} [<@&${role.id}>]`;
+ }
+ renderEmoji(emoji: Discord.GuildEmoji) {
+ return `<${emoji.animated ? 'a' : ''}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
+ }
- public readonly NucleusColors = {
- red: 0xF27878,
- yellow: 0xF2D478,
- green: 0x68D49E,
+ public readonly NucleusColors = {
+ red: 0xF27878,
+ yellow: 0xF2D478,
+ green: 0x68D49E,
- }
+ }
- async getAuditLog(guild: Discord.Guild, event) {
- await wait(250)
- let auditLog = await guild.fetchAuditLogs({type: event});
- return auditLog;
- }
+ async getAuditLog(guild: Discord.Guild, event) {
+ await wait(250)
+ let auditLog = await guild.fetchAuditLogs({type: event});
+ return auditLog;
+ }
- async log(log: any, client): Promise<void> {
- let config = await readConfig(log.hidden.guild);
- if (!config.logging.logs.enabled) return;
- if (!(log.meta.calculateType == true)) if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
- if (config.logging.logs.channel) {
- let channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
- let description = {};
- Object.entries(log.list).map(entry => {
- let key = entry[0];
- let value:any = entry[1];
- if(value.displayValue) {
- description[key] = value.displayValue;
- } else {
- description[key] = value;
- }
- })
- if (channel) {
- log.separate = log.separate || {};
- let embed = new Discord.MessageEmbed()
- .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
- .setDescription(
- (log.separate.start ? log.separate.start + "\n" : "") +
- generateKeyValueList(description) +
- (log.separate.end ? "\n" + log.separate.end : "")
- )
- .setTimestamp(log.meta.timestamp)
- .setColor(log.meta.color);
- channel.send({embeds: [embed]});
- }
- }
- saveLog(log);
- }
+ async log(log: any, client): Promise<void> {
+ let config = await readConfig(log.hidden.guild);
+ if (!config.logging.logs.enabled) return;
+ if (!(log.meta.calculateType == true)) {
+ if(!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType)) return console.log('Not logging this type of event');
+ }
+ if (config.logging.logs.channel) {
+ let channel = await client.channels.fetch(config.logging.logs.channel) as Discord.TextChannel;
+ let description = {};
+ Object.entries(log.list).map(entry => {
+ let key = entry[0];
+ let value:any = entry[1];
+ if(value.displayValue) {
+ description[key] = value.displayValue;
+ } else {
+ description[key] = value;
+ }
+ })
+ if (channel) {
+ log.separate = log.separate || {};
+ let embed = new Discord.MessageEmbed()
+ .setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
+ .setDescription(
+ (log.separate.start ? log.separate.start + "\n" : "") +
+ generateKeyValueList(description) +
+ (log.separate.end ? "\n" + log.separate.end : "")
+ )
+ .setTimestamp(log.meta.timestamp)
+ .setColor(log.meta.color);
+ channel.send({embeds: [embed]});
+ }
+ }
+ saveLog(log);
+ }
}
@@ -93,9 +95,9 @@
}
export function readLogs(guild: string) {
-
+
}
export function readSpecificLog(guild: string, id: number) {
-
+
}
diff --git a/src/utils/memory.ts b/src/utils/memory.ts
new file mode 100644
index 0000000..a4f9501
--- /dev/null
+++ b/src/utils/memory.ts
@@ -0,0 +1,22 @@
+import readConfig from "./readConfig.js";
+
+class Memory {
+ memory: {};
+ constructor() {
+ this.memory = {};
+ }
+
+ async readGuildInfo(guild: string): Promise<object> {
+ if (!this.memory[guild]) {
+ let guildData = await readConfig(guild);
+ this.memory[guild] = {
+ filters: guildData.filters,
+ logging: guildData.logging,
+ tickets: guildData.tickets,
+ }; // TODO: REMOVE GUILD FROM MEMORY WHEN THESE UPDATE
+ }
+ return this.memory[guild];
+ }
+}
+
+export default Memory;
\ No newline at end of file
diff --git a/src/utils/plurals.ts b/src/utils/plurals.ts
new file mode 100644
index 0000000..f956057
--- /dev/null
+++ b/src/utils/plurals.ts
@@ -0,0 +1,6 @@
+function addPlural(amount: any, unit: string) {
+ if (amount === '1') return `${amount} ${unit}`
+ return `${amount} ${unit}s`
+}
+
+export default addPlural;
\ No newline at end of file
diff --git a/src/utils/readConfig.ts b/src/utils/readConfig.ts
index fb6835b..50cb6c6 100644
--- a/src/utils/readConfig.ts
+++ b/src/utils/readConfig.ts
@@ -85,13 +85,13 @@
moderation: {
mute: {
timeout: true,
- role: null, // TODO: actually give it
+ role: "934941369137524816", // TODO: Remove this role after the time
text: null,
link: null
},
kick: {
text: "Appeal here",
- link: "https://clicksminuteper.net"
+ link: "https://clicks.codes"
},
ban: {
text: null,
diff --git a/src/utils/scanners.ts b/src/utils/scanners.ts
index 97e9bf4..5abd726 100644
--- a/src/utils/scanners.ts
+++ b/src/utils/scanners.ts
@@ -8,23 +8,23 @@
const __dirname = path.dirname(__filename);
export async function testNSFW(link: string): Promise<JSON> {
- const image = (await (await fetch(link)).buffer()).toString('base64')
- let fileName = generateFileName(link.split('/').pop().split('.').pop())
- let p = path.join(__dirname, '/temp', fileName)
- writeFileSync(p, image, 'base64')
- let result = await us.nsfw.file(p)
+ const image = (await (await fetch(link)).buffer()).toString('base64')
+ let fileName = generateFileName(link.split('/').pop().split('.').pop())
+ let p = path.join(__dirname, '/temp', fileName)
+ writeFileSync(p, image, 'base64')
+ let result = await us.nsfw.file(p)
return result
}
export async function testMalware(link: string): Promise<JSON> {
- const file = (await (await fetch(link)).buffer()).toString('base64')
- let fileName = generateFileName(link.split('/').pop().split('.').pop())
- let p = path.join(__dirname, '/temp', fileName)
- writeFileSync(p, file, 'base64')
- let result = await us.malware.file(p)
+ const file = (await (await fetch(link)).buffer()).toString('base64')
+ let fileName = generateFileName(link.split('/').pop().split('.').pop())
+ let p = path.join(__dirname, '/temp', fileName)
+ writeFileSync(p, file, 'base64')
+ let result = await us.malware.file(p)
return result
}
export async function testLink(link: string): Promise<JSON> {
- return await us.link.scan(link)
+ return await us.link.scan(link)
}