blob: de0e69b2d21fa27a57ed812336d3421e7b948751 [file] [log] [blame]
PineaFan0d06edc2023-01-17 22:10:31 +00001import { LoadingEmbed } from '../../utils/defaults.js';
PineaFan1dee28f2023-01-16 22:09:07 +00002import { ButtonStyle, CommandInteraction } from "discord.js";
3import Discord from "discord.js";
PineaFan64486c42022-12-28 09:21:04 +00004import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
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";
PineaFan1dee28f2023-01-16 22:09:07 +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> => {
PineaFan538d3752023-01-12 21:48:23 +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;
PineaFan1dee28f2023-01-16 22:09:07 +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(
40 `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}\n\n` +
41 `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`,
42 )
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 )]
56 });
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 });
pineafan63fc5e22022-08-04 22:04:10 +010067};
pineafan4f164f32022-02-26 22:07:12 +000068
PineaFan0d06edc2023-01-17 22:10:31 +000069const check = () => {
pineafan4f164f32022-02-26 22:07:12 +000070 return true;
pineafan63fc5e22022-08-04 22:04:10 +010071};
pineafan4f164f32022-02-26 22:07:12 +000072
73export { command };
74export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010075export { check };