blob: 79a0673078aaa770599d65ff33968b1b2ec434c5 [file] [log] [blame]
Skyler Greyda16adf2023-03-05 10:22:12 +00001import { LoadingEmbed } from "../../utils/defaults.js";
PineaFan1dee28f2023-01-16 22:09:07 +00002import { ButtonStyle, CommandInteraction } from "discord.js";
3import Discord from "discord.js";
TheCodedProff86ba092023-01-27 17:10:07 -05004import type { SlashCommandSubcommandBuilder } from "discord.js";
pineafan377794f2022-04-18 19:01:01 +01005import confirmationMessage from "../../utils/confirmationMessage.js";
pineafan4edb7762022-06-26 19:21:04 +01006import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan63fc5e22022-08-04 22:04:10 +01007import client from "../../utils/client.js";
Skyler Greyda16adf2023-03-05 10:22:12 +00008import getEmojiByName from "../../utils/getEmojiByName.js";
pineafan4f164f32022-02-26 22:07:12 +00009
10const command = (builder: SlashCommandSubcommandBuilder) =>
11 builder
pineafan63fc5e22022-08-04 22:04:10 +010012 .setName("suggest")
13 .setDescription("Sends a suggestion to the developers")
Skyler Grey75ea9172022-08-06 10:22:23 +010014 .addStringOption((option) =>
Skyler Grey11236ba2022-08-08 21:13:33 +010015 option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
Skyler Grey75ea9172022-08-06 10:22:23 +010016 );
pineafan4f164f32022-02-26 22:07:12 +000017
pineafanbd02b4a2022-08-05 22:01:38 +010018const callback = async (interaction: CommandInteraction): Promise<void> => {
Skyler Greyda16adf2023-03-05 10:22:12 +000019 await interaction.guild?.members.fetch(interaction.member!.user.id);
pineafan63fc5e22022-08-04 22:04:10 +010020 const { renderUser } = client.logger;
PineaFan538d3752023-01-12 21:48:23 +000021 const suggestion = interaction.options.get("suggestion")?.value as string;
Skyler Greyda16adf2023-03-05 10:22:12 +000022 await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
pineafan63fc5e22022-08-04 22:04:10 +010023 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010024 .setEmoji("ICONS.OPP.ADD")
25 .setTitle("Suggest")
Skyler Grey75ea9172022-08-06 10:22:23 +010026 .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 )
pineafan377794f2022-04-18 19:01:01 +010030 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010031 .setInverted(true)
PineaFan0d06edc2023-01-17 22:10:31 +000032 .setFailedMessage("Your suggestion was deleted", "Success", "ICONS.ADD")
PineaFan1dee28f2023-01-16 22:09:07 +000033 .send(true);
PineaFan0d06edc2023-01-17 22:10:31 +000034 if (confirmation.cancelled || !confirmation.success) return;
35 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
36 embeds: [
37 new EmojiEmbed()
38 .setTitle("Suggestion")
39 .setDescription(
Skyler Greyda16adf2023-03-05 10:22:12 +000040 `**From:** ${renderUser(
41 interaction.member!.user as Discord.User
42 )}\n**Suggestion:**\n> ${suggestion}\n\n` +
43 `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`
PineaFan0d06edc2023-01-17 22:10:31 +000044 )
45 .setStatus("Warning")
Skyler Greyda16adf2023-03-05 10:22:12 +000046 ],
47 components: [
48 new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
49 new Discord.ButtonBuilder()
50 .setCustomId("suggestionAccept")
51 .setLabel("Accept")
52 .setStyle(ButtonStyle.Secondary)
53 .setEmoji(getEmojiByName("ICONS.ADD", "id")),
54 new Discord.ButtonBuilder()
55 .setCustomId("suggestionDeny")
56 .setLabel("Delete")
57 .setStyle(ButtonStyle.Secondary)
58 .setEmoji(getEmojiByName("ICONS.REMOVE", "id"))
59 )
60 ]
PineaFan0d06edc2023-01-17 22:10:31 +000061 });
62 await interaction.editReply({
63 embeds: [
64 new EmojiEmbed()
65 .setEmoji("ICONS.ADD")
66 .setTitle("Suggest")
67 .setDescription("Your suggestion was sent successfully")
68 .setStatus("Success")
69 ],
70 components: []
71 });
pineafan63fc5e22022-08-04 22:04:10 +010072};
pineafan4f164f32022-02-26 22:07:12 +000073
pineafan4f164f32022-02-26 22:07:12 +000074export { command };
75export { callback };