Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 1 | import { LoadingEmbed } from "../../utils/defaults.js"; |
PineaFan | 1dee28f | 2023-01-16 22:09:07 +0000 | [diff] [blame] | 2 | import { ButtonStyle, CommandInteraction } from "discord.js"; |
| 3 | import Discord from "discord.js"; |
TheCodedProf | f86ba09 | 2023-01-27 17:10:07 -0500 | [diff] [blame] | 4 | import type { SlashCommandSubcommandBuilder } from "discord.js"; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 5 | import confirmationMessage from "../../utils/confirmationMessage.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 6 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 7 | import client from "../../utils/client.js"; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 8 | import getEmojiByName from "../../utils/getEmojiByName.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 9 | |
| 10 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 11 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 12 | .setName("suggest") |
| 13 | .setDescription("Sends a suggestion to the developers") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 14 | .addStringOption((option) => |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame] | 15 | option.setName("suggestion").setDescription("The suggestion to send").setRequired(true) |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 16 | ); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 17 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 18 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 19 | await interaction.guild?.members.fetch(interaction.member!.user.id); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 20 | const { renderUser } = client.logger; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 21 | const suggestion = interaction.options.get("suggestion")?.value as string; |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 22 | await interaction.reply({ embeds: LoadingEmbed, ephemeral: true }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 23 | const confirmation = await new confirmationMessage(interaction) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 24 | .setEmoji("ICONS.OPP.ADD") |
| 25 | .setTitle("Suggest") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 26 | .setDescription( |
| 27 | `**Suggestion:**\n> ${suggestion}\n` + |
| 28 | "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?" |
| 29 | ) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 30 | .setColor("Danger") |
PineappleFan | 19b002b | 2022-05-19 11:54:01 +0100 | [diff] [blame] | 31 | .setInverted(true) |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 32 | .setFailedMessage("Your suggestion was deleted", "Success", "ICONS.ADD") |
PineaFan | 1dee28f | 2023-01-16 22:09:07 +0000 | [diff] [blame] | 33 | .send(true); |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 34 | if (confirmation.cancelled || !confirmation.success) return; |
| 35 | await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({ |
| 36 | embeds: [ |
| 37 | new EmojiEmbed() |
| 38 | .setTitle("Suggestion") |
| 39 | .setDescription( |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 40 | `**From:** ${renderUser( |
| 41 | interaction.member!.user as Discord.User |
| 42 | )}\n**Suggestion:**\n> ${suggestion}\n\n` + |
| 43 | `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n` |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 44 | ) |
| 45 | .setStatus("Warning") |
Skyler Grey | da16adf | 2023-03-05 10:22:12 +0000 | [diff] [blame] | 46 | ], |
| 47 | components: [ |
| 48 | new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents( |
| 49 | new Discord.ButtonBuilder() |
| 50 | .setCustomId("suggestionAccept") |
| 51 | .setLabel("Accept") |
| 52 | .setStyle(ButtonStyle.Secondary) |
| 53 | .setEmoji(getEmojiByName("ICONS.ADD", "id")), |
| 54 | new Discord.ButtonBuilder() |
| 55 | .setCustomId("suggestionDeny") |
| 56 | .setLabel("Delete") |
| 57 | .setStyle(ButtonStyle.Secondary) |
| 58 | .setEmoji(getEmojiByName("ICONS.REMOVE", "id")) |
| 59 | ) |
| 60 | ] |
PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 61 | }); |
| 62 | await interaction.editReply({ |
| 63 | embeds: [ |
| 64 | new EmojiEmbed() |
| 65 | .setEmoji("ICONS.ADD") |
| 66 | .setTitle("Suggest") |
| 67 | .setDescription("Your suggestion was sent successfully") |
| 68 | .setStatus("Success") |
| 69 | ], |
| 70 | components: [] |
| 71 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 72 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 73 | |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 74 | export { command }; |
| 75 | export { callback }; |