PineaFan | 0d06edc | 2023-01-17 22:10:31 +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"; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -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"; |
PineaFan | 1dee28f | 2023-01-16 22:09:07 +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> => { |
PineaFan | 538d375 | 2023-01-12 21:48:23 +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; |
PineaFan | 1dee28f | 2023-01-16 22:09:07 +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( |
| 40 | `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}\n\n` + |
| 41 | `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`, |
| 42 | ) |
| 43 | .setStatus("Warning") |
| 44 | ], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents( |
| 45 | new Discord.ButtonBuilder() |
| 46 | .setCustomId("suggestionAccept") |
| 47 | .setLabel("Accept") |
| 48 | .setStyle(ButtonStyle.Secondary) |
| 49 | .setEmoji(getEmojiByName("ICONS.ADD", "id")), |
| 50 | new Discord.ButtonBuilder() |
| 51 | .setCustomId("suggestionDeny") |
| 52 | .setLabel("Delete") |
| 53 | .setStyle(ButtonStyle.Secondary) |
| 54 | .setEmoji(getEmojiByName("ICONS.REMOVE", "id")) |
| 55 | )] |
| 56 | }); |
| 57 | await interaction.editReply({ |
| 58 | embeds: [ |
| 59 | new EmojiEmbed() |
| 60 | .setEmoji("ICONS.ADD") |
| 61 | .setTitle("Suggest") |
| 62 | .setDescription("Your suggestion was sent successfully") |
| 63 | .setStatus("Success") |
| 64 | ], |
| 65 | components: [] |
| 66 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 67 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 68 | |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 69 | export { command }; |
| 70 | export { callback }; |