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

Function migrateLoggingConfig

src/utils/schemas.js:110–158  ·  view source on GitHub ↗
(raw = {}, legacy = {})

Source from the content-addressed store, hash-verified

108};
109
110function migrateLoggingConfig(raw = {}, legacy = {}) {
111 const base = typeof raw === 'object' && raw !== null ? raw : {};
112 const {
113 logChannelId,
114 reportChannelId,
115 enableLogging,
116 logIgnore,
117 } = legacy;
118
119 const auditChannel =
120 base.channels?.audit ??
121 base.channelId ??
122 logChannelId ??
123 null;
124
125 const applicationsChannel = base.channels?.applications ?? null;
126
127 const reportsChannel =
128 base.channels?.reports ??
129 reportChannelId ??
130 null;
131
132 const ignore = {
133 users: base.ignore?.users ?? logIgnore?.users ?? [],
134 channels: base.ignore?.channels ?? logIgnore?.channels ?? [],
135 };
136
137 let enabled = base.enabled ?? false;
138 if (enableLogging === false) {
139 enabled = false;
140 } else if (auditChannel && base.enabled === undefined && enableLogging !== false) {
141 enabled = base.enabled ?? Boolean(enableLogging);
142 }
143
144 const { channelId: _legacyChannelId, ignore: _ignore, channels: _channels, ...rest } = base;
145
146 return {
147 ...DEFAULT_LOGGING,
148 ...rest,
149 enabled,
150 channels: {
151 audit: auditChannel,
152 applications: applicationsChannel,
153 reports: reportsChannel,
154 },
155 ignore,
156 enabledEvents: base.enabledEvents ?? {},
157 };
158}
159
160export function stripLegacyLoggingFields(config) {
161 if (!config || typeof config !== 'object') {

Callers 2

normalizeGuildConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected