Working on viewas
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index 62e9609..a22045b 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -5,7 +5,9 @@
import createTranscript from "../premium/createTranscript.js";
import type { Interaction } from "discord.js";
+import type Discord from "discord.js";
import type { NucleusClient } from "../utils/client.js";
+import EmojiEmbed from "../utils/generateEmojiEmbed.js";
export const event = "interactionCreate";
@@ -18,20 +20,29 @@
case "createticket": { return await create(interaction); }
case "closeticket": { return await close(interaction); }
case "createtranscript": { return await createTranscript(interaction); }
+ case "suggestionAccept": { return await modifySuggestion(interaction, true); }
+ case "suggestionDeny": { return await modifySuggestion(interaction, false); }
}
- // } else if (interaction.type === "APPLICATION_COMMAND_AUTOCOMPLETE") {
- // const int = interaction as AutocompleteInteraction;
- // switch (`${int.commandName} ${int.options.getSubcommandGroup(false)} ${int.options.getSubcommand(false)}`) {
- // case "settings null stats": {
- // return int.respond(generateStatsChannelAutocomplete(int.options.getString("name") ?? ""));
- // }
- // case "settings null welcome": {
- // return int.respond(generateWelcomeMessageAutocomplete(int.options.getString("message") ?? ""));
- // }
- // }
}
}
+async function modifySuggestion(interaction: Discord.MessageComponentInteraction, accept: boolean) {
+ const message = await interaction.message;
+ await message.fetch();
+ if (message.embeds.length === 0) return;
+ const embed = message.embeds[0];
+ const newColour = accept ? "Success" : "Danger";
+ const footer = {text: `Suggestion ${accept ? "accepted" : "denied"} by ${interaction.user.tag}`, iconURL: interaction.user.displayAvatarURL()};
+
+ const newEmbed = new EmojiEmbed()
+ .setTitle(embed!.title!)
+ .setDescription(embed!.description!)
+ .setFooter(footer)
+ .setStatus(newColour);
+
+ await interaction.update({embeds: [newEmbed], components: []});
+}
+
export async function callback(_client: NucleusClient, interaction: Interaction) {
await interactionCreate(interaction);
}