From 2d52cdad8c0c031fcc5ea26bb852e04aef7f2a9c Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Wed, 4 Jan 2023 14:20:15 -0500 Subject: [PATCH] fixing more crap I broke lol --- commands/Info/modal.js | 1 + events/interactionCreate.js | 38 ++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/commands/Info/modal.js b/commands/Info/modal.js index 5b515d1..226c518 100644 --- a/commands/Info/modal.js +++ b/commands/Info/modal.js @@ -7,6 +7,7 @@ var unirest = require('unirest'); module.exports = { name: "advanced", description: "Formatted submit", + private: false, run: async (client, interaction) => { // await interaction.deferReply(); diff --git a/events/interactionCreate.js b/events/interactionCreate.js index f54a184..8ffe10e 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,10 +1,27 @@ const client = require("../raven_ai"); const fs = require('fs') const jsonfile = require('jsonfile') - +const { glob } = require("glob"); +const { promisify } = require("util"); +const globPromise = promisify(glob); client.on("interactionCreate", async (interaction) => { +// Slash Commands +const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`); +const arrayOfSlashCommands = []; +slashCommands.map((value) => { + const file = require(value); + const splitted = value.split("/"); + const directory = splitted[splitted.length - 2]; + if (!file?.name) return; + + const properties = { directory, ...file }; + client.slashCommands.set(file.name, properties); + + if (["MESSAGE", "USER"].includes(file.type)) delete file.description; + arrayOfSlashCommands.push(file); +}); // Slash Command Handling if (interaction.isChatInputCommand()) { @@ -12,22 +29,9 @@ client.on("interactionCreate", async (interaction) => { if (interaction.commandName === 'advanced'){ console.log("Modal detected, skipping...") } else { - // Process and Parse Data - let dataToProcess = JSON.stringify(commandData[0]) - let parsedData = JSON.parse(dataToProcess) - - // If the command is private, set ephemeral true else, set false - if (parsedData.private == true) { - await interaction.deferReply({ - ephemeral: true - }).catch(() => {}); - - } else { - await interaction.deferReply({ - ephemeral: false - }).catch(() => {}); - } - + // If not, defer and wait for edits - Max 15 Minutes! + // Send defer depending on what the user has their privacy set to + await interaction.deferReply({ ephemeral: false }).catch(() => { }); } // Get command info