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:
@@ -13,7 +13,6 @@ describe("sendBoostGreeting", () => {
|
|||||||
await sendBoostGreeting(channel, "user-123", "channel-456");
|
await sendBoostGreeting(channel, "user-123", "channel-456");
|
||||||
|
|
||||||
expect(sent.length).toBe(1);
|
expect(sent.length).toBe(1);
|
||||||
expect(sent[0]).toContain("Makasih udah ngeboost");
|
|
||||||
expect(sent[0]).toContain("<@user-123>");
|
expect(sent[0]).toContain("<@user-123>");
|
||||||
expect(sent[0]).toContain("/booster-role claim");
|
expect(sent[0]).toContain("/booster-role claim");
|
||||||
expect(sent[0]).toContain("di sini");
|
expect(sent[0]).toContain("di sini");
|
||||||
|
|||||||
@@ -1,7 +1,20 @@
|
|||||||
import { logger } from "../../logger";
|
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).
|
* acquires the booster eligibility role (i.e. just boosted the server).
|
||||||
*/
|
*/
|
||||||
export async function sendBoostGreeting(
|
export async function sendBoostGreeting(
|
||||||
@@ -9,11 +22,10 @@ export async function sendBoostGreeting(
|
|||||||
userId: string,
|
userId: string,
|
||||||
greetingChannelId: string,
|
greetingChannelId: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const message =
|
const pick = Math.floor(Math.random() * greetings.length);
|
||||||
`🎉 Makasih udah ngeboost <@${userId}>! ` +
|
const message = greetings[pick](userId);
|
||||||
`Sekarang kamu bisa claim custom role pake \`/booster-role claim\` di sini.`;
|
|
||||||
|
|
||||||
await channel.send({ content: message });
|
await channel.send({ content: message });
|
||||||
|
|
||||||
logger.info("Boost greeting sent", { userId, channelId: greetingChannelId });
|
logger.info("Boost greeting sent", { userId, channelId: greetingChannelId, variant: pick });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user