JaBa/events/guildMemberUpdate.js

26 lines
766 B
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
module.exports = class {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
this.client = client;
}
2021-12-26 19:29:37 +05:00
async run(oldMember, newMember) {
2021-12-10 21:39:54 +05:00
if (oldMember.guild.id !== this.client.config.support.id) return;
2021-12-11 21:08:37 +05:00
if (oldMember.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) return;
if (newMember.roles.cache.some((r) => r.name === "Поддержавшие JaBa")) {
2021-12-26 19:29:37 +05:00
const userData = await this.client.findOrCreateUser({
id: newMember.id
});
2021-12-10 21:39:54 +05:00
userData.achievements.tip.progress.now = 1;
userData.achievements.tip.achieved = true;
userData.markModified("achievements.tip");
await userData.save();
2021-12-16 23:42:58 +05:00
2021-12-26 19:29:37 +05:00
newMember.send({
files: [{
name: "unlocked.png",
attachment: "./assets/img/achievements/achievement_unlocked5.png"
}]
});
2021-12-10 21:39:54 +05:00
};
}
};