Move terminal.service.ts and prune.service.ts entirely to bot/modules/ since they are Discord-specific. Split lootdrop.service.ts: pure logic (activity tracking, DB ops, claim) stays in shared/, Discord operations (message sending, channel interactions) move to bot/modules/economy/ lootdrop.handler.ts. Move effect registry/handlers/types from bot/ to shared/modules/inventory/ since they contain no Discord.js imports and are needed by inventory.service.ts in shared. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { ButtonInteraction } from "discord.js";
|
|
import { lootdropService } from "@shared/modules/economy/lootdrop.service";
|
|
import { UserError } from "@shared/lib/errors";
|
|
import { getLootdropClaimedMessage } from "./lootdrop.view";
|
|
import { terminalService } from "@modules/system/terminal.service";
|
|
|
|
export async function handleLootdropInteraction(interaction: ButtonInteraction) {
|
|
if (interaction.customId === "lootdrop_claim") {
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
const result = await lootdropService.tryClaim(interaction.message.id, interaction.user.id, interaction.user.username);
|
|
|
|
if (!result.success) {
|
|
throw new UserError(result.error || "Failed to claim.");
|
|
}
|
|
|
|
// Update terminal display after successful claim
|
|
terminalService.update();
|
|
|
|
await interaction.editReply({
|
|
content: `🎉 You successfully claimed **${result.amount} ${result.currency}**!`
|
|
});
|
|
|
|
const { content, files, components } = await getLootdropClaimedMessage(
|
|
interaction.user.id,
|
|
interaction.user.username,
|
|
interaction.user.displayAvatarURL({ extension: "png" }),
|
|
result.amount || 0,
|
|
result.currency || "Coins"
|
|
);
|
|
|
|
await interaction.message.edit({
|
|
content,
|
|
embeds: [],
|
|
files,
|
|
components
|
|
});
|
|
}
|
|
}
|