diff options
| author | Fuwn <[email protected]> | 2025-09-13 16:12:15 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-13 16:12:15 -0700 |
| commit | e057df4be5fce92b52a44961a10dfc36c4f1189c (patch) | |
| tree | 33b0b18b7f291bf849056bd49b125d4f68d42ff9 /src/server.ts | |
| parent | feat: Colour role distribution command (diff) | |
| download | umabotdiscord-e057df4be5fce92b52a44961a10dfc36c4f1189c.tar.xz umabotdiscord-e057df4be5fce92b52a44961a10dfc36c4f1189c.zip | |
refactor(server): Move role distribution embed to embeds module
Diffstat (limited to 'src/server.ts')
| -rw-r--r-- | src/server.ts | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/server.ts b/src/server.ts index ce7e8c7..2252ea7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -16,7 +16,11 @@ import { } from "./reddit.ts"; import type { TimePeriod } from "./discord/types.ts"; import type { Environment, DiscordEmbed } from "./discord/interfaces.ts"; -import { createPostEmbed, createComplaintEmbed } from "./discord/embeds.ts"; +import { + createPostEmbed, + createComplaintEmbed, + createRoleDistributionEmbed, +} from "./discord/embeds.ts"; import { JSONResponse } from "./discord/responses.ts"; import { verifyDiscordRequest } from "./discord/verification.ts"; @@ -432,23 +436,7 @@ router.post("/", async (request: Request, environment: Environment) => { }, }); - const totalMembers = roleDistribution.reduce( - (sum, role) => sum + role.count, - 0, - ); - const embed: DiscordEmbed = { - title: "🎨 Colour Role Distribution", - description: `Total members with colour roles: **${totalMembers}**`, - color: 0x5865F2, - fields: roleDistribution.map((role) => ({ - name: role.name, - value: `${role.count} member${role.count !== 1 ? "s" : ""}`, - inline: true, - })), - footer: { - text: "Sorted by member count (highest to lowest)", - }, - }; + const embed = createRoleDistributionEmbed(roleDistribution); return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, |