pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 1 | import Discord, { CommandInteraction } from "discord.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 2 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
| 3 | import { WrappedCheck } from "jshaiku"; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 4 | import confirmationMessage from "../../utils/confirmationMessage.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 5 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 6 | import client from "../../utils/client.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 7 | |
| 8 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 9 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 10 | .setName("suggest") |
| 11 | .setDescription("Sends a suggestion to the developers") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 12 | .addStringOption((option) => |
| 13 | option |
| 14 | .setName("suggestion") |
| 15 | .setDescription("The suggestion to send") |
| 16 | .setRequired(true) |
| 17 | ); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 18 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 19 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 20 | const { renderUser } = client.logger; |
| 21 | const suggestion = interaction.options.getString("suggestion"); |
| 22 | const confirmation = await new confirmationMessage(interaction) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 23 | .setEmoji("ICONS.OPP.ADD") |
| 24 | .setTitle("Suggest") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 25 | .setDescription( |
| 26 | `**Suggestion:**\n> ${suggestion}\n` + |
| 27 | "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?" |
| 28 | ) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 29 | .setColor("Danger") |
PineappleFan | 19b002b | 2022-05-19 11:54:01 +0100 | [diff] [blame] | 30 | .setInverted(true) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 31 | .send(); |
| 32 | if (confirmation.cancelled) return; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 33 | if (confirmation.success) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 34 | await ( |
| 35 | client.channels.cache.get( |
| 36 | "955161206459600976" |
| 37 | ) as Discord.TextChannel |
| 38 | ).send({ |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 39 | embeds: [ |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 40 | new EmojiEmbed() |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 41 | .setTitle("Suggestion") |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 42 | .setDescription( |
| 43 | `**From:** ${renderUser( |
| 44 | interaction.member.user |
| 45 | )}\n**Suggestion:**\n> ${suggestion}` |
| 46 | ) |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 47 | .setStatus("Danger") |
| 48 | .setEmoji("NUCLEUS.LOGO") |
| 49 | ] |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 50 | }); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 51 | await interaction.editReply({ |
| 52 | embeds: [ |
| 53 | new EmojiEmbed() |
| 54 | .setEmoji("ICONS.ADD") |
| 55 | .setTitle("Suggest") |
| 56 | .setDescription("Your suggestion was sent successfully") |
| 57 | .setStatus("Success") |
| 58 | ], |
| 59 | components: [] |
| 60 | }); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 61 | } else { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 62 | await interaction.editReply({ |
| 63 | embeds: [ |
| 64 | new EmojiEmbed() |
| 65 | .setEmoji("ICONS.OPP.ADD") |
| 66 | .setTitle("Suggest") |
| 67 | .setDescription("No changes were made") |
| 68 | .setStatus("Danger") |
| 69 | ], |
| 70 | components: [] |
| 71 | }); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 72 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 73 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 74 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 75 | const check = ( |
| 76 | _interaction: CommandInteraction, |
| 77 | _defaultCheck: WrappedCheck |
| 78 | ) => { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 79 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 80 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 81 | |
| 82 | export { command }; |
| 83 | export { callback }; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame^] | 84 | export { check }; |