premium.js (4606B)
1 const { EmbedBuilder } = require("discord.js"); 2 module.exports = { 3 name: "premiumserver", 4 category: "Config", 5 description: "Add premium to a server", 6 Premium: true, 7 options: [ 8 { 9 type: 5, 10 name: "choice", 11 description: "Whether add or remove premium server", 12 required: true, 13 }, 14 ], 15 run: async (client, interaction) => { 16 try { 17 const user = await client.data.getUser(interaction.user.id); 18 const guild = await client.data.getGuild(interaction.guild.id); 19 if (interaction.options.getBoolean("choice")) { 20 if (guild.Premium) { 21 return interaction.followUp({ 22 content: "This server is already premium", 23 }); 24 } 25 if ( 26 (user.Tier == 1 && user.PremiumServers.length >= 5) || 27 (user.Tier == 2 && user.PremiumServers.length >= 2) || 28 (user.Tier == 3 && user.PremiumServers.length >= 0) 29 ) { 30 interaction.followUp({ 31 content: 32 "You have already reached the maximum amount of premium servers", 33 }); 34 } else { 35 await client.data.setPremium(interaction.guild.id, "true"); 36 await client.data.pushGuild( 37 interaction.user.id, 38 interaction.guild.id, 39 "push" 40 ); 41 interaction.followUp({ 42 embeds: [ 43 new EmbedBuilder() 44 .setTitle("Success!") 45 .setDescription( 46 `Premium added to **${interaction.guild.name}**! \n` 47 ) 48 .setFooter({ text: "Thank you for supporting Cath!" }) 49 .setColor("Green") 50 .setTimestamp() 51 .setAuthor({ 52 name: interaction.user.tag, 53 iconURL: interaction.user.displayAvatarURL({ dynamic: true }), 54 }), 55 ], 56 }); 57 client.channels.cache.get(client.config.ServerLog).send({ 58 embeds: [ 59 new EmbedBuilder() 60 .setTitle("New Premium Server") 61 .addFields({ 62 name: "Server Info", 63 value: `**>Server Name**: \n${interaction.guild.name} 64 **>Server ID**: \n${interaction.guild.id} 65 **>Server Member Count**: \n${interaction.guild.memberCount}`, 66 }) 67 .setTimestamp() 68 .setThumbnail(interaction.guild.iconURL({ dynamic: true })) 69 .setColor("Green"), 70 ], 71 }); 72 } 73 } else { 74 if (!guild.Premium) { 75 return interaction.followUp({ 76 content: "This server isn't premium yet", 77 }); 78 } 79 if (!user.PremiumServers.includes(interaction.guild.id)) { 80 return interaction.followUp({ 81 content: 82 "You can't remove due to you aren't the person who made the server premium", 83 }); 84 } else { 85 await client.data.setPremium(interaction.guild.id, "false"); 86 await client.data.pushGuild( 87 interaction.user.id, 88 interaction.guild.id, 89 "splice" 90 ); 91 interaction.followUp({ 92 embeds: [ 93 new EmbedBuilder() 94 .setTitle("Removed!") 95 .setDescription( 96 `Premium removed from **${interaction.guild.name}**! \n` 97 ) 98 .setColor("Red") 99 .setTimestamp() 100 .setAuthor({ 101 name: interaction.user.tag, 102 iconURL: interaction.user.displayAvatarURL({ dynamic: true }), 103 }), 104 ], 105 }); 106 client.channels.cache.get(client.config.ServerLog).send({ 107 embeds: [ 108 new EmbedBuilder() 109 .setTitle("Premium Server Removed") 110 .addFields({ 111 name: "Server Info", 112 value: `**>Server Name**: \n${interaction.guild.name} 113 **>Server ID**: \n${interaction.guild.id} 114 **>Server Member Count**: \n${interaction.guild.memberCount}`, 115 }) 116 .setTimestamp() 117 .setThumbnail(interaction.guild.iconURL({ dynamic: true })) 118 .setColor("Red"), 119 ], 120 }); 121 } 122 } 123 } catch (e) { 124 console.log(e); 125 interaction.followUp({ content: `**Error**: ${e.message}` }); 126 } 127 }, 128 };