few changes
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)
}