Search code examples
javascriptdiscorddiscord.jsapplication-error

DiscordAPIError[10002]: Unknown Application


I've ran into an error, but I have no idea where's the problem. Please help me find the problem. There's is what it got me as error: There was an error: DiscordAPIError[10002]: Unknown Application

And here's the code:

require('dotenv').config();
const { REST, Routes, ApplicationCommandOptionType } = require('discord.js');


const commands = [

    {
        name: 'embed',
        description: 'Sends an embed!', 
        options: [
            {
                name: 'title',
                description: 'Title of embed',
                type: ApplicationCommandOptionType.String,
                required: true,
            },
            {
                name: 'description',
                description: 'The description of embed',
                type: ApplicationCommandOptionType.String,
                required: false,
            },
            {
                name: 'color',
                description: 'The color of embed',
                type: ApplicationCommandOptionType.String,
                required: false,
                choices: [
                    {
                        name: 'red',
                        value: 'ED4245',
                    },
                    {
                        name: 'green',
                        value: '57F287',
                    },
                    {
                        name: 'blue',
                        value: '3498DB',
                    },
                    {
                        name: 'yellow',
                        value: 'FFFF00',
                    },
                    {
                        name: 'white',
                        value: 'FFFFFF',
                    },
                    {
                        name: 'gold',
                        value: 'F1C40F',
                    },
                    {
                        name: 'orange',
                        value: 'E67E22',
                    },
                ]
            },
        ]
    },
];

Finding a solution to fix this error


Solution

  • It could be that you are passing the wrong client ID. Make sure to use the client ID you get from the Discord Developer Portal in the oauth2 section and pass it as a string. Also, make sure that when registering the commands as Guild Commands you pass the guild ID as a string.