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}`);
    }
  })();
Was this page helpful?