【问题标题】:I'm getting the error clear missing intents when coding a bot我在编写机器人代码时收到错误清除缺失的意图
【发布时间】:2022-01-10 13:21:19
【问题描述】:
const Discord = require("discord.js");

const client = new Discord.Client({ ws: { intents: new Discord.Intents(Discord.Intents.ALL) } });

这是一个需要所有意图的代码是不是错了

client.once('ready', () => {
    console.log('Coleria is online!');
});

const prefix = '*'

我可以用这个前缀吗

client.on("message", message =>{
    if(!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(" ");
    const command = args.shift().toLowerCase();

    if(command === 'sa'){
        messageCreate.channel.send('As kardeşim hoşgeldin.');
    }
});

client.login("my token");

【问题讨论】:

    标签: javascript discord.js bots


    【解决方案1】:

    你不应该使用ws: { intents: new Discord.Intents(Discord.Intents.ALL)}

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

    您应该使用此代码,因为您的机器人正在尝试查找 GUILDSGUILD_MESSAGES 标志,而这就是您需要使用的全部内容。

    【讨论】:

    • 我的机器人需要进行审核才能工作?
    • 是的,无论如何它都会工作,我正在我的客户端上使用它。
    猜你喜欢
    • 2018-05-11
    • 2021-11-18
    • 2021-01-28
    • 2021-11-04
    • 2020-08-30
    • 2021-12-26
    • 2021-11-18
    • 2020-07-08
    • 2022-10-22
    相关资源
    最近更新 更多