【发布时间】:2021-12-03 02:53:03
【问题描述】:
我是编程的大三学生。我知道 node.js 并想为不和谐编写自己的机器人。
下面写的我的代码不起作用。 你能帮我解决这个问题吗?
const { Client, Intents } = require('discord.js');
const config = require('./config.json');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message=>{
if(!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
message.channel.send('pong!');
}
})
client.login(config.token);
【问题讨论】:
-
对不起我的英语顺便说一句
-
能否请您添加一个尝试运行机器人时遇到的错误?
标签: javascript node.js discord discord.js