Problem with my slash-commands.js

Why am I getting this error (DiscordAPIError[20012]: You are not authorized to perform this action on this application) while running slash-commands.js? slash-commands.js:
const { Client, ApplicationCommandOptionType, REST, Routes } = require('discord.js')
const token = 'x';

let botId = 'x'
const commands = [{
name: 'ping',
description: 'Ping',
},
{
name: 'ticket',
description: 'Ticket',
},
{
name: 'announce',
description: 'Announcement',
options: [
{
name: 'announcement-description',
description: 'Description of the announcement.',
type: ApplicationCommandOptionType.String,
required: true,
},
],
}];
(async () => {
try {
console.log('Registering slash commands...');

const rest = new REST({ version: '10' }).setToken(token);
await rest.put(
Routes.applicationCommands(botId),
{ body: commands }
);

console.log('Slash commands were registered successfully!');
} catch (error) {
console.log(`There was an error: ${error}`);
}
})();
const { Client, ApplicationCommandOptionType, REST, Routes } = require('discord.js')
const token = 'x';

let botId = 'x'
const commands = [{
name: 'ping',
description: 'Ping',
},
{
name: 'ticket',
description: 'Ticket',
},
{
name: 'announce',
description: 'Announcement',
options: [
{
name: 'announcement-description',
description: 'Description of the announcement.',
type: ApplicationCommandOptionType.String,
required: true,
},
],
}];
(async () => {
try {
console.log('Registering slash commands...');

const rest = new REST({ version: '10' }).setToken(token);
await rest.put(
Routes.applicationCommands(botId),
{ body: commands }
);

console.log('Slash commands were registered successfully!');
} catch (error) {
console.log(`There was an error: ${error}`);
}
})();
3 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
space
space2y ago
This error usually happens when you use the id of another application. i.e. The token does not belong to the id you provided.
NotPiotrekDev
NotPiotrekDevOP2y ago
thx
Want results from more Discord servers?
Add your server