New*_*wJs 26 javascript node.js discord discord.js
我开始学习discord.js,但现在我面临这个问题。我尝试了一些谷歌搜索,但无法修复它。
const Discord = require('discord.js');
// const Discord = require('discord.js');
// Using Intents class
const client = new Discord.Client();
client.on('message', (msg) => {
// Send back a reply when the specific command has been written by a user.
if (msg.content === '!hello') {
msg.reply('Hello, World!');
}
});
client.login('my_token');
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
Dre*_*egg 34
您需要使用网关意图指定您希望机器人接收的事件。
代替
const client = new Discord.Client();
Run Code Online (Sandbox Code Playgroud)
使用
const client = new Discord.Client({ intents: [Enter intents here] })
Run Code Online (Sandbox Code Playgroud)
例如
Discord.js v14:
const client = new Discord.Client({ intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages
]})
Run Code Online (Sandbox Code Playgroud)
Discord.js v13:
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
这是另一个有用的页面:网关
npm install node@16在外壳中。| 归档时间: |
|
| 查看次数: |
105056 次 |
| 最近记录: |