refactor: Extract UI component creation into new view files for lootdrop, trade, item wizard, and enrollment.

This commit is contained in:
syntaxbullet
2025-12-24 11:36:19 +01:00
parent eaf97572a4
commit 5c36b9be25
10 changed files with 341 additions and 244 deletions

View File

@@ -1,8 +1,9 @@
import { Message, TextChannel, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } from "discord.js";
import { Message, TextChannel } from "discord.js";
import { getLootdropMessage } from "./lootdrop.view";
import { config } from "@/lib/config";
import { economyService } from "./economy.service";
import { createBaseEmbed } from "@lib/embeds";
import { lootdrops } from "@/db/schema";
import { DrizzleClient } from "@/lib/DrizzleClient";
@@ -92,19 +93,10 @@ class LootdropService {
const reward = Math.floor(Math.random() * (max - min + 1)) + min;
const currency = config.lootdrop.reward.currency;
const embed = createBaseEmbed("💰 LOOTDROP!", `A lootdrop has appeared! Click the button below to claim **${reward} ${currency}**!`, "#FFD700");
const claimButton = new ButtonBuilder()
.setCustomId("lootdrop_claim")
.setLabel("CLAIM REWARD")
.setStyle(ButtonStyle.Success)
.setEmoji("💸");
const row = new ActionRowBuilder<ButtonBuilder>()
.addComponents(claimButton);
const { embeds, components } = getLootdropMessage(reward, currency);
try {
const message = await channel.send({ embeds: [embed], components: [row] });
const message = await channel.send({ embeds, components });
// Persist to DB
await DrizzleClient.insert(lootdrops).values({