Support channel follow messages

This commit is contained in:
Cadence Ember
2026-03-25 15:29:18 +13:00
parent 201814e9f4
commit 5c9e569a2a
3 changed files with 55 additions and 0 deletions

View File

@@ -357,6 +357,17 @@ async function messageToEvent(message, guild, options = {}, di) {
}]
}
if (message.type === DiscordTypes.MessageType.ChannelFollowAdd) {
return [{
$type: "m.room.message",
msgtype: "m.emote",
body: `set this room to receive announcements from ${message.content}`,
format: "org.matrix.custom.html",
formatted_body: tag`set this room to receive announcements from <strong>${message.content}</strong>`,
"m.mentions": {}
}]
}
let isInteraction = (message.type === DiscordTypes.MessageType.ChatInputCommand || message.type === DiscordTypes.MessageType.ContextMenuCommand) && message.interaction && "name" in message.interaction
let isThinkingInteraction = isInteraction && !!((message.flags || 0) & DiscordTypes.MessageFlags.Loading)

View File

@@ -1142,6 +1142,19 @@ test("message2event: type 4 channel name change", async t => {
}])
})
test("message2event: type 12 channel follow add", async t => {
const events = await messageToEvent(data.special_message.channel_follow_add, data.guild.general)
t.deepEqual(events, [{
$type: "m.room.message",
"m.mentions": {},
msgtype: "m.emote",
body: "set this room to receive announcements from PluralKit #downtime",
format: "org.matrix.custom.html",
formatted_body: "set this room to receive announcements from <strong>PluralKit #downtime</strong>",
"m.mentions": {}
}])
})
test("message2event: thread start message reference", async t => {
const events = await messageToEvent(data.special_message.thread_start_context, data.guild.general, {}, {
api: {