blob: 238e7d50c941e8a5ce9bc710057dc595dc26c338 [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")
12 .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true));
pineafan4f164f32022-02-26 22:07:12 +000013
pineafan4edb7762022-06-26 19:21:04 +010014const callback = async (interaction: CommandInteraction): Promise<any> => {
pineafan63fc5e22022-08-04 22:04:10 +010015 const { renderUser } = client.logger;
16 const suggestion = interaction.options.getString("suggestion");
17 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010018 .setEmoji("ICONS.OPP.ADD")
19 .setTitle("Suggest")
20 .setDescription(`**Suggestion:**\n> ${suggestion}\n`
pineafan63fc5e22022-08-04 22:04:10 +010021 + "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?")
pineafan377794f2022-04-18 19:01:01 +010022 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010023 .setInverted(true)
pineafan63fc5e22022-08-04 22:04:10 +010024 .send();
25 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010026 if (confirmation.success) {
pineafan63fc5e22022-08-04 22:04:10 +010027 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010028 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010029 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010030 .setTitle("Suggestion")
pineafane625d782022-05-09 18:04:32 +010031 .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
32 .setStatus("Danger")
33 .setEmoji("NUCLEUS.LOGO")
34 ]
pineafan63fc5e22022-08-04 22:04:10 +010035 });
pineafan4edb7762022-06-26 19:21:04 +010036 await interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010037 .setEmoji("ICONS.ADD")
pineafan63fc5e22022-08-04 22:04:10 +010038 .setTitle("Suggest")
pineafan377794f2022-04-18 19:01:01 +010039 .setDescription("Your suggestion was sent successfully")
40 .setStatus("Success")
pineafan63fc5e22022-08-04 22:04:10 +010041 ], components: []});
pineafan377794f2022-04-18 19:01:01 +010042 } else {
pineafan4edb7762022-06-26 19:21:04 +010043 await interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010044 .setEmoji("ICONS.OPP.ADD")
pineafan63fc5e22022-08-04 22:04:10 +010045 .setTitle("Suggest")
pineafan377794f2022-04-18 19:01:01 +010046 .setDescription("No changes were made")
47 .setStatus("Danger")
pineafan63fc5e22022-08-04 22:04:10 +010048 ], components: []});
pineafan377794f2022-04-18 19:01:01 +010049 }
pineafan63fc5e22022-08-04 22:04:10 +010050};
pineafan4f164f32022-02-26 22:07:12 +000051
52const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
53 return true;
pineafan63fc5e22022-08-04 22:04:10 +010054};
pineafan4f164f32022-02-26 22:07:12 +000055
56export { command };
57export { callback };
58export { check };