Code block attachments use Discord supported types

This commit is contained in:
Cadence Ember
2026-05-12 14:07:14 +12:00
parent 92d6ada71b
commit 2aff1fbd06
3 changed files with 423 additions and 1 deletions
+2 -1
View File
@@ -894,7 +894,8 @@ async function eventToMessage(event, guild, channel, di) {
let preNode
if (node.nodeType === 3 && node.nodeValue.includes("```") && (preNode = nodeIsChildOf(node, ["PRE"]))) {
if (preNode.firstChild?.nodeName === "CODE") {
const ext = preNode.firstChild.className.match(/language-(\S+)/)?.[1] || "txt"
let ext = preNode.firstChild.className.match(/language-(\S+)/)?.[1]
if (!dUtils.supportedPlaintextPreviewExtensions.has(ext)) ext = "txt"
const filename = `inline_code.${ext}`
// Build the replacement <code> node
const replacementCode = doc.createElement("code")