Skip to content

Commit bd0e78f

Browse files
authored
Geschenk Embeds mit Feldern ausschmücken (#489)
* Add loot opener and rarity as fields to embed * explicitly filter loot attributes for rarities * remove unrequired template string * Field Tweaks * Update ehren word * remove rarity from title
1 parent 3c2a647 commit bd0e78f

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/service/lootDrop.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { randomEntry, randomEntryWeighted } from "@/utils/arrayUtils.js";
2121

2222
import * as lootService from "@/service/loot.js";
2323
import {
24+
LootAttributeClassId,
2425
LootAttributeKindId,
2526
lootAttributeTemplates,
2627
LootKindId,
@@ -157,12 +158,11 @@ export async function postLootDrop(
157158

158159
const template = randomEntryWeighted(lootTemplates, weights);
159160

160-
const rarityWeights = lootAttributeTemplates.map(a => a.initialDropWeight ?? 0);
161+
const rarities = lootAttributeTemplates.filter(a => a.classId === LootAttributeClassId.RARITY);
162+
const rarityWeights = rarities.map(a => a.initialDropWeight ?? 0);
161163

162164
const initialAttribute =
163-
template.id === LootKindId.NICHTS
164-
? null
165-
: randomEntryWeighted(lootAttributeTemplates, rarityWeights);
165+
template.id === LootKindId.NICHTS ? null : randomEntryWeighted(rarities, rarityWeights);
166166

167167
const claimedLoot = await lootService.createLoot(
168168
template,
@@ -197,15 +197,31 @@ export async function postLootDrop(
197197
await message.edit({
198198
embeds: [
199199
{
200-
title: `Das Geschenk enthielt: ${template.titleText} ${initialAttribute?.shortDisplay ?? ""}`.trim(),
200+
title: `Das Geschenk enthielt: ${template.titleText}`,
201201
description: template.dropDescription,
202202
image: attachment
203203
? {
204204
url: "attachment://opened.gif",
205205
}
206206
: undefined,
207+
fields: [
208+
{
209+
name: "🎉 Ehrenwerter Empfänger",
210+
value: winner.toString(),
211+
inline: true,
212+
},
213+
...(initialAttribute
214+
? [
215+
{
216+
name: "✨ Rarität",
217+
value: `${initialAttribute.shortDisplay} ${initialAttribute.displayName}`.trim(),
218+
inline: true,
219+
},
220+
]
221+
: []),
222+
],
207223
footer: {
208-
text: `🎉 ${winner.displayName} hat das Geschenk geöffnet\n${messages.join("\n")}`.trim(),
224+
text: messages.join("\n").trim(),
209225
},
210226
},
211227
],

0 commit comments

Comments
 (0)