【问题标题】:Intents keep giving me a error even though the intents code is a C&P from a working bot即使意图代码是来自工作机器人的 C&P,意图仍然给我一个错误
【发布时间】:2022-10-22 06:47:15
【问题描述】:

我已经尝试过,这是我的另一个机器人的现有代码的副本,但是当我运行它时,我收到一条错误消息,提示“未定义意图”

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

错误:

ReferenceError: Intents is not defined

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    简单地说,您应该通过这样做来定义意图:

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

    编辑:您不需要在 discord.js v13 上使用Discord,因为它不需要,而是这样做:

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

    【讨论】:

      猜你喜欢
      • 2023-01-05
      • 2020-04-14
      • 2022-01-10
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2014-01-09
      • 2016-10-29
      • 1970-01-01
      相关资源
      最近更新 更多