changes to how deleting tickets works, and UI when creating mod tickets
diff --git a/src/automations/createModActionTicket.ts b/src/automations/createModActionTicket.ts
index 4de2924..ef317b7 100644
--- a/src/automations/createModActionTicket.ts
+++ b/src/automations/createModActionTicket.ts
@@ -3,7 +3,7 @@
import generateEmojiEmbed from '../utils/generateEmojiEmbed.js';
import getEmojiByName from "../utils/getEmojiByName.js";
-export async function create(guild: Discord.Guild, member: Discord.User, client) {
+export async function create(guild: Discord.Guild, member: Discord.User, createdBy: Discord.User, client) {
let config = await readConfig(guild.id);
// @ts-ignore
const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = client.logger
@@ -70,6 +70,7 @@
},
list: {
ticketFor: entry(member.id, renderUser(member)),
+ createdBy: entry(createdBy.id, renderUser(createdBy)),
created: entry(new Date().getTime(), renderDelta(new Date().getTime())),
ticketChannel: entry(c.id, renderChannel(c)),
},
diff --git a/src/automations/tickets/delete.ts b/src/automations/tickets/delete.ts
index 32315bc..17d889a 100644
--- a/src/automations/tickets/delete.ts
+++ b/src/automations/tickets/delete.ts
@@ -11,7 +11,7 @@
let channel = (interaction.channel as Discord.TextChannel)
if (!channel.parent || config.tickets.category != channel.parent.id) {
return interaction.reply({embeds: [new generateEmojiEmbed()
- .setTitle("Close Ticket")
+ .setTitle("Deleting Ticket...")
.setDescription("This ticket is not in your tickets category, so cannot be deleted. You cannot run close in a thread.") // TODO bridge to cross later!
.setStatus("Danger")
.setEmoji("CONTROL.BLOCKCROSS")
@@ -19,96 +19,92 @@
}
let status = channel.topic.split(" ")[1];
if (status == "Archived") {
- interaction.reply({embeds: [new generateEmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket will be deleted in 3 seconds.")
+ await interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("Delete Ticket")
+ .setDescription("Your ticket is being deleted...")
.setStatus("Danger")
.setEmoji("GUILD.TICKET.CLOSE")
]});
- setTimeout(async () => {
- let data = {
- meta:{
- type: 'ticketClosed',
- displayName: 'Ticket Closed',
- calculateType: true,
- color: NucleusColors.red,
- emoji: 'GUILD.TICKET.CLOSE',
- timestamp: new Date().getTime()
- },
- list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- closed: entry(new Date().getTime(), renderDelta(new Date().getTime()))
- },
- hidden: {
- guild: interaction.guild.id
- }
+ let data = {
+ meta:{
+ type: 'ticketDeleted',
+ displayName: 'Ticket Deleted',
+ calculateType: true,
+ color: NucleusColors.red,
+ emoji: 'GUILD.TICKET.CLOSE',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
+ deletedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ closed: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data, interaction.client);
- interaction.channel.delete();
- }, 3000);
+ }
+ log(data, interaction.client);
+ interaction.channel.delete();
return;
} else if (status == "Active") {
- interaction.reply({embeds: [new generateEmojiEmbed()
+ await interaction.reply({embeds: [new generateEmojiEmbed()
.setTitle("Close Ticket")
- .setDescription("This ticket will be archived in 3 seconds.")
+ .setDescription("Your ticket is being closed...")
.setStatus("Warning")
.setEmoji("GUILD.TICKET.ARCHIVED")
]});
- setTimeout(async () =>{
- let overwrites = [
- {
- id: channel.topic.split(" ")[0],
- deny: ["VIEW_CHANNEL"],
- type: "member"
- },
- {
- id: interaction.guild.id,
- deny: ["VIEW_CHANNEL"],
- type: "role"
- }
- ] as Discord.OverwriteResolvable[];
- if (config.tickets.supportRole != null) {
- overwrites.push({
- id: interaction.guild.roles.cache.get(config.tickets.supportRole),
- allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
- type: "role"
- })
+ let overwrites = [
+ {
+ id: channel.topic.split(" ")[0],
+ deny: ["VIEW_CHANNEL"],
+ type: "member"
+ },
+ {
+ id: interaction.guild.id,
+ deny: ["VIEW_CHANNEL"],
+ type: "role"
}
- channel.edit({permissionOverwrites: overwrites})
- channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
- let data = {
- meta:{
- type: 'ticketArchive',
- displayName: 'Ticket Archived',
- calculateType: true,
- color: NucleusColors.yellow,
- emoji: 'GUILD.TICKET.ARCHIVED',
- timestamp: new Date().getTime()
- },
- list: {
- ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
- archivedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
- archived: entry(new Date().getTime(), renderDelta(new Date().getTime())),
- ticketChannel: entry(channel.id, renderChannel(channel)),
- },
- hidden: {
- guild: interaction.guild.id
- }
+ ] as Discord.OverwriteResolvable[];
+ if (config.tickets.supportRole != null) {
+ overwrites.push({
+ id: interaction.guild.roles.cache.get(config.tickets.supportRole),
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
+ type: "role"
+ })
+ }
+ channel.edit({permissionOverwrites: overwrites})
+ channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
+ let data = {
+ meta:{
+ type: 'ticketClosed',
+ displayName: 'Ticket Closed',
+ calculateType: true,
+ color: NucleusColors.yellow,
+ emoji: 'GUILD.TICKET.ARCHIVED',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
+ closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ closed: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ ticketChannel: entry(channel.id, renderChannel(channel)),
+ },
+ hidden: {
+ guild: interaction.guild.id
}
- log(data, interaction.client);
- await interaction.editReply({embeds: [new generateEmojiEmbed()
- .setTitle("Close Ticket")
- .setDescription("This ticket has been archived.\nType `/ticket close` to delete it.")
- .setStatus("Warning")
- .setEmoji("GUILD.TICKET.ARCHIVED") // TODO:[Premium] Add a transcript option ||\----/|| <- the bridge we will cross when we come to it
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setLabel("Close")
- .setStyle("DANGER")
- .setCustomId("closeticket")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- ])]});
- }, 3000);
+ }
+ log(data, interaction.client);
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("This ticket has been closed.\nType `/ticket close` again to delete it.")
+ .setStatus("Warning")
+ .setEmoji("GUILD.TICKET.ARCHIVED") // TODO:[Premium] Add a transcript option ||\----/|| <- the bridge we will cross when we come to it
+ ], components: [new MessageActionRow().addComponents([new MessageButton()
+ .setLabel("Delete")
+ .setStyle("DANGER")
+ .setCustomId("closeticket")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ ])]});
return;
}
}
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index d81a5cc..b2cc94e 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -6,7 +6,6 @@
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import humanizeDuration from "humanize-duration";
-import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
import readConfig from "../../utils/readConfig.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index cd3a7af..e8463f4 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -29,10 +29,10 @@
+ `The user **will${interaction.options.getString("notify") == "yes" ? '' : ' not'}** be notified\n\n`
+ `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${(interaction.options.getMember("user") as GuildMember).id}>'s nickname?`)
.setColor("Danger")
- .addCustomCallback(
+ .addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- () => { create(interaction.guild, interaction.options.getUser("user"), interaction.client)},
- "An appeal ticket was created")
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
+ "An appeal ticket will be created when Confirm is clicked")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
@@ -96,7 +96,7 @@
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.NICKNAME.${failed ? "YELLOW" : "GREEN"}`)
.setTitle(`Nickname`)
- .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : ""))
+ .setDescription("The members nickname was changed" + (failed ? ", but was not notified" : "") + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus(failed ? "Warning" : "Success")
], components: []})
} else {
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index e388ea0..924e507 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -5,7 +5,6 @@
import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import { create, areTicketsEnabled } from "../../automations/createModActionTicket.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
diff --git a/src/commands/mod/unnamed.ts b/src/commands/mod/unnamed.ts
index 20ebc30..ca0bcef 100644
--- a/src/commands/mod/unnamed.ts
+++ b/src/commands/mod/unnamed.ts
@@ -129,10 +129,10 @@
+ `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}>?`) // TODO
.setColor("Danger")
- .addCustomCallback(
+ .addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- () => { create(interaction.guild, interaction.options.getUser("user"), interaction.client)},
- "An appeal ticket was created")
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
+ "An appeal ticket will be created when Confirm is clicked")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 3f63cce..ce54cfb 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -30,10 +30,10 @@
+ `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
- .addCustomCallback(
+ .addCustomBoolean(
"Create appeal ticket", !(await areTicketsEnabled(interaction.guild.id)),
- () => { create(interaction.guild, interaction.options.getUser("user"), interaction.client)},
- "An appeal ticket was created")
+ async () => await create(interaction.guild, interaction.options.getUser("user"), interaction.user, interaction.client),
+ "An appeal ticket will be created when Confirm is clicked")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
.send()
@@ -85,7 +85,7 @@
await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
- .setDescription("The user was warned")
+ .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus("Success")
], components: []})
} else {
@@ -135,7 +135,7 @@
return await interaction.editReply({embeds: [new generateEmojiEmbed()
.setEmoji(`PUNISH.WARN.GREEN`)
.setTitle(`Warn`)
- .setDescription("The user was warned")
+ .setDescription("The user was warned" + (confirmation.response ? ` and an appeal ticket was opened in <#${confirmation.response}>` : ``))
.setStatus("Success")
], components: []})
} else {
diff --git a/src/config/default.json b/src/config/default.json
new file mode 100644
index 0000000..129bfe9
--- /dev/null
+++ b/src/config/default.json
@@ -0,0 +1,108 @@
+{
+ "id": "default",
+ "version": 1,
+ "singleEventNotifications": {
+ "statsChannelDeleted": false
+ },
+ "filters": {
+ "images": {
+ "NSFW": false,
+ "size": false
+ },
+ "malware": false,
+ "wordFilter": {
+ "enabled": false,
+ "words": {
+ "strict": [],
+ "loose": []
+ },
+ "allowed": {
+ "users": [],
+ "roles": [],
+ "channels": []
+ }
+ },
+ "invite": {
+ "enabled": false,
+ "allowed": {
+ "users": [],
+ "channels": [],
+ "roles": []
+ }
+ },
+ "pings": {
+ "mass": 5,
+ "everyone": true,
+ "roles": true,
+ "allowed": {
+ "roles": [],
+ "rolesToMention": [],
+ "users": [],
+ "channels": []
+ }
+ }
+ },
+ "welcome": {
+ "enabled": false,
+ "verificationRequired": {
+ "message": null,
+ "role": null
+ },
+ "welcomeRole": null,
+ "channel": null,
+ "message": null
+ },
+ "stats": [],
+ "logging": {
+ "logs": {
+ "enabled": true,
+ "channel": null,
+ "toLog": "3fffff"
+ },
+ "staff": {
+ "channel": null
+ }
+ },
+ "verify": {
+ "enabled": false,
+ "role": null
+ },
+ "tickets": {
+ "enabled": false,
+ "category": null,
+ "types": "3f",
+ "customTypes": null,
+ "supportRole": null,
+ "maxTickets": 5
+ },
+ "moderation": {
+ "mute": {
+ "timeout": true,
+ "role": null,
+ "text": null,
+ "link": null
+ },
+ "kick": {
+ "text": null,
+ "link": null
+ },
+ "ban": {
+ "text": null,
+ "link": null
+ },
+ "softban": {
+ "text": null,
+ "link": null
+ },
+ "warn": {
+ "text": null,
+ "link": null
+ },
+ "role": {
+ "role": null
+ }
+ },
+ "tracks": [],
+ "roleMenu": [],
+ "tags": {}
+}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 306c5ee..2616f40 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,13 +1,10 @@
-import { HaikuClient } from 'jshaiku';
-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);
+import Database from './utils/database.js';
+import client from './utils/client.js';
await client.registerCommandsIn("./commands");
await client.registerEventsIn("./events");
@@ -19,5 +16,7 @@
client.verify = {}
client.roleMenu = {}
client.memory = new Memory()
+client.database = await new Database(config.mongoUrl).connect()
+
await client.login();
\ No newline at end of file
diff --git a/src/utils/client.ts b/src/utils/client.ts
new file mode 100644
index 0000000..3f4a8a1
--- /dev/null
+++ b/src/utils/client.ts
@@ -0,0 +1,9 @@
+import { HaikuClient } from 'jshaiku';
+import { Intents } from 'discord.js';
+import config from '../config/main.json' assert {type: 'json'};
+
+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);
+
+export default client;
\ No newline at end of file
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index dd97603..7a06d83 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -14,6 +14,8 @@
customCallbackString: string = "";
customCallbackClicked: boolean = false;
customCallbackResponse: any = null;
+ customBoolean: () => any;
+ customBooleanClicked: boolean = null;
inverted: boolean;
constructor(interaction: CommandInteraction) {
@@ -23,8 +25,9 @@
this.emoji = "";
this.description = "";
this.color = "";
- this.inverted = false
- this.customCallback = () => {}
+ this.inverted = false;
+ this.customCallback = () => {};
+ this.customBoolean = () => {};
}
setTitle(title: string) { this.title = title; return this }
@@ -33,12 +36,23 @@
setColor(color: string) { this.color = color; return this }
setInverted(inverted: boolean) { this.inverted = inverted; return this }
addCustomCallback(title: string, disabled: boolean, callback: () => any, callbackClicked: string) {
+ if (this.customButtonTitle) return this
this.customButtonTitle = title;
this.customButtonDisabled = disabled;
this.customCallback = callback;
this.customCallbackString = callbackClicked;
return this;
}
+ addCustomBoolean(title: string, disabled: boolean, callback: () => any, callbackClicked: string) {
+ if (this.customButtonTitle) return this
+ this.customButtonTitle = title;
+ this.customButtonDisabled = disabled;
+ this.customBoolean = callback;
+ this.customCallbackString = callbackClicked;
+ this.customBooleanClicked = false;
+ return this;
+ }
+
async send(editOnly?: boolean) {
while (true) {
@@ -49,7 +63,7 @@
.setTitle(this.title)
.setDescription(this.description)
.setStatus(this.color)
- .setFooter({text: this.customCallbackClicked ? this.customCallbackString : ""})
+ .setFooter({text: (this.customBooleanClicked ?? this.customCallbackClicked) ? this.customCallbackString : ""})
],
components: [
new MessageActionRow().addComponents([
@@ -66,7 +80,10 @@
].concat(this.customButtonTitle ? [new Discord.MessageButton()
.setCustomId("custom")
.setLabel(this.customButtonTitle)
- .setStyle("PRIMARY")
+ .setStyle(this.customBooleanClicked !== null ?
+ ( this.customBooleanClicked ? "SUCCESS" : "PRIMARY" ) :
+ "PRIMARY"
+ )
.setDisabled(this.customButtonDisabled)
.setEmoji(getEmojiByName("CONTROL.TICKET", "id"))
] : []))
@@ -84,19 +101,36 @@
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 };
+ return {
+ success: false,
+ buttonClicked: this.customBooleanClicked ?? this.customCallbackClicked,
+ response: this.customCallbackResponse
+ };
}
if (component.customId === "yes") {
component.deferUpdate();
- return { success: true, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse };
+ if (this.customBooleanClicked === true) this.customCallbackResponse = await this.customBoolean();
+ return {
+ success: true,
+ buttonClicked: this.customBooleanClicked ?? this.customCallbackClicked,
+ response: this.customCallbackResponse
+ };
} else if (component.customId === "no") {
component.deferUpdate();
- return { success: false, buttonClicked: this.customCallbackClicked, response: this.customCallbackResponse };
+ return {
+ success: false,
+ buttonClicked: this.customBooleanClicked ?? this.customCallbackClicked,
+ response: this.customCallbackResponse
+ };
} else if (component.customId === "custom") {
component.deferUpdate();
- this.customCallbackResponse = this.customCallback();
- this.customCallbackClicked = true;
- this.customButtonDisabled = true;
+ if (this.customBooleanClicked !== null) {
+ this.customBooleanClicked = !this.customBooleanClicked;
+ } else {
+ this.customCallbackResponse = await this.customCallback();
+ this.customCallbackClicked = true;
+ this.customButtonDisabled = true;
+ }
editOnly = true;
}
}
diff --git a/src/utils/database.ts b/src/utils/database.ts
new file mode 100644
index 0000000..53ccb97
--- /dev/null
+++ b/src/utils/database.ts
@@ -0,0 +1,180 @@
+import { Collection, Db, MongoClient } from 'mongodb';
+
+
+export const Entry = data => {
+ data = data ?? {};
+ return {
+ get(target, prop, receiver) {
+ let dataToReturn = data[prop]
+ if (dataToReturn === null ) return Reflect.get(target, prop, receiver);
+ if (typeof dataToReturn === "object" && !Array.isArray(dataToReturn)) dataToReturn = new Proxy(
+ Reflect.get(target, prop, receiver),
+ Entry(dataToReturn),
+ )
+ return dataToReturn ?? Reflect.get(target, prop, receiver);
+ }
+ }
+}
+
+
+export default class Database {
+ mongoClient: MongoClient;
+ database: Db;
+ guilds: Collection<GuildConfig>;
+ defaultData: GuildConfig;
+
+ constructor(url) {
+ this.mongoClient = new MongoClient(url);
+ }
+
+ async connect() {
+ await this.mongoClient.connect()
+ this.database = this.mongoClient.db("Nucleus");
+ this.guilds = this.database.collection<GuildConfig>("guilds");
+ await this.guilds.createIndex({ id: "text" }, { unique: true });
+ this.defaultData = (await import("../config/default.json", { assert: { type: "json" }})).default as unknown as GuildConfig;
+ return this;
+ }
+
+ async read(guild: string) {
+ let entry = await this.guilds.findOne({ id: guild });
+ return new Proxy(this.defaultData, Entry(entry)) as unknown as GuildConfig
+ }
+
+ async write(guild: string, config: GuildConfig) {
+ await this.guilds.updateOne({ id: guild }, { $set: config }, { upsert: true });
+ }
+}
+
+export interface GuildConfig {
+ id: string,
+ version: number,
+ singleEventNotifications: {
+ statsChannelDeleted: boolean
+ }
+ filters: {
+ images: {
+ NSFW: boolean,
+ size: boolean
+ },
+ malware: boolean,
+ wordFilter: {
+ enabled: boolean,
+ words: {
+ strict: string[],
+ loose: string[]
+ },
+ allowed: {
+ users: string[],
+ roles: string[],
+ channels: string[]
+ }
+ },
+ invite: {
+ enabled: boolean,
+ allowed: {
+ users: string[],
+ channels: string[],
+ roles: string[]
+ }
+ },
+ pings: {
+ mass: number,
+ everyone: boolean,
+ roles: boolean,
+ allowed: {
+ roles: string[],
+ rolesToMention: string[],
+ users: string[],
+ channels: string[]
+ }
+ }
+ }
+ welcome: {
+ enabled: boolean,
+ verificationRequired: {
+ message: boolean,
+ role: string
+ },
+ welcomeRole: string,
+ channel: string,
+ message: string
+ }
+ stats: {
+ enabled: boolean,
+ channel: string,
+ text: string
+ }[]
+ logging: {
+ logs: {
+ enabled: boolean,
+ channel: string,
+ toLog: string
+ },
+ staff: {
+ channel: string
+ }
+ }
+ verify: {
+ enabled: boolean,
+ role: string
+ }
+ tickets: {
+ enabled: boolean,
+ category: string,
+ types: string,
+ customTypes: string[],
+ supportRole: string,
+ maxTickets: number
+ }
+ moderation: {
+ mute: {
+ timeout: boolean,
+ role: string,
+ text: string,
+ link: string
+ },
+ kick: {
+ text: string,
+ link: string
+ },
+ ban: {
+ text: string,
+ link: string
+ },
+ softban: {
+ text: string,
+ link: string
+ },
+ warn: {
+ text: string,
+ link: string
+ },
+ role: {
+ role: string
+ }
+ }
+ tracks: {
+ name: string,
+ retainPrevious: boolean,
+ nullable: boolean,
+ track: string[],
+ manageableBy: string[]
+ }[]
+ roleMenu: {
+ enabled: boolean,
+ allowWebUI: boolean,
+ options: {
+ name: string,
+ description: string,
+ min: number,
+ max: number,
+ options: {
+ name: string,
+ description: string,
+ role: string
+ }[]
+ }[]
+ }
+ tags: {}
+};
\ No newline at end of file
diff --git a/src/utils/memory.ts b/src/utils/memory.ts
index a4f9501..0cbf955 100644
--- a/src/utils/memory.ts
+++ b/src/utils/memory.ts
@@ -14,7 +14,7 @@
logging: guildData.logging,
tickets: guildData.tickets,
}; // TODO: REMOVE GUILD FROM MEMORY WHEN THESE UPDATE
- }
+ } // TODO: Add a "lastAccessed" prop, delete after 15 minutes
return this.memory[guild];
}
}
diff --git a/src/utils/readConfig.ts b/src/utils/readConfig.ts
index 50cb6c6..b363fc0 100644
--- a/src/utils/readConfig.ts
+++ b/src/utils/readConfig.ts
@@ -1,165 +1,5 @@
+import client from './client.js';
export default async function readConfig(guild: string): Promise<any> {
-
- let config = {
- singleEventNotifications: {
- statsChannelDeleted: false
- },
- filters: {
- images: {
- NSFW: true,
- size: true
- },
- malware: true,
- wordFilter: {
- enabled: true,
- words: {
- strict: [],
- loose: []
- },
- allowed: {
- users: [],
- roles: [],
- channels: []
- }
- },
- invite: {
- enabled: false,
- allowed: {
- users: [],
- channels: [],
- roles: []
- }
- },
- pings: {
- mass: 5,
- everyone: true,
- roles: true,
- allowed: {
- roles: [],
- rolesToMention: [],
- users: [],
- channels: []
- }
- }
- },
- welcome: {
- enabled: true,
- verificationRequired: {
- message: false,
- role: false
- },
- welcomeRole: null,
- channel: '895209752315961344', // null, channel ID or 'dm'
- message: "Welcome to the server, {@}!"
- },
- stats: [
- {
- enabled: true,
- channel: '951910554291818526',
- text: "{count} members | {count:bots} bots | {count:humans} humans"
- }
- ],
- logging: {
- logs: {
- enabled: true,
- channel: '952247098437427260',
- toLog: "3fffff" // "3ffffe" = - channelUpdate, "3fffff" = all
- },
- staff: {
- channel: "895212366252367933"
- }
- },
- verify: {
- enabled: true,
- role: '934941369137524816',
- },
- tickets: {
- enabled: true,
- category: "952302254302584932",
- types: "3f",
- customTypes: null,
- supportRole: null,
- maxTickets: 5
- },
- moderation: {
- mute: {
- timeout: true,
- role: "934941369137524816", // TODO: Remove this role after the time
- text: null,
- link: null
- },
- kick: {
- text: "Appeal here",
- link: "https://clicks.codes"
- },
- ban: {
- text: null,
- link: null
- },
- softban: {
- text: null,
- link: null
- },
- warn: {
- text: null,
- link: null
- },
- role: {
- role: "934941369137524816"
- },
- },
- tracks: [
- {
- name: "Moderation",
- retainPrevious: false,
- nullable: true,
- track: [
- "934941369137524816",
- "934941399806246984",
- "934941408849186856",
- "934941466734764092"
- ],
- manageableBy: []
- },
- {
- name: "Verification",
- retainPrevious: false,
- nullable: true,
- track: [
- "963166531318067250"
- ],
- manageableBy: []
- }
- ],
- roleMenu: {
- enabled: true,
- allowWebUI: true,
- options: [
- {
- name: "Gender",
- description: "What's your gender?",
- min: 1,
- max: 1,
- options: [
- { name: "Male", role: "959901318019948574" },
- { name: "Female", role: "959901346000154674" },
- { name: "Non Binary", description: "Better than the others", role: "959901378363420704"}
- ]
- },
- {
- name: "Pick",
- min: 0,
- max: 4,
- options: [
- { name: "Test Role 1", role: "934941369137524816" },
- { name: "Test Role 2", role: "934941399806246984" },
- { name: "Test Role 3", role: "934941408849186856" },
- { name: "Test Role 4", role: "934941466734764092" }
- ]
- }
- ]
- }
- };
- return config;
+ return await client.database.read(guild);
}