【问题标题】:Node . not working while making a discord bot节点。制作不和谐机器人时不工作
【发布时间】:2021-11-08 21:59:24
【问题描述】:

所以我想制作一个不和谐的机器人,当我输入 node 时。进入 CMD 它给了我一个错误。我的代码在下面

const { Client, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

const client = new Discord.Client();

client.once('ready', () => {
    console.log('Better Call Saul!');
});


client.login('The code'); 

错误:

抛出新的 TypeError('CLIENT_MISSING_INTENTS'); ^ TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。在 Client._validateOptions (C:\Users\Uzivatel\Desktop\joe\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:544:13) 在新客户端 (C:\Users\Uzivatel\ Desktop\joe\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:73:10) 在对象。 (C:\Users\Uzivatel\Desktop\joe\main.js:3:16) ←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m ←[90m at Object .Module._extensions..js

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    看来问题出在这里:

    const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
    
    const client = new Discord.Client();
    

    只有第一行有效。

    【讨论】:

    • 那我该怎么办?删除第二个或您的想法。谢谢你
    猜你喜欢
    • 2021-01-17
    • 2018-08-24
    • 2021-01-19
    • 2021-10-02
    • 2018-05-19
    • 2021-07-08
    • 2021-04-02
    • 2020-10-08
    • 1970-01-01
    相关资源
    最近更新 更多