gpt4 book ai didi

javascript - Discord 机器人仅对少数命令使用react

转载 作者:行者123 更新时间:2023-11-28 03:07:12 25 4
gpt4 key购买 nike

我一直在试图弄清楚如何为我的服务器制作一个不和谐的机器人。我一开始很简单,只有基本的 react ,但它对我给它的另一半命令没有反应。如果有人愿意帮助我,这里是代码。请记住,我只是一个初学者,这是我的第一个项目。此外,这些命令非常有趣,因此请注意。

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);

最佳答案

Client 只能识别其中一个时,您正在注册三个单独的 message 事件监听器。

将所有 message 事件监听器合并到 on.on("message", ...) 命令中,它应该可以正常工作。

关于javascript - Discord 机器人仅对少数命令使用react,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60499398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com