category subspaces #113

Open
mschae wants to merge 9 commits from mschae/out-of-your-element:category-subspaces into main
2 changed files with 6 additions and 0 deletions
Showing only changes of commit a7632181f9 - Show all commits

never revert a manually linked category subspace

mschae23 2026-11-22 23:28:05 +01:00
Signed by untrusted user: mschae
GPG key ID: A87721D300DE88AB

View file

@ -52,6 +52,7 @@ async function event(event) {
try {
await createSpace.syncSpaceFully(guild_id)
process.exit(0)
} catch (e) {
console.error(e)
process.exit(1) // won't exit automatically on thrown error due to living discord connection, so manual exit is necessary

View file

@ -85,6 +85,11 @@ async function shouldMakeCategorySpace(guild, channel, parentChannel, autocreate
if (parentChannel?.type === DiscordTypes.ChannelType.GuildForum) return true
if (!autocreate || parentChannel.type !== DiscordTypes.ChannelType.GuildCategory) return false
// if there is already a bridged room for the parent channel, don't revert it
// this can happen when manually linking categories in the web UI for default guilds
const parentRoom = select("channel_room", "room_id", {room_id: parentChannel.id}).pluck().get()
if (parentRoom) return true
const defaultRoles = select("role_default", "role_id", {guild_id: guild.id}).pluck().all()
/** @type {DiscordTypes.APIChannel[]} */
// @ts-ignore