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