blob: a75e8a07af9ff16bdd92f0971d43b2fcd8a5557f [file] [log] [blame]
PineaFan538d3752023-01-12 21:48:23 +00001import type { CommandInteraction } from "discord.js";
2import type Discord from "discord.js";
PineaFan64486c42022-12-28 09:21:04 +00003import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
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) =>
Skyler Grey11236ba2022-08-08 21:13:33 +010013 option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
Skyler Grey75ea9172022-08-06 10:22:23 +010014 );
pineafan4f164f32022-02-26 22:07:12 +000015
pineafanbd02b4a2022-08-05 22:01:38 +010016const callback = async (interaction: CommandInteraction): Promise<void> => {
PineaFan538d3752023-01-12 21:48:23 +000017 await interaction.guild?.members.fetch(interaction.member!.user.id)
pineafan63fc5e22022-08-04 22:04:10 +010018 const { renderUser } = client.logger;
PineaFan538d3752023-01-12 21:48:23 +000019 const suggestion = interaction.options.get("suggestion")?.value as string;
pineafan63fc5e22022-08-04 22:04:10 +010020 const confirmation = await new confirmationMessage(interaction)
pineafan377794f2022-04-18 19:01:01 +010021 .setEmoji("ICONS.OPP.ADD")
22 .setTitle("Suggest")
Skyler Grey75ea9172022-08-06 10:22:23 +010023 .setDescription(
24 `**Suggestion:**\n> ${suggestion}\n` +
25 "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
26 )
pineafan377794f2022-04-18 19:01:01 +010027 .setColor("Danger")
PineappleFan19b002b2022-05-19 11:54:01 +010028 .setInverted(true)
pineafan63fc5e22022-08-04 22:04:10 +010029 .send();
30 if (confirmation.cancelled) return;
pineafan377794f2022-04-18 19:01:01 +010031 if (confirmation.success) {
Skyler Grey11236ba2022-08-08 21:13:33 +010032 await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
pineafane625d782022-05-09 18:04:32 +010033 embeds: [
pineafan4edb7762022-06-26 19:21:04 +010034 new EmojiEmbed()
pineafan63fc5e22022-08-04 22:04:10 +010035 .setTitle("Suggestion")
Skyler Grey75ea9172022-08-06 10:22:23 +010036 .setDescription(
PineaFan538d3752023-01-12 21:48:23 +000037 `**From:** ${renderUser(interaction.member!.user as Discord.User)}\n**Suggestion:**\n> ${suggestion}`
Skyler Grey75ea9172022-08-06 10:22:23 +010038 )
pineafane625d782022-05-09 18:04:32 +010039 .setStatus("Danger")
40 .setEmoji("NUCLEUS.LOGO")
41 ]
pineafan63fc5e22022-08-04 22:04:10 +010042 });
Skyler Grey75ea9172022-08-06 10:22:23 +010043 await interaction.editReply({
44 embeds: [
45 new EmojiEmbed()
46 .setEmoji("ICONS.ADD")
47 .setTitle("Suggest")
48 .setDescription("Your suggestion was sent successfully")
49 .setStatus("Success")
50 ],
51 components: []
52 });
pineafan377794f2022-04-18 19:01:01 +010053 } else {
Skyler Grey75ea9172022-08-06 10:22:23 +010054 await interaction.editReply({
55 embeds: [
56 new EmojiEmbed()
57 .setEmoji("ICONS.OPP.ADD")
58 .setTitle("Suggest")
59 .setDescription("No changes were made")
60 .setStatus("Danger")
61 ],
62 components: []
63 });
pineafan377794f2022-04-18 19:01:01 +010064 }
pineafan63fc5e22022-08-04 22:04:10 +010065};
pineafan4f164f32022-02-26 22:07:12 +000066
PineaFan64486c42022-12-28 09:21:04 +000067const check = (_interaction: CommandInteraction) => {
pineafan4f164f32022-02-26 22:07:12 +000068 return true;
pineafan63fc5e22022-08-04 22:04:10 +010069};
pineafan4f164f32022-02-26 22:07:12 +000070
71export { command };
72export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010073export { check };