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