NotPiotrekDev
NotPiotrekDev
DIAdiscord.js - Imagine an app
Created by NotPiotrekDev on 8/1/2023 in #djs-questions
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}`);
}
})();
4 replies