out-of-your-element/d2m/actions/update-pins.js

23 lines
658 B
JavaScript
Raw Normal View History

2023-10-10 04:41:53 +00:00
// @ts-check
const passthrough = require("../../passthrough")
const {discord, sync} = passthrough
/** @type {import("../converters/pins-to-list")} */
const pinsToList = sync.require("../converters/pins-to-list")
/** @type {import("../../matrix/api")} */
const api = sync.require("../../matrix/api")
/**
* @param {string} channelID
* @param {string} roomID
*/
async function updatePins(channelID, roomID) {
const pins = await discord.snow.channel.getChannelPinnedMessages(channelID)
const eventIDs = pinsToList.pinsToList(pins)
await api.sendState(roomID, "m.room.pinned_events", "", {
pinned: eventIDs
})
}
module.exports.updatePins = updatePins