2023-01-04 11:44:59 -05:00
|
|
|
const client = require("../raven_ai");
|
2023-01-04 13:58:27 -05:00
|
|
|
const fs = require('fs')
|
|
|
|
const jsonfile = require('jsonfile')
|
2023-01-04 11:44:59 -05:00
|
|
|
|
|
|
|
|
2023-01-04 13:58:27 -05:00
|
|
|
client.on("interactionCreate", async (interaction) => {
|
2023-01-04 11:44:59 -05:00
|
|
|
|
|
|
|
// Slash Command Handling
|
|
|
|
if (interaction.isChatInputCommand()) {
|
|
|
|
|
2023-01-04 13:58:27 -05:00
|
|
|
// If we have a modal, lets make sure to skip the deferal.
|
|
|
|
if (interaction.commandName === 'advanced'){
|
|
|
|
console.log("Modal detected, skipping...")
|
|
|
|
} else {
|
2023-01-04 14:01:50 -05:00
|
|
|
// 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(() => {});
|
|
|
|
}
|
|
|
|
|
2023-01-04 13:58:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get command info
|
|
|
|
const cmd = client.slashCommands.get(interaction.commandName);
|
|
|
|
if (!cmd)
|
|
|
|
return interaction.followUp({ content: "An error has occurred " });
|
|
|
|
// Args, Options and Subdommands handling from module.exports.
|
|
|
|
const args = [];
|
|
|
|
for (let option of interaction.options.data) {
|
|
|
|
if (option.type === "SUB_COMMAND") {
|
|
|
|
if (option.name) args.push(option.name);
|
|
|
|
option.options?.forEach((x) => {
|
|
|
|
if (x.value) args.push(x.value);
|
|
|
|
});
|
|
|
|
} else if (option.value) args.push(option.value);
|
|
|
|
}
|
|
|
|
// Set GUILD member
|
|
|
|
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
|
|
|
|
|
|
|
// Run Command
|
|
|
|
cmd.run(client, interaction, args);
|
2023-01-04 11:44:59 -05:00
|
|
|
}
|
|
|
|
|
2023-01-04 13:58:27 -05:00
|
|
|
|
2023-01-04 11:44:59 -05:00
|
|
|
// Context Menu Handling
|
|
|
|
if (interaction.isContextMenuCommand()) {
|
2023-01-04 13:58:27 -05:00
|
|
|
await interaction.deferReply({ ephemeral: false });
|
|
|
|
const command = client.slashCommands.get(interaction.commandName);
|
|
|
|
if (command) command.run(client, interaction);
|
2023-01-04 11:44:59 -05:00
|
|
|
}
|
|
|
|
});
|