Goal: Make a command that only certain people can use, and prevent spam.
Create commands/secret.js
const { SlashCommandBuilder } = require("@discordjs/builders");
module.exports = {
dev: true,
cooldown: 10, // 10 seconds between uses per user
users: ["PUT_YOUR_USER_ID_HERE"], // only these users can run it
data: new SlashCommandBuilder()
.setName("secret")
.setDescription("A locked command for approved users"),
async execute(interaction) {
await interaction.reply({ content: "You are allowed to use this command.", ephemeral: true });
},
};
Discord → Settings → Advanced → Developer Mode ON → Right-click your name → Copy ID.
node index.js
Run /secret. Then run it again quickly to see cooldown.
/secret