-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneratekey.js
44 lines (37 loc) · 1.23 KB
/
generatekey.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const {
Client,
Interaction,
EmbedBuilder,
PermissionFlagsBits,
} = require("discord.js");
const { v4: uuidv4 } = require("uuid"); // Import the UUID generator
module.exports = {
/**
* @param {Client} client
* @param {Interaction} interaction
*/
callback: async (client, interaction) => {
const allowedRole = "";
if (!interaction.member.roles.cache.has(allowedRole)) {
return await interaction.reply({ content: "❌ You don't have permission to use this command.", ephemeral: true });
}
try {
const generatedKey = uuidv4();
const embed = new EmbedBuilder()
.setColor("#4ea554")
.setTitle("🔑 Key Generated")
.setDescription(`Here's your generated key: \`${generatedKey}\``)
.setTimestamp()
.setFooter({
text: `Requested by ${interaction.user.tag}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
});
await interaction.reply({ embeds: [embed] });
} catch (error) {
console.error("Error generating key:", error);
await interaction.reply({ content: "❌ Failed to generate a key.", ephemeral: true });
}
},
name: "generatekey",
description: "Generates a key.",
};