2026-06-06 03:29:21 +07:00
|
|
|
import { logger } from "../../logger";
|
|
|
|
|
|
|
|
|
|
type GuildTextChannel = {
|
|
|
|
|
send(input: { content: string }): Promise<unknown>;
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-06 03:30:16 +07:00
|
|
|
type GuildMemberLike = {
|
2026-06-06 03:29:21 +07:00
|
|
|
id: string;
|
2026-06-06 03:30:16 +07:00
|
|
|
user?: { id: string };
|
2026-06-06 03:29:21 +07:00
|
|
|
guild: {
|
|
|
|
|
id: string;
|
|
|
|
|
channels: {
|
|
|
|
|
cache: {
|
|
|
|
|
get(channelId: string): GuildTextChannel | undefined;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-06 03:30:16 +07:00
|
|
|
* Sends a welcome message to the configured greeting channel.
|
|
|
|
|
* Call this after confirming the member newly gained the booster eligibility role.
|
2026-06-06 03:29:21 +07:00
|
|
|
*/
|
|
|
|
|
export async function sendBoostGreeting(
|
2026-06-06 03:30:16 +07:00
|
|
|
member: GuildMemberLike,
|
2026-06-06 03:29:21 +07:00
|
|
|
greetingChannelId: string,
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
const channel = member.guild.channels.cache.get(greetingChannelId);
|
2026-06-06 03:30:16 +07:00
|
|
|
|
2026-06-06 03:29:21 +07:00
|
|
|
if (!channel) {
|
2026-06-06 03:30:16 +07:00
|
|
|
logger.warn("Boost greeting channel not found", {
|
|
|
|
|
channelId: greetingChannelId,
|
|
|
|
|
guildId: member.guild.id,
|
|
|
|
|
});
|
2026-06-06 03:29:21 +07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-06 03:30:16 +07:00
|
|
|
const mention = member.user?.id ?? member.id;
|
|
|
|
|
const message =
|
|
|
|
|
`🎉 Thank you for boosting <@${mention}>! ` +
|
|
|
|
|
`You can now claim a custom role using \`/booster-role claim\` in <#${greetingChannelId}>.`;
|
|
|
|
|
|
|
|
|
|
await channel.send({ content: message });
|
2026-06-06 03:29:21 +07:00
|
|
|
|
|
|
|
|
logger.info("Boost greeting sent", {
|
2026-06-06 03:30:16 +07:00
|
|
|
userId: member.id,
|
2026-06-06 03:29:21 +07:00
|
|
|
guildId: member.guild.id,
|
|
|
|
|
channelId: greetingChannelId,
|
|
|
|
|
});
|
|
|
|
|
}
|