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