Implement limbomode command
This commit is contained in:
@@ -1,10 +1,21 @@
|
|||||||
import type { Message } from "discord.js";
|
import type { Message } from "discord.js";
|
||||||
import type { Command } from "../../models";
|
import type { Command } from "../../models";
|
||||||
|
import RoleService from "../../services/role";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "limbomode",
|
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.",
|
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]",
|
usage: ".limbomode [on|off]",
|
||||||
execute: async (message: Message) => {
|
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(`limbomode: *${ogState}* -> **${RoleService.limboMode}**`);
|
||||||
}
|
}
|
||||||
} satisfies Command;
|
} satisfies Command;
|
||||||
|
|||||||
+10
-2
@@ -1,7 +1,7 @@
|
|||||||
import type { Guild, GuildMember, Collection, RoleCreateOptions } from "discord.js";
|
import type { Guild, GuildMember, Collection, RoleCreateOptions } from "discord.js";
|
||||||
|
|
||||||
export default abstract class RoleService {
|
export default abstract class RoleService {
|
||||||
static readonly ROLES: Record<string, RoleCreateOptions> = {
|
static readonly ROLES = {
|
||||||
// Main
|
// Main
|
||||||
"ROBOT": {
|
"ROBOT": {
|
||||||
name: "robot",
|
name: "robot",
|
||||||
@@ -47,10 +47,12 @@ export default abstract class RoleService {
|
|||||||
"LIMBO": {
|
"LIMBO": {
|
||||||
name: "limbo",
|
name: "limbo",
|
||||||
}
|
}
|
||||||
};
|
} satisfies Record<string, RoleCreateOptions>;
|
||||||
|
|
||||||
static readonly STARTER_ROLES = [RoleService.ROLES["LURKER"], RoleService.ROLES["NEWFAG"]];
|
static readonly STARTER_ROLES = [RoleService.ROLES["LURKER"], RoleService.ROLES["NEWFAG"]];
|
||||||
|
|
||||||
|
public static limboMode = false;
|
||||||
|
|
||||||
static validate(guilds: Collection<string, Guild>): void {
|
static validate(guilds: Collection<string, Guild>): void {
|
||||||
guilds.forEach(guild => {
|
guilds.forEach(guild => {
|
||||||
const missing = Object.values(RoleService.ROLES).filter(role => !this.getRoleByName(guild, role.name));
|
const missing = Object.values(RoleService.ROLES).filter(role => !this.getRoleByName(guild, role.name));
|
||||||
@@ -83,6 +85,12 @@ export default abstract class RoleService {
|
|||||||
console.error(`Failed to add starter role: ${role.name}`, err);
|
console.error(`Failed to add starter role: ${role.name}`, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.limboMode) {
|
||||||
|
const limboRole = this.getRoleByName(guildMember.guild, this.ROLES["LIMBO"].name)
|
||||||
|
if (!limboRole) return;
|
||||||
|
await guildMember.roles.add(limboRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static getRoleByName(guild: Guild, roleName?: string) {
|
static getRoleByName(guild: Guild, roleName?: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user