【问题标题】:DISCORD JS BOT - TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client [duplicate]DISCORD JS BOT-TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效意图[重复]
【发布时间】:2021-10-17 07:19:23
【问题描述】:

我收到上述错误。

代码如下:

// token: ---------------------------------------------------

const token = ('') // a ''-k közé kell beírni a tokent-

// ----------------------------------------------------------


// channel id-k ----------------------------

const ofo = ('779369203572015134');
const magyar = ('797181568355008573');
const matematika = ('779368815364538398');
const angol = ('780147093850554408');
const tortenelem = ('780147128671797259');
const fizika = ('784325257754181632');
const biologia = ('784325257754181632');
const foldrajz = ('797181800661254144');
const rezidencia = ('821122601283747841');
const detox = ('743212240215212064');
const testgeneral = ('876043353593118725')

// -----------------------------------------

const schedule = require('node-schedule');
const Discord = require('discord.js');
const fs = require('fs');
const client = new Discord.Client();




client.on("ready", () => {
    const job = schedule.scheduleJob({hour: 20, minute: 10}, () => {     
        const channel = client.channels.cache.get(testgeneral);
    
        if (!channel) return console.error("ilen csatolna nincsen embe");
        channel.join().then(connection => {
            console.log("sikeres csatlakozás.");
        }).catch(e => {
            console.error(e);
        });
    });
    client.login(token); 
});

这是我输入 ' node 时的错误代码。 ' : TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。

有人知道我该如何解决这个问题吗? 谢谢

【问题讨论】:

标签: node.js discord discord.js


【解决方案1】:

在 Discord.JS v13+ 上,您需要为客户端设置意图。

示例:

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

您可以在Discord Guides查看更多信息

所有存在的意图是:

  • Intents.FLAGS.GUILDS
  • Intents.FLAGS.GUILD_MEMBERS
  • Intents.FLAGS.GUILD_BANS
  • Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS
  • Intents.FLAGS.GUILD_INTEGRATIONS
  • Intents.FLAGS.GUILD_WEBHOOKS
  • Intents.FLAGS.GUILD_INVITES
  • Intents.FLAGS.GUILD_VOICE_STATES
  • Intents.FLAGS.GUILD_PRESENCES
  • Intents.FLAGS.GUILD_MESSAGES
  • Intents.FLAGS.GUILD_MESSAGE_REACTIONS
  • Intents.FLAGS.GUILD_MESSAGE_TYPING
  • Intents.FLAGS.DIRECT_MESSAGES
  • Intents.FLAGS.DIRECT_MESSAGE_REACTION
  • Intents.FLAGS.DIRECT_MESSAGE_TYPING

【讨论】:

    猜你喜欢
    • 2021-10-14
    • 2022-06-19
    • 2021-12-02
    • 2021-10-12
    • 1970-01-01
    • 2021-02-07
    • 2021-05-23
    • 2020-07-15
    • 2017-08-26
    相关资源
    最近更新 更多