我一直试图弄清楚如何为服务器制作一个不和谐的机器人。我从简单的开始就只是基本的反应,但是它对我给它的另一半命令没有反应。如果有人想帮助我,这是代码。请记住,我只是一个初学者,这是我有史以来的第一个项目。另外,这些命令非常有趣,因此请注意。
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'RETRACTED';
bot.on('ready', () =>{
console.log('Im alive whore');
bot.user.setActivity ("owo");
});
const PREFIX = '!';
bot.on ("message", (message => {
if (message.author.bot) return;
msg = message.content.toLowerCase();
if (msg.includes ("pp")) {
message.channel.sendMessage ("haha you said pp!")
}
msg = message.content.toLowerCase();
if (msg.startsWith ("good morning")) {
message.channel.send("Good morning! Remember to stay hydrated!")
}
if (msg.includes ("komaeda"))
message.react ('?');
}
))
bot.on ("message", (message => {
if (message.author.bot) return;
msg = message.content.toLowerCase();
if (msg.includes ("eggs")) {
message.react ('?');
message.channel.sendMessage ("SunnySideup please")
}
if (msg.includes ("Jojo good")) {
message.channel.sendMessage("Your opinion is WRONG!")
}
if (msg.startsWith ("Jojo")) {
message.channel.sendMessage("jojo is bad ah ha ha")
}
}))
bot.on ("message", (message => {
if (message.author.bot) return;
msg = message.content.toLowerCase();
if (msg.includes ("Like scoob what's your favorite thing to do on the weekened")) {
message.channel.sendMessage("Arururururururururu")
}
if (msg.includes ("Bathroom time")) {
message.channel.sendMessage("Piss? Yummy!")
}
if (msg.includes ("Bathroom time")) {
message.channel.sendMessage("Piss? Yummy!")
}
}))
bot.login (token);
答案 0 :(得分:0)
当message
仅识别其中一个时,您将注册三个单独的Client
事件监听器。
将所有message
事件监听器组合到.on("message", ...)
命令中,它应该可以正常工作。