nyx/events/guildDelete.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-06-24 09:53:19 +02:00
const client = require("../bot");
2021-06-12 12:53:51 +02:00
const db = require("../models/guilds");
2021-06-14 12:53:39 +02:00
const { prefix } = require("../config.json");
2021-06-12 12:53:51 +02:00
const { MessageEmbed } = require("discord.js");
client.on("guildDelete", async guild => {
2021-06-24 09:53:19 +02:00
client.data.DelGuild(guild.id);
2021-09-06 12:38:25 +02:00
client.channels.cache.get(client.ServerLog).send({
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}`,
])
.addField("Owner Info", [
`**>Owner Tag**: \n${guild.owner.user.tag}`,
`**>Owner ID**: \n${guild.owner.id}`,
])
.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
});
/**
* @param {Client} client
*/
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;
} else {
custom = prefix;
}
return custom;
};