client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channelID) {
if (reaction.emoji.name === EmojiTeam) {
let member = await reaction.message.guild.members.cache.get(user.id);
member.roles.add(EmojiRole);
}
} else {
return;
}
});
client.on('messageReactionRemove', async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.id == channelID) {
if (reaction.emoji.name === EmojiTeam) {
let member = await reaction.message.guild.members.cache.get(user.id);
member.roles.remove(EmojiRole);
}
} else {
return;
}
});
передавать что либо можно в самом warn.js. В warn.js там где execute, можно вписать что нужно для выполнения этого файла.
module.exports = {
name: "warn",
description: "Give players warn points and then kick/ban them",
execute(message, pingedUserTag) {
. . .
}
};
const Discord = require("discord.js");
const client = new Discord.Client();
const mysql = require("mysql");
module.exports = {
name: "warn",
description: "Give players warn points and then kick/ban",
execute(message) {
//используемые функции
var con = mysql.createConnection({
host: "host",
user: "user",
password: "pass",
database: "database"
});
deleteLastM = function() {
message.channel.messages.fetch({
limit: 1
}).then(messages => {
message.channel.bulkDelete(messages)
});
}
//конец используемых функций
deleteLastM();
if (message.member.hasPermission("MANAGE_MESSAGES")){
var warnTarget = message.mentions.users.first();
var num = parseInt(message.content);
let points;
let action;
let why;
if (message.content.includes("1")) { points = 10; console.log("first rule"); }
else if (message.content.includes("2")) { points = 10; console.log("second rule"); }
else if (message.content.includes("3")) { points = 20; console.log("third rule"); }
else if (message.content.includes("4")) { points = 20; }
//else { points = 10; }
con.query(`SELECT * FROM table WHERE id = '${warnTarget.id}'`, (err, warns) => {
if(err) throw err;
let sql;
if (warns >= 50 && warns <= 60) {
warnTarget.kick();
sql = `UPDATE table SET warns = ${warns + points} WHERE id = '${warnTarget.id}'`;
warnTarget.send(deletedembed);
}
else if (warns >= 100){
sql = `UPDATE table SET warns = ${warns + points} WHERE id = '${warnTarget.id}'`;
warnTarget.ban();
warnTarget.send(deletedembed);
}
else {
sql = `INSERT INTO AniBot_warns (id, warns) VALUES ('${warnTarget.id}','${points}')`;
}
con.query(sql);
});
}
else {message.channel.send("У вас не хватает прав")}
}
};
Появилось даже тогда когда бот сам поставил на сообщение эмодзи.