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") |
| 12 | .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 13 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame^] | 14 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 15 | const { renderUser } = client.logger; |
| 16 | const suggestion = interaction.options.getString("suggestion"); |
| 17 | const confirmation = await new confirmationMessage(interaction) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 18 | .setEmoji("ICONS.OPP.ADD") |
| 19 | .setTitle("Suggest") |
| 20 | .setDescription(`**Suggestion:**\n> ${suggestion}\n` |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 21 | + "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 22 | .setColor("Danger") |
PineappleFan | 19b002b | 2022-05-19 11:54:01 +0100 | [diff] [blame] | 23 | .setInverted(true) |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 24 | .send(); |
| 25 | if (confirmation.cancelled) return; |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 26 | if (confirmation.success) { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 27 | await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({ |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 28 | embeds: [ |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 29 | new EmojiEmbed() |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 30 | .setTitle("Suggestion") |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 31 | .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`) |
| 32 | .setStatus("Danger") |
| 33 | .setEmoji("NUCLEUS.LOGO") |
| 34 | ] |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 35 | }); |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 36 | await interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 37 | .setEmoji("ICONS.ADD") |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 38 | .setTitle("Suggest") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 39 | .setDescription("Your suggestion was sent successfully") |
| 40 | .setStatus("Success") |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 41 | ], components: []}); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 42 | } else { |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 43 | await interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 44 | .setEmoji("ICONS.OPP.ADD") |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 45 | .setTitle("Suggest") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 46 | .setDescription("No changes were made") |
| 47 | .setStatus("Danger") |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 48 | ], components: []}); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 49 | } |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 50 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 51 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame^] | 52 | const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 53 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 54 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 55 | |
| 56 | export { command }; |
| 57 | export { callback }; |
| 58 | export { check }; |