(guild, eventType, data)
| 266 | } |
| 267 | |
| 268 | function 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); |
no test coverage detected