From ae57fa28016722744c696d63dbecad1893510313 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 1 Feb 2025 22:03:41 +1300 Subject: [PATCH] Only announce if they can reasonably type here --- src/web/routes/link.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/web/routes/link.js b/src/web/routes/link.js index efc474f..9db39d7 100644 --- a/src/web/routes/link.js +++ b/src/web/routes/link.js @@ -3,6 +3,7 @@ const {z} = require("zod") const {defineEventHandler, useSession, createError, readValidatedBody, setResponseHeader} = require("h3") const Ty = require("../../types") +const DiscordTypes = require("discord-api-types/v10") const {discord, db, as, sync, select, from} = require("../../passthrough") /** @type {import("../../d2m/actions/create-space")} */ @@ -64,10 +65,12 @@ as.router.post("/api/link", defineEventHandler(async event => { await createRoom.syncRoom(parsedBody.discord) // Send a notification in the room - await api.sendEvent(parsedBody.matrix, "m.room.message", { - msgtype: "m.notice", - body: "👋 This room is now bridged with Discord. Say hi!" - }) + if (channel.type === DiscordTypes.ChannelType.GuildText) { + await api.sendEvent(parsedBody.matrix, "m.room.message", { + msgtype: "m.notice", + body: "👋 This room is now bridged with Discord. Say hi!" + }) + } setResponseHeader(event, "HX-Refresh", "true") return null // 204