diff --git a/src/bot/database/schema.ts b/src/bot/database/schema.ts index f42568d..208ee60 100644 --- a/src/bot/database/schema.ts +++ b/src/bot/database/schema.ts @@ -3,8 +3,15 @@ import * as mongoose from "mongoose"; const guildConfigSchema = new mongoose.Schema( { guildId: {type: String, required: true}, - tempVoiceChannelId: {type: String, required: true}, - tempVoiceCategoryId: {type: String, required: true} + tempVoiceEnabled: {type: Boolean, required: true}, + tempVoiceChannelId: {type: String}, + tempVoiceCategoryId: {type: String}, + tempTextEnabled: {type: Boolean, required: true}, + tempTextChannelId: {type: String}, + tempTextCategoryId: {type: String}, + ticketsEnabled: {type: Boolean, required: true}, + ticketsMessageId: {type: String}, + ticketsCategoryId: {type: String}, } ) @@ -17,6 +24,24 @@ const tempVoiceSchema = new mongoose.Schema( } ) +const tempTextSchema = new mongoose.Schema( + { + tempTextId: {type: String}, + guildId: {type: String, required: true}, + textChannelId: {type: String, required: true}, + ownerId: {type: String, required: true} + } +) + +const ticketSchema = new mongoose.Schema( + { + ticketId: {type: String}, + guildId: {type: String, required: true}, + ticketChannelId: {type: String, required: true}, + ownerId: {type: String, required: true} + } +) + tempVoiceSchema.pre('save', function(next) { const randomString = Math.random().toString(36).substring(2, 8); this.tempVoiceId = randomString; diff --git a/src/bot/index.ts b/src/bot/index.ts index 95e2a9e..a1721d0 100644 --- a/src/bot/index.ts +++ b/src/bot/index.ts @@ -41,11 +41,10 @@ for (const folder of commandFolders) { } } -/* // Load buttons logger.info("Loading buttons"); client.buttons = new Map(); -const buttonsPath = path.join(__dirname, "./components/buttons"); +const buttonsPath = path.join(import.meta.dir, "./components/buttons"); const buttonFiles = fs .readdirSync(buttonsPath) .filter((file: string) => file.endsWith(".ts")); @@ -54,13 +53,24 @@ for (const file of buttonFiles) { const button = require(`${buttonsPath}/${file}`); client.buttons.set(button.data.customId, button); } -*/ -/* +// Load select menus +logger.info("Loading select menus"); +client.buttons = new Map(); +const selectMenusPath = path.join(import.meta.dir, "./components/selectmenus"); +const selectMenuFiles = fs + .readdirSync(buttonsPath) + .filter((file: string) => file.endsWith(".ts")); + +for (const file of buttonFiles) { + const selectMenu = require(`${selectMenusPath}/${file}`); + client.selectMenus.set(selectMenu.data.customId, selectMenu); +} + // Load modals logger.info("Loading modals"); client.modals = new Map(); -const modalsPath = path.join(__dirname, "./components/modals"); +const modalsPath = path.join(import.meta.dir, "./components/modals"); const modalFiles = fs .readdirSync(modalsPath) .filter((file: string) => file.endsWith(".ts")); @@ -69,11 +79,10 @@ for (const file of modalFiles) { const model = require(`${modalsPath}/${file}`); client.modals.set(model.data.customId, model); } -*/ // Handle events logger.info("Loading events"); -const eventsPath = path.join(__dirname, "events"); +const eventsPath = path.join(import.meta.dir, "events"); const eventFiles = fs .readdirSync(eventsPath) .filter((file: string) => file.endsWith(".ts")); diff --git a/src/templates/button.ts b/src/templates/button.ts new file mode 100644 index 0000000..43641db --- /dev/null +++ b/src/templates/button.ts @@ -0,0 +1,12 @@ +const { ButtonBuilder, ButtonStyle, Interaction } = require("discord.js"); +const config = require("../../config.ts"); + +module.exports = { + button: new ButtonBuilder() + .setLabel("label") + .setCustomId("id") + .setStyle(ButtonStyle), + async execute(interaction: typeof Interaction) { + // Logic + }, +}; diff --git a/src/templates/modal.ts b/src/templates/modal.ts new file mode 100644 index 0000000..6454205 --- /dev/null +++ b/src/templates/modal.ts @@ -0,0 +1,9 @@ +const { EmbedBuilder, Interaction } = require("discord.js"); +const config = require("../../config.ts"); + +module.exports = { + modal: () => {}, + async execute(interaction: typeof Interaction) { + // Logic + }, +};