【问题标题】:An issue in making my bot online in discord使我的机器人不和谐在线的问题
【发布时间】:2021-11-14 21:40:36
【问题描述】:

(节点版本:14.17.6)

当我在终端输入node . 时,它给了我这个问题:

抛出新的 TypeError('CLIENT_MISSING_INTENTS'); ^

TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。 在 Client._validateOptions (C:\Users\DELL\Desktop\Discord Bot\node_modules\discord.js\src\client\Client.js:544:13) 在新客户端(C:\Users\DELL\Desktop\Discord Bot\node_modules\discord.js\src\client\Client.js:73:10) 在对象。 (C:\Users\DELL\Desktop\Discord Bot\index.js:2:13) 在 Module._compile (internal/modules/cjs/loader.js:1072:14) 在 Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) 在 Module.load (internal/modules/cjs/loader.js:937:32) 在 Function.Module._load (internal/modules/cjs/loader.js:778:12) 在 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) 在内部/main/run_main_module.js:17:47 { [符号(代码)]:'CLIENT_MISSING_INTENTS' }

我在 VSC 中写的内容:

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

const token ='MY TOKEN';

bot.on('ready', () =>{
    console.log('This bot is online!');
})

bot.on("message", msg=>{
    if (msg.content === "HELLO"){
        msg.reply('HELLO FRIEND!');
    }
})   
    
bot.login(token);



【问题讨论】:

标签: node.js visual-studio-code discord


【解决方案1】:

客户没有意图 这些将是您的主要内容

let bot = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })

【讨论】:

  • 如需更多帮助,请联系discord.js guide site
  • 所以我将const bot = new Discord.Client(); 切换到let bot = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
  • 但它仍然给了我同样的错误
  • 我刚刚下载了 node 的最新版本,它可以工作了!..谢谢
猜你喜欢
  • 2022-11-10
  • 2021-11-18
  • 2020-06-08
  • 2020-12-25
  • 1970-01-01
  • 2019-02-26
  • 2019-09-04
  • 2020-07-20
  • 2019-08-03
相关资源
最近更新 更多