【问题标题】:Discord.js 'CLIENT_MISSING_INTENTS' ErrorDiscord.js 'CLIENT_MISSING_INTENTS' 错误
【发布时间】:2021-10-25 11:37:45
【问题描述】:

我正在尝试让我的 Discord 机器人出现在网上,但我收到了 error

代码:

const Discord = require('discord.js');
const client = new Discord.Client();

client.once('ready' , () => {
    console.log('Bot is online');
});

client.login('My token');

谁能指出我正确的方向?

【问题讨论】:

标签: discord discord.js bots


【解决方案1】:

Intents 是在 discord.js v13 中引入的,并确保机器人只做它打算做的事情 - 即它不会浪费处理能力。

//example from the official Discord.js guide
const { Client, Intents } = require('discord.js');

const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS);

const client = new Client({ intents: myIntents });

client.login('mytoken');

The docs 总是一个先看的好地方。

【讨论】:

    猜你喜欢
    • 2021-11-09
    • 2021-10-12
    • 1970-01-01
    • 2021-10-15
    • 2021-10-16
    • 2021-11-24
    • 1970-01-01
    • 2021-04-07
    • 2021-08-13
    相关资源
    最近更新 更多