Glow Bunny
Glow Bunny

Reputation: 102

Discord.js Slash Commands saying missing access even though I have "Use slash commands" scope on

I've been trying to make a bot that uses slash commands and the code looks like this:

const Discord = require("discord.js")
const {token} = require("./config.json")

const client = new Discord.Client()
const guildId = "798268649613033532"

const getApp = (guildId) => {
    const app = client.api.applications(client.user.id)
    if (guildId) {
        app.guilds(guildId)
    }
    return app
}

client.once("ready", async () => {
    console.log("Ready!")

    try {
        const commands = getApp(guildId).commands.get()
        console.log(commands)
        
    } catch(err) {
        console.error(err)
    }
})

client.login(token)

but in the console it says: "Promise { } (node:1848) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access"

I know I have use slash commands permission/scope on

Upvotes: 0

Views: 7442

Answers (1)

MrMythical
MrMythical

Reputation: 9041

Make sure that when you invite the bot, the scope is on. Also, use slash commands is a permission, not a scope. You need at least these 2 boxes checked when you copy the link. bot and application.commands boxes checked

Upvotes: 1

Related Questions