blob: e31696b6d019e9a1010f9b7cdb893cebb7eeed51 [file] [log] [blame]
PineaFan1dee28f2023-01-16 22:09:07 +00001import { LoadingEmbed } from './../../utils/defaultEmbeds.js';
2import { 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)
PineaFan1dee28f2023-01-16 22:09:07 +000032 .send(true);
pineafan63fc5e22022-08-04 22:04:10 +010033 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010034 if (confirmation.success) {
Skyler Grey11236ba2022-08-08 21:13:33 +010035 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010036 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010037 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010038 .setTitle("Suggestion")
Skyler Grey75ea9172022-08-06 10:22:23 +010039 .setDescription(
PineaFan1dee28f2023-01-16 22:09:07 +000040 `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}\n\n` +
41 `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`,
Skyler Grey75ea9172022-08-06 10:22:23 +010042 )
PineaFan1dee28f2023-01-16 22:09:07 +000043 .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 )]
pineafan63fc5e22022-08-04 22:04:10 +010056 });
Skyler Grey75ea9172022-08-06 10:22:23 +010057 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 });
pineafan377794f2022-04-18 19:01:01 +010067 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010068 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 });
pineafan377794f2022-04-18 19:01:01 +010078 }
pineafan63fc5e22022-08-04 22:04:10 +010079};
pineafan4f164f32022-02-26 22:07:12 +000080
PineaFan64486c42022-12-28 09:21:04 +000081const check = (_interaction: CommandInteraction) => {
pineafan4f164f32022-02-26 22:07:12 +000082 return true;
pineafan63fc5e22022-08-04 22:04:10 +010083};
pineafan4f164f32022-02-26 22:07:12 +000084
85export { command };
86export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010087export { check };