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

Function createLogEmbed

src/services/loggingService.js:268–339  ·  view source on GitHub ↗
(guild, eventType, data)

Source from the content-addressed store, hash-verified

266}
267
268function createLogEmbed(guild, eventType, data) {
269 const color = data.color ?? EVENT_COLORS[eventType] ?? 0x0099ff;
270 const icon = EVENT_ICONS[eventType] || '📌';
271 const title = data.title || `${icon} ${formatEventType(eventType)}`;
272
273 const inlineFields = [];
274 let description = data.description || '';
275
276 if (data.lines?.length) {
277 description = buildLogDescription({
278 headline: data.headline || description || undefined,
279 lines: data.lines,
280 quoted: data.quoted !== false,
281 meta: data.meta,
282 });
283
284 if (data.fields?.length) {
285 const { before, after } = splitComparisonFields(data.fields);
286 if (before !== null) inlineFields.push({ name: 'Before', value: before, inline: true });
287 if (after !== null) inlineFields.push({ name: 'After', value: after, inline: true });
288 }
289 } else if (data.fields?.length) {
290 const { before, after, rest } = splitComparisonFields(data.fields);
291
292 if (before !== null || after !== null) {
293 const metaLines = fieldsToLines(rest);
294 description = buildLogDescription({
295 headline: description || undefined,
296 lines: metaLines,
297 quoted: true,
298 });
299
300 if (before !== null) {
301 inlineFields.push({ name: 'Before', value: before, inline: true });
302 }
303 if (after !== null) {
304 inlineFields.push({ name: 'After', value: after, inline: true });
305 }
306 } else {
307 description = buildLogDescription({
308 headline: description || undefined,
309 lines: fieldsToLines(data.fields),
310 quoted: data.quoted ?? !description,
311 });
312 }
313 } else if (data.meta?.length) {
314 description = buildLogDescription({
315 headline: description || undefined,
316 meta: data.meta,
317 });
318 }
319
320 if (data.section?.body) {
321 description = appendContentSection(description, data.section.title || 'Message', data.section.body);
322 }
323
324 if (data.inlineFields?.length) {
325 inlineFields.push(...data.inlineFields);

Callers 1

logEventFunction · 0.85

Calls 6

buildLogDescriptionFunction · 0.90
splitComparisonFieldsFunction · 0.90
fieldsToLinesFunction · 0.90
appendContentSectionFunction · 0.90
buildStandardLogEmbedFunction · 0.90
formatEventTypeFunction · 0.85

Tested by

no test coverage detected