adding ephemeral support
This commit is contained in:
parent
f76e482f60
commit
f15c2786a6
@ -4,6 +4,7 @@ var generator = require('generate-password');
|
||||
module.exports = {
|
||||
name: "password-generator",
|
||||
description: "Generates a random secure password",
|
||||
private: true,
|
||||
options: [{
|
||||
"name": "length",
|
||||
"description": "Provide a number for how long to make the password.",
|
||||
|
@ -1,15 +1,51 @@
|
||||
const client = require("../index");
|
||||
require("dotenv").config();
|
||||
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()) {
|
||||
console.log(interaction )
|
||||
if (interaction.commandName == "password-generator") {
|
||||
await interaction.deferReply({ ephemeral: true }).catch(() => { });
|
||||
|
||||
let commandData = []
|
||||
await arrayOfSlashCommands.forEach(command => {
|
||||
console.log(command.name)
|
||||
if (command.name == interaction.commandName) {
|
||||
commandData.push(command)
|
||||
}
|
||||
});
|
||||
|
||||
let dataToProcess = JSON.stringify(commandData[0])
|
||||
let parsedData = JSON.parse(dataToProcess)
|
||||
|
||||
console.log(parsedData.private)
|
||||
|
||||
if (parsedData.private == true) {
|
||||
await interaction.deferReply({ ephemeral: true }).catch(() => { });
|
||||
|
||||
} else {
|
||||
await interaction.deferReply({ ephemeral: false }).catch(() => { });
|
||||
|
||||
}
|
||||
|
||||
const cmd = client.slashCommands.get(interaction.commandName);
|
||||
if (!cmd)
|
||||
return interaction.followUp({ content: "An error has occurred " });
|
||||
@ -35,4 +71,5 @@ console.log(interaction )
|
||||
const command = client.slashCommands.get(interaction.commandName);
|
||||
if (command) command.run(client, interaction);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -30,6 +30,7 @@ module.exports = async (client) => {
|
||||
// // Register for a single guild
|
||||
// await client.guilds.cache.get("GUIDIDHERE").commands.set(arrayOfSlashCommands);
|
||||
|
||||
console.log(arrayOfSlashCommands)
|
||||
// Register for all the guilds the bot is in
|
||||
await client.application.commands.set(arrayOfSlashCommands);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user