JaBa/events/Guild/guildCreate.js

74 lines
2 KiB
JavaScript
Raw Normal View History

const BaseEvent = require("../../base/BaseEvent");
2022-01-04 02:18:28 +05:00
class GuildCreate extends BaseEvent {
constructor() {
super({
name: "guildCreate",
once: false,
});
2022-01-04 02:18:28 +05:00
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").Guild} guild
*/
async execute(client, guild) {
const userData = await client.getUserData(guild.ownerId);
2022-01-16 20:54:40 +05:00
2022-01-04 02:18:28 +05:00
if (!userData.achievements.invite.achieved) {
2023-06-27 21:19:55 +05:00
userData.achievements.invite.progress.now = 1;
2022-01-04 02:18:28 +05:00
userData.achievements.invite.achieved = true;
2022-01-04 02:18:28 +05:00
await userData.save();
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
2024-10-03 11:07:02 +05:00
const embed = client.embed({
author: "Thanks for inviting me to your server!",
2024-10-03 11:07:02 +05:00
description: "Use </help:1029832476077596773> in your server to get a list of all commands!",
});
2022-01-04 02:18:28 +05:00
try {
const owner = await guild.fetchOwner();
2024-10-03 11:07:02 +05:00
await owner.send({
files: [
{
name: "unlocked.png",
attachment: "./assets/img/achievements/achievement_unlocked7.png",
},
],
2024-10-03 11:07:02 +05:00
embeds: [embed],
});
2024-10-03 11:07:02 +05:00
} catch (e) {
client.logger.error(`Failed to send welcome message to guild owner: ${e.message}`);
}
2022-02-05 22:16:07 +05:00
if (client.config.support.logs) {
const users = guild.members.cache.filter(m => !m.user.bot).size;
const bots = guild.members.cache.filter(m => m.user.bot).size;
const embed = client.embed({
author: {
name: guild.name,
2024-09-20 22:48:40 +05:00
iconURL: guild.iconURL() || client.user.avatarURL(),
},
2024-10-03 11:07:02 +05:00
description: `Joined a new guild **${guild.name}**. It has **${users}** ${client.functions.getNoun(
users,
client.translate("misc:NOUNS:USERS:1"),
client.translate("misc:NOUNS:USERS:2"),
client.translate("misc:NOUNS:USERS:5"),
)} and **${bots}** ${client.functions.getNoun(bots, client.translate("misc:NOUNS:BOTS:1"), client.translate("misc:NOUNS:BOTS:2"), client.translate("misc:NOUNS:BOTS:5"))}.`,
});
2024-10-03 11:07:02 +05:00
const logChannel = client.channels.cache.get(client.config.support.logs);
if (logChannel)
await logChannel.send({
embeds: [embed],
});
}
2022-01-04 02:18:28 +05:00
}
}
2023-07-05 00:58:06 +05:00
module.exports = GuildCreate;