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"; |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +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 |
| 10 | .setName("suggest") |
| 11 | .setDescription("Sends a suggestion to the developers") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 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 | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 14 | const callback = async (interaction: CommandInteraction): Promise<any> => { |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +0100 | [diff] [blame] | 15 | const { renderUser } = client.logger |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 16 | let suggestion = interaction.options.getString("suggestion"); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 17 | let confirmation = await new confirmationMessage(interaction) |
| 18 | .setEmoji("ICONS.OPP.ADD") |
| 19 | .setTitle("Suggest") |
| 20 | .setDescription(`**Suggestion:**\n> ${suggestion}\n` |
| 21 | + `Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?`) |
| 22 | .setColor("Danger") |
PineappleFan | 19b002b | 2022-05-19 11:54:01 +0100 | [diff] [blame] | 23 | .setInverted(true) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 24 | .send() |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame^] | 25 | if (confirmation.cancelled) return |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 26 | if (confirmation.success) { |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +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 | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 30 | .setTitle(`Suggestion`) |
| 31 | .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`) |
| 32 | .setStatus("Danger") |
| 33 | .setEmoji("NUCLEUS.LOGO") |
| 34 | ] |
| 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") |
| 38 | .setTitle(`Suggest`) |
| 39 | .setDescription("Your suggestion was sent successfully") |
| 40 | .setStatus("Success") |
| 41 | ], components: []}) |
| 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") |
| 45 | .setTitle(`Suggest`) |
| 46 | .setDescription("No changes were made") |
| 47 | .setStatus("Danger") |
| 48 | ], components: []}) |
| 49 | } |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | export { command }; |
| 57 | export { callback }; |
| 58 | export { check }; |