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"; |
| 5 | import generateEmojiEmbed 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 | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 14 | const callback = async (interaction: CommandInteraction) => { |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 15 | // @ts-ignore |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +0100 | [diff] [blame^] | 16 | const { renderUser } = client.logger |
pineafan | e625d78 | 2022-05-09 18:04:32 +0100 | [diff] [blame] | 17 | let suggestion = interaction.options.getString("suggestion"); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 18 | let confirmation = await new confirmationMessage(interaction) |
| 19 | .setEmoji("ICONS.OPP.ADD") |
| 20 | .setTitle("Suggest") |
| 21 | .setDescription(`**Suggestion:**\n> ${suggestion}\n` |
| 22 | + `Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?`) |
| 23 | .setColor("Danger") |
PineappleFan | 19b002b | 2022-05-19 11:54:01 +0100 | [diff] [blame] | 24 | .setInverted(true) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 25 | .send() |
| 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: [ |
| 29 | new generateEmojiEmbed() |
| 30 | .setTitle(`Suggestion`) |
| 31 | .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`) |
| 32 | .setStatus("Danger") |
| 33 | .setEmoji("NUCLEUS.LOGO") |
| 34 | ] |
| 35 | }) |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 36 | await interaction.editReply({embeds: [new generateEmojiEmbed() |
| 37 | .setEmoji("ICONS.ADD") |
| 38 | .setTitle(`Suggest`) |
| 39 | .setDescription("Your suggestion was sent successfully") |
| 40 | .setStatus("Success") |
| 41 | ], components: []}) |
| 42 | } else { |
| 43 | await interaction.editReply({embeds: [new generateEmojiEmbed() |
| 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 }; |