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"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 6 | |
| 7 | const command = (builder: SlashCommandSubcommandBuilder) => |
| 8 | builder |
| 9 | .setName("suggest") |
| 10 | .setDescription("Sends a suggestion to the developers") |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 11 | .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)) |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 12 | |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 13 | const callback = async (interaction: CommandInteraction) => { |
| 14 | // @ts-ignore |
| 15 | const { renderUser } = interaction.client.logger |
| 16 | let suggestion = interaction.options.getString("suggestion"); |
| 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") |
| 23 | .send() |
| 24 | if (confirmation.success) { |
| 25 | await (interaction.client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({ |
| 26 | embeds: [ |
| 27 | new generateEmojiEmbed() |
| 28 | .setTitle(`Suggestion`) |
| 29 | .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`) |
| 30 | .setStatus("Danger") |
| 31 | .setEmoji("NUCLEUS.LOGO") |
| 32 | ] |
| 33 | }) |
| 34 | await interaction.editReply({embeds: [new generateEmojiEmbed() |
| 35 | .setEmoji("ICONS.ADD") |
| 36 | .setTitle(`Suggest`) |
| 37 | .setDescription("Your suggestion was sent successfully") |
| 38 | .setStatus("Success") |
| 39 | ], components: []}) |
| 40 | } else { |
| 41 | await interaction.editReply({embeds: [new generateEmojiEmbed() |
| 42 | .setEmoji("ICONS.OPP.ADD") |
| 43 | .setTitle(`Suggest`) |
| 44 | .setDescription("No changes were made") |
| 45 | .setStatus("Danger") |
| 46 | ], components: []}) |
| 47 | } |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | export { command }; |
| 55 | export { callback }; |
| 56 | export { check }; |