From 0557c7b143112aa5331cef03ccd07ab71a94f5fc Mon Sep 17 00:00:00 2001 From: Guzio Date: Thu, 26 Feb 2026 16:00:22 +0000 Subject: [PATCH 1/2] works yay --- src/matrix/matrix-command-handler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/matrix/matrix-command-handler.js b/src/matrix/matrix-command-handler.js index 07ae178..7c8667e 100644 --- a/src/matrix/matrix-command-handler.js +++ b/src/matrix/matrix-command-handler.js @@ -339,13 +339,13 @@ const commands = [{ body: "You cannot create threads in a Discord channel of the type, to which this Matrix room is bridged to. Did you try to create a thread inside a thread?" }) } - /*else if (e.code === 50035) { + else if (e.code === 50035) { return api.sendEvent(event.room_id, "m.room.message", { ...ctx, msgtype: "m.text", body: "Specified thread name is too long - thread creation failed. Please yap a bit less in the title, the thread body is for that. ;)" }) - }*/ + } else { await api.sendEvent(event.room_id, "m.room.message", { ...ctx, From ffed434c6ab11e584b4d1ab6ca3e6e871d589814 Mon Sep 17 00:00:00 2001 From: Guzio Date: Thu, 26 Feb 2026 16:05:53 +0000 Subject: [PATCH 2/2] rewrote the f#cker as a switch statement --- src/matrix/matrix-command-handler.js | 44 ++++++++++++---------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/matrix/matrix-command-handler.js b/src/matrix/matrix-command-handler.js index 7c8667e..8c0c3c2 100644 --- a/src/matrix/matrix-command-handler.js +++ b/src/matrix/matrix-command-handler.js @@ -314,45 +314,39 @@ const commands = [{ } catch (e_raw){ const e = unmarshallDiscordError(e_raw) - if (e.code === "NO_ATTACH_TARGET") { - return api.sendEvent(event.room_id, "m.room.message", { + switch (e.code) { + case "NO_ATTACH_TARGET": return api.sendEvent(event.room_id, "m.room.message", { ...ctx, msgtype: "m.text", "body": "⚠️ Couldn't find a Discord representation of the message under which you're trying to attach 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.", "format": "org.matrix.custom.html", "formatted_body": "⚠️ Couldn't find a Discord representation of the message under which you're trying to attach 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." }) - } - else if (e.code === 160004) { // see: https://docs.discord.com/developers/topics/opcodes-and-status-codes - return api.sendEvent(event.room_id, "m.room.message", { - ...ctx, - 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 attachment 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.", - "format": "org.matrix.custom.html", - "formatted_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 attachment 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.", - }) - } - else if (e.code === 50024) { - return api.sendEvent(event.room_id, "m.room.message", { + case (160004): // see: https://docs.discord.com/developers/topics/opcodes-and-status-codes + return api.sendEvent(event.room_id, "m.room.message", { + ...ctx, + 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 attachment 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.", + "format": "org.matrix.custom.html", + "formatted_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 attachment 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", { ...ctx, msgtype: "m.text", body: "You cannot create threads in a Discord channel of the type, to which this Matrix room is bridged to. Did you try to create a thread inside a thread?" }) - } - else if (e.code === 50035) { - return api.sendEvent(event.room_id, "m.room.message", { + case (50035): return api.sendEvent(event.room_id, "m.room.message", { ...ctx, msgtype: "m.text", body: "Specified thread name is too long - thread creation failed. Please yap a bit less in the title, the thread body is for that. ;)" }) - } - else { - await api.sendEvent(event.room_id, "m.room.message", { - ...ctx, - 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." - }) - throw e_raw; + default: + await api.sendEvent(event.room_id, "m.room.message", { + ...ctx, + 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." + }) + throw e_raw; } } }