我想通过特定频道的 ID 检索频道名称、用户列表。
我收到错误 Missing access
错误信息:
DiscordAPIError: Missing Access
at RequestHandler.execute (c:\Users\Viktor\Desktop\BattlefyParser\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async RequestHandler.push (c:\Users\Viktor\Desktop\BattlefyParser\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (c:\Users\Viktor\Desktop\BattlefyParser\node_modules\discord.js\src\managers\GuildManager.js:247:18) {
method: 'get',
path: '/guilds/810614721694007316?with_counts=true',
code: 50001,
httpStatus: 403
}
我的代码:
const channelID = "810614721694007316";
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
client.guilds
.fetch(channelID)
.then((guild) => console.log(guild.name))
.catch(console.error);
});
client.login("TOKEN");