d->m: Better text for links to unbridged channels

This commit is contained in:
Cadence Ember 2024-02-14 11:57:01 +13:00
commit e0d96cde19
4 changed files with 63 additions and 3 deletions

View file

@ -41,8 +41,13 @@ function getDiscordParseCallbacks(message, guild, useHTML) {
},
/** @param {{id: string, type: "discordChannel", row: {room_id: string, name: string, nick: string?}?, via: string}} node */
channel: node => {
if (!node.row) {
return `#[channel-from-an-unknown-server]` // fallback for when this channel is not bridged
if (!node.row) { // fallback for when this channel is not bridged
const channel = discord.channels.get(node.id)
if (channel) {
return `#${channel.name} [channel not bridged]`
} else {
return `#unknown-channel [channel from an unbridged server]`
}
} else if (useHTML) {
return `<a href="https://matrix.to/#/${node.row.room_id}?${node.via}">#${node.row.nick || node.row.name}</a>`
} else {