blob: 0f4050126eb92bd51ee0a9ee8180fab998c23a1c [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) =>
13 option
14 .setName("suggestion")
15 .setDescription("The suggestion to send")
16 .setRequired(true)
17 );
pineafan4f164f32022-02-26 22:07:12 +000018
pineafanbd02b4a2022-08-05 22:01:38 +010019const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan63fc5e22022-08-04 22:04:10 +010020 const { renderUser } = client.logger;
21 const suggestion = interaction.options.getString("suggestion");
22 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010023 .setEmoji("ICONS.OPP.ADD")
24 .setTitle("Suggest")
Skyler Grey75ea9172022-08-06 10:22:23 +010025 .setDescription(
26 `**Suggestion:**\n> ${suggestion}\n` +
27 "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
28 )
pineafan377794f2022-04-18 19:01:01 +010029 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010030 .setInverted(true)
pineafan63fc5e22022-08-04 22:04:10 +010031 .send();
32 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010033 if (confirmation.success) {
Skyler Grey75ea9172022-08-06 10:22:23 +010034 await (
35 client.channels.cache.get(
36 "955161206459600976"
37 ) as Discord.TextChannel
38 ).send({
pineafane625d782022-05-09 18:04:32 +010039 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010040 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010041 .setTitle("Suggestion")
Skyler Grey75ea9172022-08-06 10:22:23 +010042 .setDescription(
43 `**From:** ${renderUser(
44 interaction.member.user
45 )}\n**Suggestion:**\n> ${suggestion}`
46 )
pineafane625d782022-05-09 18:04:32 +010047 .setStatus("Danger")
48 .setEmoji("NUCLEUS.LOGO")
49 ]
pineafan63fc5e22022-08-04 22:04:10 +010050 });
Skyler Grey75ea9172022-08-06 10:22:23 +010051 await interaction.editReply({
52 embeds: [
53 new EmojiEmbed()
54 .setEmoji("ICONS.ADD")
55 .setTitle("Suggest")
56 .setDescription("Your suggestion was sent successfully")
57 .setStatus("Success")
58 ],
59 components: []
60 });
pineafan377794f2022-04-18 19:01:01 +010061 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010062 await interaction.editReply({
63 embeds: [
64 new EmojiEmbed()
65 .setEmoji("ICONS.OPP.ADD")
66 .setTitle("Suggest")
67 .setDescription("No changes were made")
68 .setStatus("Danger")
69 ],
70 components: []
71 });
pineafan377794f2022-04-18 19:01:01 +010072 }
pineafan63fc5e22022-08-04 22:04:10 +010073};
pineafan4f164f32022-02-26 22:07:12 +000074
Skyler Grey75ea9172022-08-06 10:22:23 +010075const check = (
76 _interaction: CommandInteraction,
77 _defaultCheck: WrappedCheck
78) => {
pineafan4f164f32022-02-26 22:07:12 +000079 return true;
pineafan63fc5e22022-08-04 22:04:10 +010080};
pineafan4f164f32022-02-26 22:07:12 +000081
82export { command };
83export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010084export { check };