【发布时间】:2022-01-04 22:37:33
【问题描述】:
我知道一些基本的python,我决定尝试制作一个不和谐的机器人,但未能让机器人响应命令。我尝试将“-ping”更改为“ping”并尝试在我的不和谐服务器上输入:
平 -ping
但两者都没有做任何事情。此外,
console.log('This does not run');
不显示在控制台中。
我不太确定我错在哪里。任何帮助,将不胜感激。谢谢!
const {Client, Intents} = require('discord.js');
const {token} = require('./config.json');
const client = new Client({intents:[Intents.FLAGS.GUILDS]});
const prefix = '-';
client.once('ready', () => {
console.log('Bot works');
});
client.on('message', message => {
console.log('This does not run');
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ */);
const command = args.shift().toLowerCase();
if(command === '-ping'){
message.channel.send('pong');
}
});
client.login(token);
【问题讨论】:
标签: node.js discord.js