我一直在尝试制作一个使用斜杠命令的机器人,代码如下所示:
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)
但在控制台中它说:“Promise { } (node:1848) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access"
我知道我使用了斜线命令权限/范围