blob: d1d6a03c926c0f97779248882bcad7d2555447d8 [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";
5import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan4f164f32022-02-26 22:07:12 +00006
7const command = (builder: SlashCommandSubcommandBuilder) =>
8 builder
9 .setName("suggest")
10 .setDescription("Sends a suggestion to the developers")
pineafan377794f2022-04-18 19:01:01 +010011 .addStringOption(option => option.setName("suggestion").setDescription("The suggestion to send").setRequired(true))
pineafan4f164f32022-02-26 22:07:12 +000012
pineafan377794f2022-04-18 19:01:01 +010013const callback = async (interaction: CommandInteraction) => {
pineafane625d782022-05-09 18:04:32 +010014 // @ts-ignore
pineafan377794f2022-04-18 19:01:01 +010015 const { renderUser } = interaction.client.logger
pineafane625d782022-05-09 18:04:32 +010016 let suggestion = interaction.options.getString("suggestion");
pineafan377794f2022-04-18 19:01:01 +010017 let confirmation = await new confirmationMessage(interaction)
18 .setEmoji("ICONS.OPP.ADD")
19 .setTitle("Suggest")
20 .setDescription(`**Suggestion:**\n> ${suggestion}\n`
21 + `Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?`)
22 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010023 .setInverted(true)
pineafan377794f2022-04-18 19:01:01 +010024 .send()
25 if (confirmation.success) {
26 await (interaction.client.channels.cache.get('955161206459600976') as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010027 embeds: [
28 new generateEmojiEmbed()
29 .setTitle(`Suggestion`)
30 .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
31 .setStatus("Danger")
32 .setEmoji("NUCLEUS.LOGO")
33 ]
34 })
pineafan377794f2022-04-18 19:01:01 +010035 await interaction.editReply({embeds: [new generateEmojiEmbed()
36 .setEmoji("ICONS.ADD")
37 .setTitle(`Suggest`)
38 .setDescription("Your suggestion was sent successfully")
39 .setStatus("Success")
40 ], components: []})
41 } else {
42 await interaction.editReply({embeds: [new generateEmojiEmbed()
43 .setEmoji("ICONS.OPP.ADD")
44 .setTitle(`Suggest`)
45 .setDescription("No changes were made")
46 .setStatus("Danger")
47 ], components: []})
48 }
pineafan4f164f32022-02-26 22:07:12 +000049}
50
51const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
52 return true;
53}
54
55export { command };
56export { callback };
57export { check };