refactor: Extract UI component creation into new view files for lootdrop, trade, item wizard, and enrollment.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle } from "discord.js";
|
||||
import { ButtonInteraction } from "discord.js";
|
||||
import { lootdropService } from "./lootdrop.service";
|
||||
import { createErrorEmbed, createSuccessEmbed, createBaseEmbed } from "@/lib/embeds";
|
||||
import { createErrorEmbed } from "@/lib/embeds";
|
||||
import { getLootdropClaimedMessage } from "./lootdrop.view";
|
||||
|
||||
export async function handleLootdropInteraction(interaction: ButtonInteraction) {
|
||||
if (interaction.customId === "lootdrop_claim") {
|
||||
@@ -17,21 +18,14 @@ export async function handleLootdropInteraction(interaction: ButtonInteraction)
|
||||
const originalEmbed = interaction.message.embeds[0];
|
||||
if (!originalEmbed) return;
|
||||
|
||||
const newEmbed = createBaseEmbed(originalEmbed.title || "💰 LOOTDROP!", `✅ Claimed by <@${interaction.user.id}> for **${result.amount} ${result.currency}**!`, "#00FF00");
|
||||
const { embeds, components } = getLootdropClaimedMessage(
|
||||
originalEmbed.title || "💰 LOOTDROP!",
|
||||
interaction.user.id,
|
||||
result.amount || 0,
|
||||
result.currency || "Coins"
|
||||
);
|
||||
|
||||
// Disable button
|
||||
// We reconstruct the button using builders for safety
|
||||
const newRow = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("lootdrop_claim_disabled")
|
||||
.setLabel("CLAIMED")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setEmoji("✅")
|
||||
.setDisabled(true)
|
||||
);
|
||||
|
||||
await interaction.message.edit({ embeds: [newEmbed], components: [newRow] });
|
||||
await interaction.message.edit({ embeds, components });
|
||||
|
||||
} else {
|
||||
await interaction.editReply({
|
||||
|
||||
Reference in New Issue
Block a user