fixing more crap I broke lol

This commit is contained in:
Raven Scott 2023-01-04 14:20:15 -05:00
parent 806163e104
commit 2d52cdad8c
2 changed files with 22 additions and 17 deletions

View File

@ -7,6 +7,7 @@ var unirest = require('unirest');
module.exports = { module.exports = {
name: "advanced", name: "advanced",
description: "Formatted submit", description: "Formatted submit",
private: false,
run: async (client, interaction) => { run: async (client, interaction) => {
// await interaction.deferReply(); // await interaction.deferReply();

View File

@ -1,10 +1,27 @@
const client = require("../raven_ai"); const client = require("../raven_ai");
const fs = require('fs') const fs = require('fs')
const jsonfile = require('jsonfile') const jsonfile = require('jsonfile')
const { glob } = require("glob");
const { promisify } = require("util");
const globPromise = promisify(glob);
client.on("interactionCreate", async (interaction) => { 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 // Slash Command Handling
if (interaction.isChatInputCommand()) { if (interaction.isChatInputCommand()) {
@ -12,22 +29,9 @@ client.on("interactionCreate", async (interaction) => {
if (interaction.commandName === 'advanced'){ if (interaction.commandName === 'advanced'){
console.log("Modal detected, skipping...") console.log("Modal detected, skipping...")
} else { } else {
// Process and Parse Data // If not, defer and wait for edits - Max 15 Minutes!
let dataToProcess = JSON.stringify(commandData[0]) // Send defer depending on what the user has their privacy set to
let parsedData = JSON.parse(dataToProcess) await interaction.deferReply({ ephemeral: false }).catch(() => { });
// 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(() => {});
}
} }
// Get command info // Get command info