Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
042ee931bf |
@@ -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;
|
||||||
@@ -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;
|
|
||||||
+1
-1
@@ -26,7 +26,7 @@ client.on("messageCreate", async (message) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const command = CommandService.parse(message);
|
const command = CommandService.parse(message);
|
||||||
if (command) command.execute(message);
|
if (command) await command.execute(message);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
interface Data {
|
interface Data {
|
||||||
limboMode: boolean
|
limboMode: boolean,
|
||||||
|
prevSystemChannelId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class DataService {
|
export default class DataService {
|
||||||
@@ -7,7 +8,8 @@ export default class DataService {
|
|||||||
private static file: Bun.BunFile | undefined;
|
private static file: Bun.BunFile | undefined;
|
||||||
private static _data: Data = {
|
private static _data: Data = {
|
||||||
// default values (will be overwritten)
|
// default values (will be overwritten)
|
||||||
limboMode: false
|
limboMode: false,
|
||||||
|
prevSystemChannelId: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
static async init() {
|
static async init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user