nyx/events/guild.js

63 lines
1.9 KiB
JavaScript
Raw Normal View History

const client = require("../");
2022-10-26 12:38:28 +02:00
const { EmbedBuilder } = require("discord.js");
const db = require("../models/guilds");
client.on("guildCreate", guild => {
client.channels.cache.get(client.config.ServerLog).send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
.setTitle("New Server")
2023-02-03 23:02:41 +01:00
.addFields({
name: "Server Info",
value: `**>Server Name**: \n${guild.name}
**>Server ID**: \n${guild.id}
**>Server Member Count**: \n${guild.memberCount}`,
})
2022-10-26 12:38:28 +02:00
.setFooter({
text: `${client.user.username} Currently in ${client.guilds.cache.size} servers`,
2023-04-02 14:12:53 +02:00
iconURL: client.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
.setTimestamp()
.setThumbnail(guild.iconURL({ dynamic: true }))
.setColor("Green"),
],
});
const newdb = new db({
Guild: guild.id,
Prefix: client.config.prefix,
});
newdb.save();
2021-06-12 12:53:51 +02:00
});
client.on("guildDelete", async guild => {
client.data.DelGuild(guild.id);
client.channels.cache.get(client.config.ServerLog).send({
embeds: [
2022-10-26 12:38:28 +02:00
new EmbedBuilder()
.setTitle("Deleted Server")
2023-02-03 23:02:41 +01:00
.addFields({
name: "Server Info",
value: `**>Server Name**: \n${guild.name}
**>Server ID**: \n${guild.id}
**>Server Member Count**: \n${guild.memberCount}`,
})
2022-10-26 12:38:28 +02:00
.setFooter({
text: `${client.user.username} Currently in ${client.guilds.cache.size} servers`,
2023-04-02 14:12:53 +02:00
iconURL: client.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
.setTimestamp()
.setThumbnail(guild.iconURL({ dynamic: true }))
2023-02-03 23:28:45 +01:00
.setColor("Red"),
],
});
2021-06-12 12:53:51 +02:00
});
client.prefix = async function (message) {
let custom;
if (!message.guild) return;
const data = await db
.findOne({ Guild: message.guild.id })
.catch(err => console.log(err));
if (data) custom = data.Prefix;
2021-09-21 01:51:56 +02:00
else custom = client.config.prefix;
return custom;
};