MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / normalizeWelcomeConfig

Function normalizeWelcomeConfig

src/utils/database.js:632–678  ·  view source on GitHub ↗
(raw = {})

Source from the content-addressed store, hash-verified

630}
631
632function normalizeWelcomeConfig(raw = {}) {
633 const base = typeof raw === "object" && raw !== null ? raw : {};
634
635 const channelId = base.channelId ?? null;
636 const goodbyeChannelId = base.goodbyeChannelId ?? null;
637
638 const welcomeMessage = base.welcomeMessage ?? "Welcome {user} to {server}!";
639 const leaveMessage = base.leaveMessage ?? "{user.tag} has left the server.";
640
641 const welcomeEmbed = base.welcomeEmbed ?? {
642 title: "🎉 Welcome!",
643 description: "Welcome {user} to {server}!",
644 color: getColor("success"),
645 thumbnail: true,
646 footer: "Welcome to {server}!"
647 };
648
649 const leaveEmbed = base.leaveEmbed ?? {
650 title: "👋 Goodbye",
651 description: "{user.tag} has left the server.",
652 color: getColor("error"),
653 thumbnail: true,
654 footer: "Goodbye from {server}!"
655 };
656
657 const roleIds = Array.isArray(base.roleIds) ? base.roleIds : [];
658
659 return {
660 ...base,
661 enabled: Boolean(base.enabled),
662 channelId,
663 welcomeMessage,
664 welcomeEmbed,
665 welcomePing: Boolean(base.welcomePing),
666 welcomeImage: base.welcomeImage ?? null,
667 goodbyeEnabled: Boolean(base.goodbyeEnabled),
668 goodbyeChannelId,
669 leaveMessage,
670 leaveEmbed,
671 dmMessage: base.dmMessage ?? "",
672 goodbyePing: Boolean(base.goodbyePing),
673 roleIds,
674 autoRoleDelay: base.autoRoleDelay ?? 0,
675 joinLogs: base.joinLogs ?? { enabled: false, channelId: null },
676 leaveLogs: base.leaveLogs ?? { enabled: false, channelId: null }
677 };
678}
679
680export async function getWelcomeConfig(client, guildId) {
681 if (!client.db) {

Callers 1

getWelcomeConfigFunction · 0.85

Calls 1

getColorFunction · 0.70

Tested by

no test coverage detected