blob: 49c80fb26e107ff1cab079e02ab19ff945203818 [file] [log] [blame]
pineafan377794f2022-04-18 19:01:01 +01001import Discord, { CommandInteraction } from "discord.js";
PineaFan64486c42022-12-28 09:21:04 +00002import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
pineafan377794f2022-04-18 19:01:01 +01003import confirmationMessage from "../../utils/confirmationMessage.js";
pineafan4edb7762022-06-26 19:21:04 +01004import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan63fc5e22022-08-04 22:04:10 +01005import client from "../../utils/client.js";
pineafan4f164f32022-02-26 22:07:12 +00006
7const command = (builder: SlashCommandSubcommandBuilder) =>
8 builder
pineafan63fc5e22022-08-04 22:04:10 +01009 .setName("suggest")
10 .setDescription("Sends a suggestion to the developers")
Skyler Grey75ea9172022-08-06 10:22:23 +010011 .addStringOption((option) =>
Skyler Grey11236ba2022-08-08 21:13:33 +010012 option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
Skyler Grey75ea9172022-08-06 10:22:23 +010013 );
pineafan4f164f32022-02-26 22:07:12 +000014
pineafanbd02b4a2022-08-05 22:01:38 +010015const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan63fc5e22022-08-04 22:04:10 +010016 const { renderUser } = client.logger;
17 const suggestion = interaction.options.getString("suggestion");
18 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010019 .setEmoji("ICONS.OPP.ADD")
20 .setTitle("Suggest")
Skyler Grey75ea9172022-08-06 10:22:23 +010021 .setDescription(
22 `**Suggestion:**\n> ${suggestion}\n` +
23 "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
24 )
pineafan377794f2022-04-18 19:01:01 +010025 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010026 .setInverted(true)
pineafan63fc5e22022-08-04 22:04:10 +010027 .send();
28 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010029 if (confirmation.success) {
Skyler Grey11236ba2022-08-08 21:13:33 +010030 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010031 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010032 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010033 .setTitle("Suggestion")
Skyler Grey75ea9172022-08-06 10:22:23 +010034 .setDescription(
Skyler Grey11236ba2022-08-08 21:13:33 +010035 `**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`
Skyler Grey75ea9172022-08-06 10:22:23 +010036 )
pineafane625d782022-05-09 18:04:32 +010037 .setStatus("Danger")
38 .setEmoji("NUCLEUS.LOGO")
39 ]
pineafan63fc5e22022-08-04 22:04:10 +010040 });
Skyler Grey75ea9172022-08-06 10:22:23 +010041 await interaction.editReply({
42 embeds: [
43 new EmojiEmbed()
44 .setEmoji("ICONS.ADD")
45 .setTitle("Suggest")
46 .setDescription("Your suggestion was sent successfully")
47 .setStatus("Success")
48 ],
49 components: []
50 });
pineafan377794f2022-04-18 19:01:01 +010051 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010052 await interaction.editReply({
53 embeds: [
54 new EmojiEmbed()
55 .setEmoji("ICONS.OPP.ADD")
56 .setTitle("Suggest")
57 .setDescription("No changes were made")
58 .setStatus("Danger")
59 ],
60 components: []
61 });
pineafan377794f2022-04-18 19:01:01 +010062 }
pineafan63fc5e22022-08-04 22:04:10 +010063};
pineafan4f164f32022-02-26 22:07:12 +000064
PineaFan64486c42022-12-28 09:21:04 +000065const check = (_interaction: CommandInteraction) => {
pineafan4f164f32022-02-26 22:07:12 +000066 return true;
pineafan63fc5e22022-08-04 22:04:10 +010067};
pineafan4f164f32022-02-26 22:07:12 +000068
69export { command };
70export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010071export { check };