2021-11-18 18:56:42 +01:00
|
|
|
const client = require("../");
|
2021-06-12 12:53:51 +02:00
|
|
|
const { MessageEmbed } = require("discord.js");
|
2021-09-17 18:28:39 +02:00
|
|
|
const db = require("../models/guilds");
|
|
|
|
client.on("guildCreate", guild => {
|
2021-11-18 18:56:42 +01:00
|
|
|
client.channels.cache.get(client.config.ServerLog).send({
|
2021-09-17 18:28:39 +02:00
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("New Server")
|
|
|
|
.addField(
|
|
|
|
"Server Info",
|
|
|
|
`**>Server Name**: \n${guild.name}
|
|
|
|
**>Server ID**: \n${guild.id}
|
|
|
|
**>Server Member Count**: \n${guild.memberCount}`
|
|
|
|
)
|
|
|
|
.setFooter(
|
|
|
|
`${client.user.username} Currently in ${client.guilds.cache.size} servers`,
|
|
|
|
client.user.displayAvatarURL()
|
|
|
|
)
|
|
|
|
.setTimestamp()
|
|
|
|
.setThumbnail(guild.iconURL({ dynamic: true }))
|
|
|
|
.setColor("GREEN"),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
const newdb = new db({
|
|
|
|
Guild: guild.id,
|
2021-11-18 18:56:42 +01:00
|
|
|
Prefix: client.config.prefix,
|
2021-09-17 18:28:39 +02:00
|
|
|
});
|
|
|
|
newdb.save();
|
2021-06-12 12:53:51 +02:00
|
|
|
});
|
|
|
|
|
2021-09-17 18:28:39 +02:00
|
|
|
client.on("guildDelete", async guild => {
|
|
|
|
client.data.DelGuild(guild.id);
|
2021-11-18 18:56:42 +01:00
|
|
|
client.channels.cache.get(client.config.ServerLog).send({
|
2021-09-17 18:28:39 +02:00
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("Deleted Server")
|
|
|
|
.addField(
|
|
|
|
"Server Info",
|
|
|
|
`**>Server Name**: \n${guild.name}
|
|
|
|
**>Server ID**: \n${guild.id}
|
|
|
|
**>Server Member Count**: \n${guild.memberCount}`
|
|
|
|
)
|
|
|
|
.setFooter(
|
|
|
|
`${client.user.username} Currently in ${client.guilds.cache.size} servers`,
|
|
|
|
client.user.displayAvatarURL()
|
|
|
|
)
|
|
|
|
.setTimestamp()
|
|
|
|
.setThumbnail(guild.iconURL({ dynamic: true }))
|
|
|
|
.setColor("RED"),
|
|
|
|
],
|
|
|
|
});
|
2021-06-12 12:53:51 +02:00
|
|
|
});
|
2021-09-17 18:28:39 +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;
|
2021-09-17 18:28:39 +02:00
|
|
|
return custom;
|
|
|
|
};
|