2022-07-26 17:20:10 +05:00
|
|
|
const BaseEvent = require("../../base/BaseEvent");
|
2022-07-23 17:14:42 +05:00
|
|
|
|
|
|
|
class GuildMemberUpdate extends BaseEvent {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
name: "guildMemberRemove",
|
|
|
|
once: false
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
|
|
|
|
2022-07-23 17:14:42 +05:00
|
|
|
/**
|
|
|
|
*
|
2022-08-02 17:18:47 +05:00
|
|
|
* @param {import("../../base/JaBa")} client
|
2022-07-23 17:14:42 +05:00
|
|
|
* @param {import("discord.js").GuildMember} oldMember
|
|
|
|
* @param {import("discord.js").GuildMember} newMember
|
|
|
|
*/
|
2022-08-02 17:18:47 +05:00
|
|
|
async execute(client, oldMember, newMember) {
|
2022-02-15 01:26:29 +05:00
|
|
|
if (oldMember.guild && oldMember.guild.id === "568120814776614924") return;
|
2022-08-02 17:18:47 +05:00
|
|
|
if (oldMember.guild.id !== client.config.support.id) return;
|
2022-01-04 02:18:28 +05:00
|
|
|
if (oldMember.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) return;
|
2022-08-02 17:18:47 +05:00
|
|
|
|
|
|
|
if (newMember?.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) {
|
|
|
|
const userData = await client.findOrCreateUser({
|
2022-01-04 02:18:28 +05:00
|
|
|
id: newMember.id
|
|
|
|
});
|
|
|
|
userData.achievements.tip.progress.now = 1;
|
|
|
|
userData.achievements.tip.achieved = true;
|
|
|
|
userData.markModified("achievements.tip");
|
|
|
|
await userData.save();
|
|
|
|
|
|
|
|
newMember.send({
|
|
|
|
files: [{
|
2022-01-24 01:34:45 +05:00
|
|
|
name: "achievement_unlocked5.png",
|
2022-01-04 02:18:28 +05:00
|
|
|
attachment: "./assets/img/achievements/achievement_unlocked5.png"
|
|
|
|
}]
|
|
|
|
});
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = GuildMemberUpdate;
|