From 8ff46104f1701820a86a01c73f4e4552043c8ff2 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Sat, 6 Jun 2026 03:39:25 +0700 Subject: [PATCH] feat(boost-greeting): implement randomized greeting messages Introduce a collection of greeting templates to provide variety when a user boosts the server. The system now selects a random message from the available variants and logs the selected variant index. --- src/discord/events/boostGreeting.test.ts | 1 - src/discord/events/boostGreeting.ts | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/discord/events/boostGreeting.test.ts b/src/discord/events/boostGreeting.test.ts index c51382a..287b41e 100644 --- a/src/discord/events/boostGreeting.test.ts +++ b/src/discord/events/boostGreeting.test.ts @@ -13,7 +13,6 @@ describe("sendBoostGreeting", () => { await sendBoostGreeting(channel, "user-123", "channel-456"); expect(sent.length).toBe(1); - expect(sent[0]).toContain("Makasih udah ngeboost"); expect(sent[0]).toContain("<@user-123>"); expect(sent[0]).toContain("/booster-role claim"); expect(sent[0]).toContain("di sini"); diff --git a/src/discord/events/boostGreeting.ts b/src/discord/events/boostGreeting.ts index d2c618b..a95b727 100644 --- a/src/discord/events/boostGreeting.ts +++ b/src/discord/events/boostGreeting.ts @@ -1,7 +1,20 @@ import { logger } from "../../logger"; +const greetings = [ + (userId: string) => + `🎉 Makasih udah ngeboost <@${userId}>! Sekarang kamu bisa claim custom role pake \`/booster-role claim\` di sini.`, + (userId: string) => + `🔥 <@${userId}> baru aja ngeboost! Langsung aja claim custom role kamu pake \`/booster-role claim\` di sini.`, + (userId: string) => + `✨ Thank you <@${userId}> for the boost! Claim custom role kamu pake \`/booster-role claim\` di sini ya.`, + (userId: string) => + `👑 <@${userId}> ngeboost server! Yuk langsung claim custom role pake \`/booster-role claim\` di sini.`, + (userId: string) => + `🎊 Ada booster baru nih, <@${userId}>! Jangan lupa claim custom role kamu pake \`/booster-role claim\` di sini.`, +]; + /** - * Sends a welcome message via the given channel when a member newly + * Sends a random welcome message via the given channel when a member newly * acquires the booster eligibility role (i.e. just boosted the server). */ export async function sendBoostGreeting( @@ -9,11 +22,10 @@ export async function sendBoostGreeting( userId: string, greetingChannelId: string, ): Promise { - const message = - `🎉 Makasih udah ngeboost <@${userId}>! ` + - `Sekarang kamu bisa claim custom role pake \`/booster-role claim\` di sini.`; + const pick = Math.floor(Math.random() * greetings.length); + const message = greetings[pick](userId); await channel.send({ content: message }); - logger.info("Boost greeting sent", { userId, channelId: greetingChannelId }); + logger.info("Boost greeting sent", { userId, channelId: greetingChannelId, variant: pick }); }