listen for guild updates and connect them
This commit is contained in:
parent
892bf4496d
commit
bfe9efe62e
2 changed files with 16 additions and 1 deletions
|
@ -82,7 +82,10 @@ const utils = {
|
||||||
|
|
||||||
// Event dispatcher for OOYE bridge operations
|
// Event dispatcher for OOYE bridge operations
|
||||||
try {
|
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)
|
await eventDispatcher.onChannelOrThreadUpdate(client, message.d, false)
|
||||||
|
|
||||||
} else if (message.t === "THREAD_CREATE") {
|
} else if (message.t === "THREAD_CREATE") {
|
||||||
|
|
|
@ -14,6 +14,8 @@ const addReaction = sync.require("./actions/add-reaction")
|
||||||
const announceThread = sync.require("./actions/announce-thread")
|
const announceThread = sync.require("./actions/announce-thread")
|
||||||
/** @type {import("./actions/create-room")}) */
|
/** @type {import("./actions/create-room")}) */
|
||||||
const createRoom = sync.require("./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")}) */
|
/** @type {import("../matrix/api")}) */
|
||||||
const api = sync.require("../matrix/api")
|
const api = sync.require("../matrix/api")
|
||||||
|
|
||||||
|
@ -116,6 +118,16 @@ module.exports = {
|
||||||
await announceThread.announceThread(parentRoomID, threadRoomID, thread)
|
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-client")} client
|
||||||
* @param {import("discord-api-types/v10").GatewayChannelUpdateDispatchData} channelOrThread
|
* @param {import("discord-api-types/v10").GatewayChannelUpdateDispatchData} channelOrThread
|
||||||
|
|
Loading…
Reference in a new issue