Help with Slash Commands

Hello there. So, I am an absolute noob when it comes to slash commands, and the documentation doesn't really help me either. That being said, I based my code off of the guide, but it seems to not be working. Here is my code for reference:
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { SlashCommandBuilder } = require('@discordjs/builders');

// Place your client and guild ids here
const clientId = 'CLIENT_ID'; // actual client ID here
const guildId = 'GUILD_ID'; // actual guild ID here

const rest = new REST({ version: '9' }).setToken("TOKEN"); // actual token here

(async () => {
try {
console.log('Started refreshing application (/) commands.');

await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: [
new SlashCommandBuilder()
.setName("message")
.setDescription("Sends the specified message to the user")
.addSubcommand(subcommand =>
subcommand
.setName("blacklist")
.setDescription("Informs a user of a LETI blacklist. For use by Command Staff.")
.addStringOption(option => option.setName("reason").setDescription("The reason for the blacklist"))
)
.addSubcommand(subcommand =>
subcommand
.setName("suspend")
.setDescription("Informs a user of a LETI suspension. For use by Command Staff.")
).toJSON()
]},
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { SlashCommandBuilder } = require('@discordjs/builders');

// Place your client and guild ids here
const clientId = 'CLIENT_ID'; // actual client ID here
const guildId = 'GUILD_ID'; // actual guild ID here

const rest = new REST({ version: '9' }).setToken("TOKEN"); // actual token here

(async () => {
try {
console.log('Started refreshing application (/) commands.');

await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: [
new SlashCommandBuilder()
.setName("message")
.setDescription("Sends the specified message to the user")
.addSubcommand(subcommand =>
subcommand
.setName("blacklist")
.setDescription("Informs a user of a LETI blacklist. For use by Command Staff.")
.addStringOption(option => option.setName("reason").setDescription("The reason for the blacklist"))
)
.addSubcommand(subcommand =>
subcommand
.setName("suspend")
.setDescription("Informs a user of a LETI suspension. For use by Command Staff.")
).toJSON()
]},
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
But, whenever I run this, I get the following error (image attached). If someone could help me, that would be amazing. Thank you for your time and help, I appreciate it.
1 Reply
Batimius
BatimiusOP3y ago
I see. Now it works. Thank!
Want results from more Discord servers?
Add your server