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