nyx/events/guildDelete.js

46 lines
1.2 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-06-12 12:53:51 +02:00
client.ServerLog.send(
new MessageEmbed()
2021-06-24 09:53:19 +02:00
.setTitle("Deleted Server")
2021-06-12 12:53:51 +02:00
.addField("Server Info", [
2021-06-14 12:53:39 +02:00
`**>Server Name**: \n${guild.name}`,
`**>Server ID**: \n${guild.id}`,
`**>Server Member Count**: \n${guild.memberCount}`,
2021-06-12 12:53:51 +02:00
])
.addField("Owner Info", [
2021-06-14 12:53:39 +02:00
`**>Owner Tag**: \n${guild.owner.user.tag}`,
`**>Owner ID**: \n${guild.owner.id}`,
2021-06-12 12:53:51 +02:00
])
2021-06-14 12:53:39 +02:00
.setFooter(
2021-06-24 09:53:19 +02:00
`${client.user.username} Currently in ${client.guilds.cache.size} servers`,
client.user.displayAvatarURL()
2021-06-14 12:53:39 +02:00
)
2021-06-12 12:53:51 +02:00
.setTimestamp()
.setThumbnail(guild.iconURL({ dynamic: true }))
.setColor("RED")
);
});
/**
* @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;
};