Interaction aint saving
// ---> Adding the needed collections
const commands = [];
//client.commands = new Discord.Collection();
// Place your client and guild ids here
const clientId = clientID;
const guildId = guildID;
// ---> Reads the command files
const commandFiles = fs.readdirSync('./Commands')
for (const folder of commandFiles) {
const commandFiles = fs.readdirSync(`./Commands/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./Commands/${folder}/${file}`);
if (command.data) { commands.push(command.data.toJSON()); }
}
}
// ---> Rest for slash commands
const rest = new REST({ version: '10' }).setToken(token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// ---> The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// ---> And of course, make sure you catch and log any errors!
console.error(error);
}
})();
// ---> Adding the needed collections
const commands = [];
//client.commands = new Discord.Collection();
// Place your client and guild ids here
const clientId = clientID;
const guildId = guildID;
// ---> Reads the command files
const commandFiles = fs.readdirSync('./Commands')
for (const folder of commandFiles) {
const commandFiles = fs.readdirSync(`./Commands/${folder}`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./Commands/${folder}/${file}`);
if (command.data) { commands.push(command.data.toJSON()); }
}
}
// ---> Rest for slash commands
const rest = new REST({ version: '10' }).setToken(token);
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// ---> The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// ---> And of course, make sure you catch and log any errors!
console.error(error);
}
})();
2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Okay so if I do this, it says it successfully loaded 1 command, which it should
However if I try that command and log "client" in my interactionCreate event, it logs nothing