1
0
Fork 0

listen for guild updates and connect them

This commit is contained in:
Cadence Ember 2023-08-23 12:37:25 +12:00
parent 892bf4496d
commit bfe9efe62e
2 changed files with 16 additions and 1 deletions

View file

@ -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") {

View file

@ -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