out-of-your-element/d2m/converters/message-to-event.js

27 lines
567 B
JavaScript
Raw Normal View History

2023-04-25 20:06:08 +00:00
// @ts-check
const markdown = require("discord-markdown")
/**
* @param {import("discord-api-types/v10").APIMessage} message
* @returns {import("../../types").M_Room_Message_content}
*/
2023-04-30 12:57:30 +00:00
module.exports = function messageToEvent(message) {
2023-04-25 20:06:08 +00:00
const body = message.content
const html = markdown.toHTML(body, {
2023-04-30 12:57:30 +00:00
/* discordCallback: {
2023-04-25 20:06:08 +00:00
user: Function,
channel: Function,
role: Function,
everyone: Function,
here: Function
2023-04-30 12:57:30 +00:00
} */
2023-04-25 20:06:08 +00:00
}, null, null)
return {
msgtype: "m.text",
body: body,
2023-04-30 12:57:30 +00:00
format: "org.matrix.custom.html",
2023-04-25 20:06:08 +00:00
formatted_body: html
}
}