1
0
Fork 0
out-of-your-element-fork-th.../d2m/actions/announce-thread.js

26 lines
931 B
JavaScript
Raw Normal View History

2023-08-21 05:25:51 +00:00
// @ts-check
const assert = require("assert")
const passthrough = require("../../passthrough")
const {discord, sync, db, select} = passthrough
/** @type {import("../converters/thread-to-announcement")} */
const threadToAnnouncement = sync.require("../converters/thread-to-announcement")
2023-08-21 05:25:51 +00:00
/** @type {import("../../matrix/api")} */
const api = sync.require("../../matrix/api")
/**
* @param {string} parentRoomID
* @param {string} threadRoomID
* @param {import("discord-api-types/v10").APIThreadChannel} thread
*/
async function announceThread(parentRoomID, threadRoomID, thread) {
const creatorMxid = select("sim", "mxid", "WHERE discord_id = ?").pluck().get(thread.owner_id)
2023-08-21 05:25:51 +00:00
const content = await threadToAnnouncement.threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thread, {api})
2023-08-21 05:25:51 +00:00
await api.sendEvent(parentRoomID, "m.room.message", content, creatorMxid)
2023-08-21 05:25:51 +00:00
}
module.exports.announceThread = announceThread