JaBa/events/guildCreate.js

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-01-04 02:18:28 +05:00
const Discord = require("discord.js");
module.exports = class {
constructor(client) {
this.client = client;
}
async run(guild) {
const messageOptions = {};
const userData = await this.client.findOrCreateUser({
id: guild.ownerId
2022-01-04 02:18:28 +05:00
});
2022-01-16 20:54:40 +05:00
2022-01-04 02:18:28 +05:00
if (!userData.achievements.invite.achieved) {
userData.achievements.invite.progress.now += 1;
userData.achievements.invite.achieved = true;
messageOptions.files = [{
name: "unlocked.png",
attachment: "./assets/img/achievements/achievement_unlocked7.png"
}];
userData.markModified("achievements.invite");
await userData.save();
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
const thanksEmbed = new Discord.MessageEmbed()
.setAuthor({
name: "Спасибо что добавили меня на свой сервер!"
})
2022-01-13 00:26:23 +05:00
.setDescription(`Для настроек используйте \`${this.client.config.prefix}help\` и посмотрите на административные команды!\nЧтобы изменить язык используйте \`${this.client.config.prefix}setlang [язык]\`.`)
.setColor(this.client.config.embed.color)
.setFooter({
2022-01-13 00:26:23 +05:00
text: this.client.config.embed.footer
})
2022-01-04 02:18:28 +05:00
.setTimestamp();
messageOptions.embed = thanksEmbed;
2022-01-16 20:54:40 +05:00
const owner = await guild.fetchOwner();
owner.send(messageOptions);
2022-01-04 02:18:28 +05:00
2022-01-16 20:59:08 +05:00
const embed = new Discord.MessageEmbed()
.setAuthor({
name: guild.name,
iconURL: guild.iconURL({
dynamic: true
})
})
2022-01-04 02:18:28 +05:00
.setColor("#32CD32")
2022-01-16 20:54:40 +05:00
.setDescription(`Зашёл на сервер **${guild.name}**. На нём **${guild.members.cache.filter((m) => !m.user.bot).size}** пользователей (из них ${guild.members.cache.filter((m) => m.user.bot).size} ботов)`);
2022-01-16 20:59:08 +05:00
this.client.channels.cache.get(this.client.config.support.logs).send({
embeds: [embed]
});
2022-01-04 02:18:28 +05:00
}
};