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