Resolve Matrix room aliases to Discord channels

This commit is contained in:
Cadence Ember 2025-01-08 13:56:59 +13:00
commit ad1aa2c0f6
4 changed files with 155 additions and 2 deletions

View file

@ -367,6 +367,16 @@ async function ackEvent(event, mxid) {
await sendReadReceipt(event.room_id, event.event_id, mxid)
}
/**
* Resolve a room alias to a room ID.
* @param {string} alias
*/
async function getAlias(alias) {
/** @type {Ty.R.ResolvedRoom} */
const root = await mreq.mreq("GET", `/client/v3/directory/room/${encodeURIComponent(alias)}`)
return root.room_id
}
module.exports.path = path
module.exports.register = register
module.exports.createRoom = createRoom
@ -395,3 +405,4 @@ module.exports.ping = ping
module.exports.getMedia = getMedia
module.exports.sendReadReceipt = sendReadReceipt
module.exports.ackEvent = ackEvent
module.exports.getAlias = getAlias