forked from cadence/out-of-your-element
Comparison of all the stuff I did. #6
2 changed files with 10 additions and 11 deletions
|
|
@ -222,10 +222,11 @@ async event => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (event.content["m.relates_to"]?.rel_type === "m.thread" && executedCommand !== "thread"){
|
if (event.content["m.relates_to"]?.rel_type === "m.thread" && executedCommand !== "thread"){
|
||||||
|
const bridgedTo = utils.getThreadRoomFromThreadEvent(event.event_id)
|
||||||
api.sendEvent(event.room_id, "m.room.message", {
|
api.sendEvent(event.room_id, "m.room.message", {
|
||||||
"body": "⚠️ **This message may not have been bridged to Discord in the way you thought it was gonna be!**\n\nIt seems like you sent this message inside a Matrix thread. Matrix threads don't work like Discord threads - they are effectively just „fancy replies”, not independent rooms/channels (any „thread-like appearance” is handled purely client-side - and even then, most Matrix clients don't handle it particularly well, with Element being the only one known to actually render threads as threads), and as such, they are bridged as replies to Discord. *In other words: __Discord users will not be aware that you sent this message inside a thread - the reply will go directly onto the main channel.__ If the thread you sent this message in is old, such a random reply may be distracting to Discord users!*\n\nFor the sake of Discord parity (and for better support in numerous Matrix clients - as stated above, most Matrix clients don't handle threads particularly well, and they just render in-thread messages as fancy replies), it is recommended to send threaded messages inside a separate Matrix room that gets bridged to Discord. If you sent this message in a pre-existing Matrix thread, please look around to see if anyone has created such a room for it. If this is the first message (ie. the thread was just created) or nobody has made a thread-room for this thread yet, it is recommended you create one with `/thread` and continue the conversation there. You can run that command directly in this thread to attach the created Discord thread to the same message as this Matrix one, or run it outside any threads to see other options for attachment.\n\n*You can read more about the rationale behind this design choice [here](https://gitdab.com/cadence/out-of-your-element/src/branch/main/docs/threads-as-rooms.md).*",
|
"body": "⚠️ **This message may not have been bridged to Discord in the way you thought it was gonna be!**\n\nIt seems like you sent this message inside a Matrix thread. Matrix threads don't work like Discord threads - they are effectively just „fancy replies”, not independent rooms/channels (any „thread-like appearance” is handled purely client-side - and even then, most Matrix clients don't handle it particularly well, with Element being the only one known to actually render threads as threads), and as such, they are bridged as replies to Discord. *In other words: __Discord users will not be aware that you sent this message inside a thread - the reply will go directly onto the main channel.__ If the thread you sent this message in is old, such a random reply **may be distracting** to Discord users!*\n\nFor the sake of Discord parity (and for better support in numerous Matrix clients - as stated above, most Matrix clients don't handle threads particularly well, and they just render in-thread messages as fancy replies), it is recommended to send threaded messages inside a separate Matrix room that gets bridged to Discord. "+ (bridgedTo ? "Luckily for you, this thread already has one! You can access it on https://matrix.to/#/"+bridgedTo+"?"+(await utils.getViaServersQuery(bridgedTo, api)).toString() : "Please run `/thread [Optional: Thread Name]` to create such a room for this thread, or get a link to it if someone else has already done so. If you run `/thread` (without any arguments) outside any threads and not as a reply, you'll get more info about this command")+".\n\n*You can read more about the rationale behind this design choice [here](https://gitdab.com/cadence/out-of-your-element/src/branch/main/docs/threads-as-rooms.md).*",
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
"formatted_body": "⚠️ <strong>This message may not have been bridged to Discord in the way you thought it was gonna be!</strong><br><br>It seems like you sent this message inside a Matrix thread. Matrix threads don't work like Discord threads - they are effectively just „fancy replies”, not independent rooms/channels (any „thread-like appearance” is handled purely client-side - and even then, most Matrix clients don't handle it particularly well, with Element being the only one known to actually render threads as threads), and as such, they are bridged as replies to Discord. <em>In other words: <u>Discord users will not be aware that you sent this message inside a thread - the reply will go directly onto the main channel.</u> If the thread you sent this message in is old, such a random reply may be distracting to Discord users!</em><br><br>For the sake of Discord parity (and for better support in numerous Matrix clients - as stated above, most Matrix clients don't handle threads particularly well, and they just render in-thread messages as fancy replies), it is recommended to send threaded messages inside a separate Matrix room that gets bridged to Discord. If you sent this message in a pre-existing Matrix thread, please look around to see if anyone has created such a room for it. If this is the first message (ie. the thread was just created) or nobody has made a thread-room for this thread yet, it is recommended you create one with <code>/thread</code> and continue the conversation there. You can run that command directly in this thread to attach the created Discord thread to the same message as this Matrix one, or run it outside any threads to see other options for attachment.<br><br><em>You can read more about the rationale behind this design choice <a href=\"https://gitdab.com/cadence/out-of-your-element/src/branch/main/docs/threads-as-rooms.md\">here</a>.</em>",
|
"formatted_body": "⚠️ <strong>This message may not have been bridged to Discord in the way you thought it was gonna be!</strong><br><br>It seems like you sent this message inside a Matrix thread. Matrix threads don't work like Discord threads - they are effectively just „fancy replies”, not independent rooms/channels (any „thread-like appearance” is handled purely client-side - and even then, most Matrix clients don't handle it particularly well, with Element being the only one known to actually render threads as threads), and as such, they are bridged as replies to Discord. <em>In other words: <u>Discord users will not be aware that you sent this message inside a thread - the reply will go directly onto the main channel.</u> If the thread you sent this message in is old, such a random reply <strong>may be distracting</strong> to Discord users!</em><br><br>For the sake of Discord parity (and for better support in numerous Matrix clients - as stated above, most Matrix clients don't handle threads particularly well, and they just render in-thread messages as fancy replies), it is recommended to send threaded messages inside a separate Matrix room that gets bridged to Discord. "+ (bridgedTo ? "Luckily for you, this thread already has one! You can access it on <a href=\"https://matrix.to/#/"+bridgedTo+"?"+(await utils.getViaServersQuery(bridgedTo, api)).toString()+"\">https://matrix.to/#/"+bridgedTo+"?"+(await utils.getViaServersQuery(bridgedTo, api)).toString()+"</a>" : "Please run <code>/thread [Optional: Thread Name]</code> to create such a room for this thread, or get a link to it if someone else has already done so. If you run <code>/thread</code> (without any arguments) outside any threads and not as a reply, you'll get more info about this command")+".<br><br><em>You can read more about the rationale behind this design choice <a href=\"https://gitdab.com/cadence/out-of-your-element/src/branch/main/docs/threads-as-rooms.md\">here</a>.</em>",
|
||||||
"m.mentions": { "user_ids": [event.sender]},
|
"m.mentions": { "user_ids": [event.sender]},
|
||||||
"m.relates_to": {
|
"m.relates_to": {
|
||||||
"event_id": event.content["m.relates_to"].event_id,
|
"event_id": event.content["m.relates_to"].event_id,
|
||||||
|
|
|
||||||
|
|
@ -312,23 +312,21 @@ const commands = [{
|
||||||
if (branchedFromDiscordMessage) await discord.snow.channel.createThreadWithMessage(channelID, branchedFromDiscordMessage, {name: words.slice(1).join(" ")})
|
if (branchedFromDiscordMessage) await discord.snow.channel.createThreadWithMessage(channelID, branchedFromDiscordMessage, {name: words.slice(1).join(" ")})
|
||||||
else throw {code: "NO_BRANCH_SOURCE", was_supposed_to_be: branchedFromMxEvent};
|
else throw {code: "NO_BRANCH_SOURCE", was_supposed_to_be: branchedFromMxEvent};
|
||||||
}
|
}
|
||||||
catch (e_raw){
|
catch (e){
|
||||||
const e = unmarshallDiscordError(e_raw)
|
switch (unmarshallDiscordError(e).code) {
|
||||||
switch (e.code) {
|
|
||||||
case "NO_BRANCH_SOURCE": return api.sendEvent(event.room_id, "m.room.message", {
|
case "NO_BRANCH_SOURCE": return api.sendEvent(event.room_id, "m.room.message", {
|
||||||
...ctx,
|
...ctx,
|
||||||
msgtype: "m.text",
|
msgtype: "m.text",
|
||||||
"body": "⚠️ Couldn't find a Discord representation of the message from which you're trying to branch this thread (event ID `"+e_raw.was_supposed_to_be+"` on Matrix), so it wasn't created. Either you ran this command on an unbridged message (one sent by this bot or one that failed to bridge due to a previous error), or this is an error on our side and should be reported.",
|
"body": "⚠️ Couldn't find a Discord representation of the message from which you're trying to branch this thread (event ID `"+e.was_supposed_to_be+"` on Matrix), so it wasn't created. Either you ran this command on an unbridged message (one sent by this bot or one that failed to bridge due to a previous error), or this is an error on our side and should be reported.",
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
"formatted_body": "⚠️ Couldn't find a Discord representation of the message from which you're trying to branch this thread (event ID <code>"+e_raw.was_supposed_to_be+"</code> on Matrix), so it wasn't created. Either you ran this command on an unbridged message (one sent by this bot or one that failed to bridge due to a previous error), or this is an error on our side and should be reported."
|
"formatted_body": "⚠️ Couldn't find a Discord representation of the message from which you're trying to branch this thread (event ID <code>"+e.was_supposed_to_be+"</code> on Matrix), so it wasn't created. Either you ran this command on an unbridged message (one sent by this bot or one that failed to bridge due to a previous error), or this is an error on our side and should be reported."
|
||||||
})
|
})
|
||||||
case (160004): // see: https://docs.discord.com/developers/topics/opcodes-and-status-codes
|
case (160004): // see: https://docs.discord.com/developers/topics/opcodes-and-status-codes
|
||||||
|
const thread = mxUtils.getThreadRoomFromThreadEvent(event.event_id)
|
||||||
return api.sendEvent(event.room_id, "m.room.message", {
|
return api.sendEvent(event.room_id, "m.room.message", {
|
||||||
...ctx,
|
...ctx,
|
||||||
msgtype: "m.text",
|
msgtype: "m.text",
|
||||||
"body": "There already exist a thread for the message you ran this command on (please run `/thread` (with no arguments and outside any threads) for details on branching rules, if you're unsure what „ran this command on” refers to); cannot create a new one. Scroll up and see where the link could be.",
|
body: "There already exist a Discord thread for the message you ran this command on" + (thread ? " - you may join its bridged room here: https://matrix.to/#/"+thread+"?"+(await mxUtils.getViaServersQuery(thread, api)).toString() : ", so a new one cannot be crated. However, it seems like that thread isn't bridged to any Matrix rooms. Please ask the space/server admins to rectify this issue (or have someone send a message in that thread on Discord side to bridge it automatically, if that's enabled for this space/server).")
|
||||||
"format": "org.matrix.custom.html",
|
|
||||||
"formatted_body": "There already exist a thread for the message you ran this command on (please run <code>/thread</code> (with no arguments and outside any threads) for details on branching rules, if you're unsure what „ran this command on” refers to); cannot create a new one. Scroll up and see where the link could be.",
|
|
||||||
})
|
})
|
||||||
case (50024): return api.sendEvent(event.room_id, "m.room.message", {
|
case (50024): return api.sendEvent(event.room_id, "m.room.message", {
|
||||||
...ctx,
|
...ctx,
|
||||||
|
|
@ -346,7 +344,7 @@ const commands = [{
|
||||||
msgtype: "m.text",
|
msgtype: "m.text",
|
||||||
body: "Unknown error occurred during thread creation. See error message below (or on the main channel, if the command was ran inside a thread) for details."
|
body: "Unknown error occurred during thread creation. See error message below (or on the main channel, if the command was ran inside a thread) for details."
|
||||||
})
|
})
|
||||||
throw e_raw; //Has to be e_raw, as functions get stripped from e as part of unmarshaling Discord error
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue