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.
This commit is contained in:
MythEclipse
2026-06-06 03:39:25 +07:00
parent 97442265ba
commit 8ff46104f1
2 changed files with 17 additions and 6 deletions
-1
View File
@@ -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");
+17 -5
View File
@@ -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<void> {
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 });
}