2021-09-21 01:51:56 +02:00
|
|
|
const { MessageEmbed } = require("discord.js");
|
|
|
|
module.exports = {
|
|
|
|
name: "premiumserver",
|
|
|
|
category: "Config",
|
|
|
|
description: "Add premium to a server",
|
|
|
|
Premium: true,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
type: 5,
|
|
|
|
name: "choice",
|
|
|
|
description: "Whether add or remove premium server",
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
2021-11-18 18:56:42 +01:00
|
|
|
run: async (client, interaction) => {
|
2021-09-21 01:51:56 +02:00
|
|
|
try {
|
|
|
|
const user = await client.data.getUser(interaction.user.id);
|
|
|
|
const guild = await client.data.getGuild(interaction.guild.id);
|
|
|
|
if (interaction.options.getBoolean("choice") == true) {
|
|
|
|
if (guild.Premium == true) {
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.followUp({ content: "This server is already premium" });
|
2021-09-21 01:51:56 +02:00
|
|
|
}
|
|
|
|
if (
|
|
|
|
(user.Tier == 1 && user.PremiumServers.length >= 5) ||
|
|
|
|
(user.Tier == 2 && user.PremiumServers.length >= 2) ||
|
|
|
|
(user.Tier == 3 && user.PremiumServers.length >= 0)
|
|
|
|
) {
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.followUp({
|
|
|
|
content:
|
|
|
|
"You have already reached the maximum amount of premium servers",
|
|
|
|
});
|
2021-09-21 01:51:56 +02:00
|
|
|
} else {
|
|
|
|
await client.data.setPremium(interaction.guild.id, "true");
|
|
|
|
await client.data.pushGuild(
|
|
|
|
interaction.user.id,
|
|
|
|
interaction.guild.id,
|
|
|
|
"push"
|
|
|
|
);
|
|
|
|
interaction.followUp({
|
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("Success!")
|
|
|
|
.setDescription(
|
|
|
|
`Premium added to **${interaction.guild.name}**! \n`
|
|
|
|
)
|
|
|
|
.setFooter("Thank you for supporting Cath!")
|
|
|
|
.setColor("GREEN")
|
|
|
|
.setTimestamp()
|
|
|
|
.setAuthor(
|
|
|
|
interaction.user.tag,
|
|
|
|
interaction.user.displayAvatarURL({ dynamic: true })
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
2021-11-18 18:56:42 +01:00
|
|
|
client.channels.cache.get(client.config.ServerLog).send({
|
2021-09-21 01:51:56 +02:00
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("New Premium Server")
|
|
|
|
.addField(
|
|
|
|
"Server Info",
|
|
|
|
`**>Server Name**: \n${interaction.guild.name}
|
|
|
|
**>Server ID**: \n${interaction.guild.id}
|
|
|
|
**>Server Member Count**: \n${interaction.guild.memberCount}`
|
|
|
|
)
|
|
|
|
.setTimestamp()
|
|
|
|
.setThumbnail(interaction.guild.iconURL({ dynamic: true }))
|
|
|
|
.setColor("GREEN"),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (guild.Premium == false) {
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.followUp({ content: "This server isn't premium yet" });
|
2021-09-21 01:51:56 +02:00
|
|
|
}
|
2021-11-18 18:56:42 +01:00
|
|
|
if (!user.PremiumServers.includes(interaction.guild.id)) {
|
|
|
|
interaction.followUp({
|
|
|
|
content:
|
|
|
|
"You can't remove due to you aren't the person who made the server premium",
|
|
|
|
});
|
|
|
|
} else {
|
2021-09-21 01:51:56 +02:00
|
|
|
await client.data.setPremium(interaction.guild.id, "false");
|
|
|
|
await client.data.pushGuild(
|
|
|
|
interaction.user.id,
|
|
|
|
interaction.guild.id,
|
|
|
|
"splice"
|
|
|
|
);
|
|
|
|
interaction.followUp({
|
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("Removed!")
|
|
|
|
.setDescription(
|
|
|
|
`Premium removed from **${interaction.guild.name}**! \n`
|
|
|
|
)
|
|
|
|
.setColor("RED")
|
|
|
|
.setTimestamp()
|
|
|
|
.setAuthor(
|
|
|
|
interaction.user.tag,
|
|
|
|
interaction.user.displayAvatarURL({ dynamic: true })
|
|
|
|
),
|
|
|
|
],
|
|
|
|
});
|
2021-11-18 18:56:42 +01:00
|
|
|
client.channels.cache.get(client.config.ServerLog).send({
|
2021-09-21 01:51:56 +02:00
|
|
|
embeds: [
|
|
|
|
new MessageEmbed()
|
|
|
|
.setTitle("Premium Server Removed")
|
|
|
|
.addField(
|
|
|
|
"Server Info",
|
|
|
|
`**>Server Name**: \n${interaction.guild.name}
|
|
|
|
**>Server ID**: \n${interaction.guild.id}
|
|
|
|
**>Server Member Count**: \n${interaction.guild.memberCount}`
|
|
|
|
)
|
|
|
|
.setTimestamp()
|
|
|
|
.setThumbnail(interaction.guild.iconURL({ dynamic: true }))
|
|
|
|
.setColor("RED"),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
2021-11-18 18:56:42 +01:00
|
|
|
interaction.followUp({ content: `**Error**: ${e.message}` });
|
2021-09-21 01:51:56 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|