blob: 0c596ff319f31b3f520f6b7ac3e50c39e4b8a36a [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";
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
pineafan4edb7762022-06-26 19:21:04 +010014const callback = async (interaction: CommandInteraction): Promise<any> => {
PineappleFanb3dd83c2022-06-17 10:53:48 +010015 const { renderUser } = 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()
pineafan02ba0232022-07-24 22:16:15 +010025 if (confirmation.cancelled) return
pineafan377794f2022-04-18 19:01:01 +010026 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: [
pineafan4edb7762022-06-26 19:21:04 +010029 new EmojiEmbed()
pineafane625d782022-05-09 18:04:32 +010030 .setTitle(`Suggestion`)
31 .setDescription(`**From:** ${renderUser(interaction.member.user)}\n**Suggestion:**\n> ${suggestion}`)
32 .setStatus("Danger")
33 .setEmoji("NUCLEUS.LOGO")
34 ]
35 })
pineafan4edb7762022-06-26 19:21:04 +010036 await interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010037 .setEmoji("ICONS.ADD")
38 .setTitle(`Suggest`)
39 .setDescription("Your suggestion was sent successfully")
40 .setStatus("Success")
41 ], components: []})
42 } 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")
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 };