【问题标题】:i an getting an error in my discord bot, please tell how fix我的不和谐机器人出现错误,请告诉我如何修复
【发布时间】:2022-01-19 09:19:47
【问题描述】:

我在 Cody Lyons 视频的帮助下编写了一个不和谐机器人,视频是关于不和谐机器人制作的基础知识: video

错误:

C:\Users\mdfar\bot\node_modules\discord.js\src\client\Client.js:544
      throw new TypeError('CLIENT_MISSING_INTENTS');
      ^

TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
    at Client._validateOptions (C:\Users\mdfar\bot\node_modules\discord.js\src\client\Client.js:544:13)
    at new Client (C:\Users\mdfar\bot\node_modules\discord.js\src\client\Client.js:73:10)
    at Object.<anonymous> (C:\Users\mdfar\bot\index.js:2:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  [Symbol(code)]: 'CLIENT_MISSING_INTENTS'

我的代码:

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

const token = 'OTIwOTQ3OTM1MjQyNTAyMTU1.Ybrxmg.lcPJbRn-xqIvsVieOt7emiAjD4w';

bot.on('ready', () =>{
    console.log('This Bot Is Online');
})

bot.login(token);

请帮忙,我正在为此使用节点 js

【问题讨论】:

    标签: javascript node.js discord bots


    【解决方案1】:

    自 Discordjs v13 起您需要提供意图

    const { Client, Intents } = require('discord.js');
    
    const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
    

    建议大家阅读全文here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 1970-01-01
      • 2021-04-30
      • 2021-11-04
      • 1970-01-01
      • 2021-05-03
      • 2020-08-29
      相关资源
      最近更新 更多