diff --git a/d2m/discord-packets.js b/d2m/discord-packets.js index a1a4505a..6ece8cad 100644 --- a/d2m/discord-packets.js +++ b/d2m/discord-packets.js @@ -82,7 +82,10 @@ const utils = { // Event dispatcher for OOYE bridge operations try { - if (message.t === "CHANNEL_UPDATE") { + if (message.t === "GUILD_UPDATE") { + await eventDispatcher.onGuildUpdate(client, message.d) + + } else if (message.t === "CHANNEL_UPDATE") { await eventDispatcher.onChannelOrThreadUpdate(client, message.d, false) } else if (message.t === "THREAD_CREATE") { diff --git a/d2m/event-dispatcher.js b/d2m/event-dispatcher.js index c871ff1c..9bb07c09 100644 --- a/d2m/event-dispatcher.js +++ b/d2m/event-dispatcher.js @@ -14,6 +14,8 @@ const addReaction = sync.require("./actions/add-reaction") const announceThread = sync.require("./actions/announce-thread") /** @type {import("./actions/create-room")}) */ const createRoom = sync.require("./actions/create-room") +/** @type {import("./actions/create-space")}) */ +const createSpace = sync.require("./actions/create-space") /** @type {import("../matrix/api")}) */ const api = sync.require("../matrix/api") @@ -116,6 +118,16 @@ module.exports = { await announceThread.announceThread(parentRoomID, threadRoomID, thread) }, + /** + * @param {import("./discord-client")} client + * @param {import("discord-api-types/v10").GatewayGuildUpdateDispatchData} guild + */ + async onGuildUpdate(client, guild) { + const spaceID = db.prepare("SELECT space_id FROM guild_space WHERE guild_id = ?").pluck().get(guild.id) + if (!spaceID) return + await createSpace.syncSpace(guild.id) + }, + /** * @param {import("./discord-client")} client * @param {import("discord-api-types/v10").GatewayChannelUpdateDispatchData} channelOrThread