From 042ee931bfc15e719ea000dc02063e2ae8dab482 Mon Sep 17 00:00:00 2001 From: Dominic Ferrando Date: Fri, 28 Aug 2026 10:43:13 -0400 Subject: [PATCH] Make setting limbo mode also update system channel. Rename from limbomode to limbo --- src/cmd/registry/limbo.ts | 39 +++++++++++++++++++++++++++++++++++ src/cmd/registry/limbomode.ts | 21 ------------------- src/index.ts | 2 +- src/services/data.ts | 6 ++++-- 4 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 src/cmd/registry/limbo.ts delete mode 100644 src/cmd/registry/limbomode.ts diff --git a/src/cmd/registry/limbo.ts b/src/cmd/registry/limbo.ts new file mode 100644 index 0000000..354b691 --- /dev/null +++ b/src/cmd/registry/limbo.ts @@ -0,0 +1,39 @@ +import { ChannelType, type Message } from "discord.js"; +import type { Command } from "../../models"; +import RoleService from "../../services/role"; +import DataService from "../../services/data"; + +const LIMBO_CHANNEL_NAME = "limbo"; + +export default { + name: "limbo", + description: "Toggles on/off limbo mode. When limbo mode is on, new members will be placed in #limbo. When off, new members will be placed in #chat-and-shitpost.", + usage: ".limbo [on|off]", + execute: async (message: Message) => { + const ogState = RoleService.limboMode; + + if (message.content.includes("on")) + RoleService.limboMode = true; + else if (message.content.includes("off")) + RoleService.limboMode = false; + else + RoleService.limboMode = !RoleService.limboMode; + + // update system channel + if (RoleService.limboMode) { + if (!ogState) + DataService.data = { ...DataService.data, prevSystemChannelId: message.guild?.systemChannel?.id }; + const limboChannel = message.guild?.channels.cache.find((ch) => ch.name.toLowerCase() === LIMBO_CHANNEL_NAME); + if (limboChannel && limboChannel.type === ChannelType.GuildText) + await message.guild?.setSystemChannel(limboChannel); + } + else { + const prevSystemChannel = message.guild?.channels.cache.find((ch) => ch.id === DataService.data.prevSystemChannelId); + if (prevSystemChannel && prevSystemChannel.type === ChannelType.GuildText) + await message.guild?.setSystemChannel(prevSystemChannel); + } + + + await message.reply(`*${ogState}* -> **${RoleService.limboMode}**`); + } +} satisfies Command; diff --git a/src/cmd/registry/limbomode.ts b/src/cmd/registry/limbomode.ts deleted file mode 100644 index 65d0d62..0000000 --- a/src/cmd/registry/limbomode.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Message } from "discord.js"; -import type { Command } from "../../models"; -import RoleService from "../../services/role"; - -export default { - name: "limbomode", - description: "Toggles on/off limbo mode. When limbo mode is on, new members will be placed in #limbo. When off, new members will be placed in #chat-and-shitpost.", - usage: ".limbomode [on|off]", - execute: async (message: Message) => { - const ogState = RoleService.limboMode; - - if (message.content.includes("on")) - RoleService.limboMode = true; - else if (message.content.includes("off")) - RoleService.limboMode = false; - else - RoleService.limboMode = !RoleService.limboMode; - - await message.reply(`*${ogState}* -> **${RoleService.limboMode}**`); - } -} satisfies Command; diff --git a/src/index.ts b/src/index.ts index 4b486de..eac1d06 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ client.on("messageCreate", async (message) => { try { const command = CommandService.parse(message); - if (command) command.execute(message); + if (command) await command.execute(message); } catch (err) { console.error(err); diff --git a/src/services/data.ts b/src/services/data.ts index 18844da..2c63f0c 100644 --- a/src/services/data.ts +++ b/src/services/data.ts @@ -1,5 +1,6 @@ interface Data { - limboMode: boolean + limboMode: boolean, + prevSystemChannelId?: string } export default class DataService { @@ -7,7 +8,8 @@ export default class DataService { private static file: Bun.BunFile | undefined; private static _data: Data = { // default values (will be overwritten) - limboMode: false + limboMode: false, + prevSystemChannelId: undefined }; static async init() {