TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 1 | import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction } from "discord.js"; |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 2 | import type { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 3 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 4 | import client from "../../utils/client.js"; |
| 5 | import { LoadingEmbed } from "../../utils/defaults.js"; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 6 | |
| 7 | const command = (builder: SlashCommandSubcommandBuilder) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 8 | builder.setName("premium").setDescription("Information about Nucleus Premium"); |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 9 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 10 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 11 | await interaction.reply({embeds: LoadingEmbed, ephemeral: true}) |
| 12 | const member = await (await interaction.client.guilds.fetch("684492926528651336")).members.fetch(interaction.user.id) |
| 13 | const firstDescription = "\n\nPremium allows your server to get access to extra features, for a fixed price per month.\nThis includes:\n" + |
| 14 | "- Attachment logs - Stores attachments so they can be viewed after a message is deleted.\n" + |
| 15 | "- Ticket Transcripts - Gives a link to view the history of a ticket after it has been closed.\n" |
| 16 | if(!member) { |
| 17 | interaction.editReply({ embeds: [ |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 18 | new EmojiEmbed() |
| 19 | .setTitle("Premium") |
| 20 | .setDescription( |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 21 | `*You are not currently in the Clicks Server. To gain access to premium please join.*` + firstDescription |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 22 | ) |
| 23 | .setEmoji("NUCLEUS.LOGO") |
| 24 | .setStatus("Danger") |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 25 | ], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(ButtonStyle.Link).setLabel("Join").setURL("https://discord.gg/bPaNnxe"))] }); |
| 26 | return; |
| 27 | } |
| 28 | const dbMember = await client.database.premium.fetchTotal(interaction.user.id) |
| 29 | let premium; |
| 30 | let count = 0; |
| 31 | if (member.roles.cache.has("1066468879309750313")) { |
| 32 | premium = `You have Infinite Premium! You have been gifted this by the developers as a thank you. You can give premium to any and all servers you are in.`; |
| 33 | count = 200; |
| 34 | } else if (member.roles.cache.has("1066465491713003520")) { |
| 35 | premium = `You have Premium tier 1! You can give premium to ${1 - dbMember}.`; |
| 36 | count = 1; |
| 37 | } else if (member.roles.cache.has("1066439526496604194")) { |
| 38 | premium = `You have Premium tier 2! You can give premium to ${3 - dbMember}.`; |
| 39 | count = 3; |
| 40 | } else if (member.roles.cache.has("1066464134322978912")) { |
| 41 | premium = `You have Premium Mod! You already give premium to all servers you have a "manage" permission in.` |
| 42 | count = 3; |
| 43 | } |
| 44 | |
PineaFan | a35b71b | 2023-01-24 19:33:27 +0000 | [diff] [blame^] | 45 | const closed = false; |
TheCodedProf | 267563a | 2023-01-21 17:00:57 -0500 | [diff] [blame] | 46 | do { |
| 47 | interaction.editReply({ |
| 48 | embeds: [ |
| 49 | new EmojiEmbed() |
| 50 | .setTitle("Premium") |
| 51 | .setDescription( |
| 52 | premium + firstDescription |
| 53 | ) |
| 54 | .setEmoji("NUCLEUS.LOGO") |
| 55 | .setStatus("Danger") |
| 56 | ], |
| 57 | components: [ |
| 58 | new ActionRowBuilder<ButtonBuilder>() |
| 59 | .addComponents( |
| 60 | new ButtonBuilder() |
| 61 | .setStyle(ButtonStyle.Primary) |
| 62 | .setLabel("Activate Premium here") |
| 63 | .setCustomId("premiumActivate") |
| 64 | .setDisabled(count <= 0) |
| 65 | ) |
| 66 | ] |
| 67 | }); |
| 68 | |
| 69 | const filter = (i: any) => i.customId === "premiumActivate" && i.user.id === interaction.user.id; |
| 70 | const collector = interaction.channel?.awaitMessageComponent({ filter, time: 60000 }); |
| 71 | |
| 72 | } while (closed); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 73 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 74 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 75 | const check = () => { |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 76 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 77 | }; |
pineafan | 813bdf4 | 2022-07-24 10:39:10 +0100 | [diff] [blame] | 78 | |
| 79 | export { command }; |
| 80 | export { callback }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 81 | export { check }; |