我有一个问题,我有3条始终处于活动状态的命令,可以检测到服务器上何时发生垃圾邮件,链接或泛滥,但是激活后,机器人会变得非常缓慢,并且执行命令所花费的时间很长,我该怎么办?
主文件中的命令
client.commands.get('spam').execute(message, keyv);
client.commands.get('links').execute(message, keyv);
client.commands.get('flood').execute(message, keyv);
spam.js
const Discord = require("discord.js")
module.exports = {
name: 'spam',
description: 'detecta spam',
execute(message, keyv) {
(async () => {
if(message.author.bot) return;
const serverid = message.guild.id;
const channelid = message.channel.id;
var affectbotsenadis = await keyv.get('spam' + "affectbots" + "enadis" + serverid);
var delmsgenadis = await keyv.get('spam' + "delmsg" + "enadis" + serverid);
var getsupsafeenadis = await keyv.get('supsafe' + "enadis" + serverid);
var getenadis = await keyv.get('spamprotection' + "enadis" + channelid + serverid);
if(message.content.includes("acaba") || message.content.includes("unio")) return;
else if(message.content.includes("unanse") && message.content.includes("server")) avise();
else if(message.content.includes("Unanse") && message.content.includes("server")) avise();
else if(message.content.includes("UNANSE") && message.content.includes("SERVER")) avise();
else if(message.content.includes("Únanse") && message.content.includes("server")) avise();
else if(message.content.includes("únanse") && message.content.includes("server")) avise();
else if(message.content.includes("ÚNANSE") && message.content.includes("SERVER")) avise();
else if(message.content.includes("une") && message.content.includes("server")) avise();
else if(message.content.includes("Une") && message.content.includes("server")) avise();
else if(message.content.includes("UNE") && message.content.includes("SERVER")) avise();
else if(message.content.includes("una") && message.content.includes("server")) avise();
else if(message.content.includes("Una") && message.content.includes("server")) avise();
else if(message.content.includes("UNA") && message.content.includes("SERVER")) avise();
else if(message.content.includes("unir") && message.content.includes("server")) avise();
else if(message.content.includes("Unir") && message.content.includes("server")) avise();
else if(message.content.includes("UNIR") && message.content.includes("SERVER")) avise();
else if(message.content.includes("uniros") && message.content.includes("server")) avise();
else if(message.content.includes("Uniros") && message.content.includes("server")) avise();
else if(message.content.includes("UNIROS") && message.content.includes("SERVER")) avise();
else if(message.content.includes("unios") && message.content.includes("server")) avise();
else if(message.content.includes("Unios") && message.content.includes("server")) avise();
else if(message.content.includes("UNIOS") && message.content.includes("SERVER")) avise();
else if(message.content.includes("Unanse") && message.content.includes("serv")) avise();
else if(message.content.includes("unanse") && message.content.includes("serv")) avise();
else if(message.content.includes("UNANSE") && message.content.includes("SERV")) avise();
else if(message.content.includes("Unete") && message.content.includes("server")) avise();
else if(message.content.includes("unete") && message.content.includes("server")) avise();
else if(message.content.includes("UNETE") && message.content.includes("SERVER")) avise();
else if(message.content.includes("ÚNETE") && message.content.includes("SERVER")) avise();
else if(message.content.includes("Únete") && message.content.includes("server")) avise();
else if(message.content.includes("únete") && message.content.includes("server")) avise();
else if(message.content.includes("Unanse") && message.content.includes("servidor")) avise();
else if(message.content.includes("UNANSE") && message.content.includes("SERVIDOR")) avise();
else if(message.content.includes("Únanse") && message.content.includes("servidor")) avise();
else if(message.content.includes("únanse") && message.content.includes("servidor")) avise();
else if(message.content.includes("ÚNANSE") && message.content.includes("SERVIDOR")) avise();
else if(message.content.includes("une") && message.content.includes("servidor")) avise();
else if(message.content.includes("Une") && message.content.includes("servidor")) avise();
else if(message.content.includes("UNE") && message.content.includes("SERVIDOR")) avise();
else if(message.content.includes("unir") && message.content.includes("servidor")) avise();
else if(message.content.includes("Unir") && message.content.includes("servidor")) avise();
else if(message.content.includes("UNIR") && message.content.includes("SERVIDOR")) avise();
else if(message.content.includes("uniros") && message.content.includes("servidor")) avise();
else if(message.content.includes("Uniros") && message.content.includes("servidor")) avise();
else if(message.content.includes("UNIROS") && message.content.includes("SERVIDOR")) avise();
else if(message.content.includes("unios") && message.content.includes("servidor")) avise();
else if(message.content.includes("Unios") && message.content.includes("servidor")) avise();
else if(message.content.includes("UNIOS") && message.content.includes("SERVIDOR")) avise();
function avise(){
if(affectbotsenadis == "false"){
if(message.author.bot) return;
}
if(getsupsafeenadis == "true"){
if(message.member.hasPermission("MANAGE_MESSAGES")) return;
}
if(getenadis == "disable") return;
if(delmsgenadis == "true"){
message.delete();
}
else{
message.react("⚠")
}
const embed = new Discord.RichEmbed()
.setDescription(message.author + ", Cuidado con ese spam")
.setColor("RED")
message.channel.send(embed)
}
})();
},
};
links.js
const Discord = require("discord.js")
module.exports = {
name: 'links',
description: 'molesta al bot',
execute(message, keyv) {
if(message.content.includes('discord.gg/'||'discordapp.com/invite/')) avise2();
else if(message.content.includes("http://") && message.content.includes(".com")) avise2();
else if(message.content.includes("https://") && message.content.includes(".com")) avise2();
else if(message.content.includes("http://") && message.content.includes(".mx")) avise2();
else if(message.content.includes("https://") && message.content.includes(".mx")) avise2();
function avise2(){
(async () => {
const serverid = message.guild.id;
const channelid = message.channel.id;
let affectbotsenadis = await keyv.get('links' + "affectbots" + "enadis" + serverid);
let delmsgenadis = await keyv.get('links' + "delmsg" + "enadis" + serverid);
let getsupsafeenadis = await keyv.get('supsafe' + "enadis" + serverid);
let getenadis = await keyv.get('linksprotection' + "enadis" + channelid + serverid);
if(affectbotsenadis == "false"){
if(message.author.bot) return;
}
if(getsupsafeenadis == "true"){
if(message.member.hasPermission("MANAGE_MESSAGES")) return;
}
if(getenadis == "disable") return;
if(delmsgenadis == "true"){
message.delete();
}
else{
message.react("⚠")
}
const embed = new Discord.RichEmbed()
.setDescription(message.author + ", Cuidado con ese link")
.setColor("RED")
message.channel.send(embed)
})();
}
},
};
flood.js
const Discord = require("discord.js")
const client = new Discord.Client();
module.exports = {
name: 'flood',
description: 'Ping!',
execute(message, keyv){
(async () => {
if(message.author.bot) return;
if(message.content.length >= 450){
const serverid = message.guild.id;
const channelid = message.channel.id;
var getenadis = await keyv.get('floodprotection' + "enadis" + channelid + serverid);
if(getenadis == "disable") return;
message.react("⚠")
const embed = new Discord.RichEmbed()
.setDescription(message.author + ", Cuidado con ese flood")
.setColor("RED")
message.channel.send(embed)
}
})();
},
};
当我从代码中删除这些命令时,机器人再次正常,但是当您将它们放回原位时,它又变慢了,执行命令大约需要3秒钟,这是什么错误或我该怎么办?