Skip to content

Commit cb2c388

Browse files
committed
Multiple embeds in a single message
1 parent 878692d commit cb2c388

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

src/service/lootDegradation.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Snowflake, userMention } from "discord.js";
1+
import { type BaseMessageOptions, type Snowflake, userMention } from "discord.js";
22
import type { BotContext } from "@/context.js";
33

44
import * as time from "@/utils/time.js";
@@ -137,24 +137,19 @@ export async function runHalfLife(context: BotContext) {
137137
replacedStats.set(replaced.winnerId, replacedStats.getOrInsert(replaced.winnerId, 0) + 1);
138138
}
139139

140-
const listFormatter = new Intl.ListFormat("de", {
141-
style: "short",
142-
type: "conjunction",
143-
});
140+
logger.info({ replacedStats }, "replacedStats");
144141

145-
const decayStats = replacedStats
146-
.entries()
147-
.toArray()
148-
.map(([user, count]) => `${count}x von ${userMention(user)}`);
142+
type Embed = NonNullable<BaseMessageOptions["embeds"]>[number];
149143

150-
logger.info({ decayStats }, "decayStats");
144+
const embeds: Embed[] = [];
145+
for (const [user, count] of replacedStats.entries()) {
146+
embeds.push({
147+
description: `:radioactive: ${count}x Müll von ${userMention(user)} ist zu einem Stück Blei zerfallen. :radioactive:`,
148+
});
149+
}
151150

152151
await context.textChannels.hauptchat.send({
153-
embeds: [
154-
{
155-
description: `:radioactive: Der Müll ${decayStats.length === 1 ? "eines Users" : "einiger User"} ist zu einem Stück Blei zerfallen: ${listFormatter.format(decayStats)}. :radioactive:`,
156-
},
157-
],
152+
embeds,
158153
allowedMentions: {
159154
users: replacedStats.keys().toArray(),
160155
},

0 commit comments

Comments
 (0)