2022-09-24 13:06:19 -04:00
|
|
|
const client = require("../index");
|
|
|
|
|
|
|
|
client.on("interactionCreate", async (interaction) => {
|
|
|
|
// Slash Command Handling
|
|
|
|
if (interaction.isChatInputCommand()) {
|
2022-09-28 14:48:15 -04:00
|
|
|
console.log(interaction )
|
|
|
|
if (interaction.commandName == "password-generator") {
|
|
|
|
await interaction.deferReply({ ephemeral: true }).catch(() => { });
|
|
|
|
} else {
|
|
|
|
await interaction.deferReply({ ephemeral: false }).catch(() => { });
|
2022-09-24 13:06:19 -04:00
|
|
|
|
2022-09-28 14:48:15 -04:00
|
|
|
}
|
2022-09-24 13:06:19 -04:00
|
|
|
const cmd = client.slashCommands.get(interaction.commandName);
|
|
|
|
if (!cmd)
|
|
|
|
return interaction.followUp({ content: "An error has occurred " });
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
interaction.member = interaction.guild.members.cache.get(interaction.user.id);
|
|
|
|
|
|
|
|
cmd.run(client, interaction, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Context Menu Handling
|
|
|
|
if (interaction.isContextMenuCommand()) {
|
|
|
|
await interaction.deferReply({ ephemeral: false });
|
|
|
|
const command = client.slashCommands.get(interaction.commandName);
|
|
|
|
if (command) command.run(client, interaction);
|
|
|
|
}
|
|
|
|
});
|