简体   繁体   English

关于 discord.js V13 启动所有 Intents

[英]About discord.js V13 start all Intents

The thing is like this, I try to upgrade my original robot to V13, So I decided to rewrite the bot.事情是这样的,我尝试将我原来的机器人升级到 V13,所以我决定重写机器人。

I don't know how to get all Intents at once I tried Intents.all but it didn't work this is my code我不知道如何一次获取所有 Intent 我尝试了 Intents.all 但它不起作用这是我的代码

 const { Client, Intents, MessageEmbed } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const cofing = require("./cofig.json"); client.on('ready', () => { console.log("================"); console.log("|i am ready|"); console.log("================"); }); client.on('message', async message => { if(message.content === 'test'){ console.log("test") } }); client.login(cofing.token);

If you could tell me how to write this, I would be very grateful如果你能告诉我怎么写,我将不胜感激

First of all: There is a small error in your message event ( client.on('message', ... ) ), it's no longer 'message', but 'messageCreate' in v13, so keep in mind u have to update that.首先:您的消息事件( client.on('message', ... ) )中有一个小错误,它不再是'message',而是v13中的'messageCreate',所以请记住你必须更新那。

About the intents: If you would like to use all intents (which I don't recommend), you can define all the intents in one intent via a Bitfield , you do this with the following code:关于意图:如果您想使用所有意图(我不推荐),您可以通过Bitfield在一个意图中定义所有意图,您可以使用以下代码执行此操作:

const allIntents = new Intents(32767);
const client = new Client({ intents: allIntents });

FYI: First in the beginning of v13 there was a flag called ALL (Intents.FLAGS.ALL), but that was removed afterwards, so this is the alternative to it.仅供参考:首先在 v13 的开头有一个名为ALL (Intents.FLAGS.ALL) 的标志,但后来被删除了,所以这是它的替代品。

const {Client,intents,Collection, DiscordAPIError, Guild} = require("discord.js") const client = new Client ({intents:[7796]})

The Intents: 32767 Is Not Working Anymore意图:32767 不再工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM