blob: bdd55af74021fc69434a6969951efb11940d6b2c [file] [log] [blame]
pineafan377794f2022-04-18 19:01:01 +01001import Discord, { CommandInteraction } from "discord.js";
pineafan4f164f32022-02-26 22:07:12 +00002import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
3import { WrappedCheck } from "jshaiku";
pineafan377794f2022-04-18 19:01:01 +01004import confirmationMessage from "../../utils/confirmationMessage.js";
pineafan4edb7762022-06-26 19:21:04 +01005import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan63fc5e22022-08-04 22:04:10 +01006import client from "../../utils/client.js";
pineafan4f164f32022-02-26 22:07:12 +00007
8const command = (builder: SlashCommandSubcommandBuilder) =>
9 builder
pineafan63fc5e22022-08-04 22:04:10 +010010 .setName("suggest")
11 .setDescription("Sends a suggestion to the developers")
Skyler Grey75ea9172022-08-06 10:22:23 +010012 .addStringOption((option) =>
Skyler Grey11236ba2022-08-08 21:13:33 +010013 option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
Skyler Grey75ea9172022-08-06 10:22:23 +010014 );
pineafan4f164f32022-02-26 22:07:12 +000015
pineafanbd02b4a2022-08-05 22:01:38 +010016const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan63fc5e22022-08-04 22:04:10 +010017 const { renderUser } = client.logger;
18 const suggestion = interaction.options.getString("suggestion");
19 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010020 .setEmoji("ICONS.OPP.ADD")
21 .setTitle("Suggest")
Skyler Grey75ea9172022-08-06 10:22:23 +010022 .setDescription(
23 `**Suggestion:**\n> ${suggestion}\n` +
24 "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
25 )
pineafan377794f2022-04-18 19:01:01 +010026 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010027 .setInverted(true)
pineafan63fc5e22022-08-04 22:04:10 +010028 .send();
29 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010030 if (confirmation.success) {
Skyler Grey11236ba2022-08-08 21:13:33 +010031 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010032 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010033 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010034 .setTitle("Suggestion")
Skyler Grey75ea9172022-08-06 10:22:23 +010035 .setDescription(
Skyler Grey11236ba2022-08-08 21:13:33 +010036 `**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`
Skyler Grey75ea9172022-08-06 10:22:23 +010037 )
pineafane625d782022-05-09 18:04:32 +010038 .setStatus("Danger")
39 .setEmoji("NUCLEUS.LOGO")
40 ]
pineafan63fc5e22022-08-04 22:04:10 +010041 });
Skyler Grey75ea9172022-08-06 10:22:23 +010042 await interaction.editReply({
43 embeds: [
44 new EmojiEmbed()
45 .setEmoji("ICONS.ADD")
46 .setTitle("Suggest")
47 .setDescription("Your suggestion was sent successfully")
48 .setStatus("Success")
49 ],
50 components: []
51 });
pineafan377794f2022-04-18 19:01:01 +010052 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010053 await interaction.editReply({
54 embeds: [
55 new EmojiEmbed()
56 .setEmoji("ICONS.OPP.ADD")
57 .setTitle("Suggest")
58 .setDescription("No changes were made")
59 .setStatus("Danger")
60 ],
61 components: []
62 });
pineafan377794f2022-04-18 19:01:01 +010063 }
pineafan63fc5e22022-08-04 22:04:10 +010064};
pineafan4f164f32022-02-26 22:07:12 +000065
Skyler Grey11236ba2022-08-08 21:13:33 +010066const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
pineafan4f164f32022-02-26 22:07:12 +000067 return true;
pineafan63fc5e22022-08-04 22:04:10 +010068};
pineafan4f164f32022-02-26 22:07:12 +000069
70export { command };
71export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010072export { check };