all repos — stealth-developers @ 05020a60748d4790c6826660a9b0d87a3aa2fb99

bot: commands to manage moderators
vi did:web:vt3e.cat
Tue, 30 Jun 2026 19:47:12 +0100
commit

05020a60748d4790c6826660a9b0d87a3aa2fb99

parent

5dccebce69d05676fd06e9f8148f8a0c91e8b1b5

1 files changed, 80 insertions(+), 1 deletions(-)

jump to
M apps/bot/src/feats/tickets/commands.tsapps/bot/src/feats/tickets/commands.ts

@@ -1,6 +1,8 @@

import { option } from "@purrkit/router"; import { Result } from "@sapphire/result"; import { + editActor, + getModerators, getTicketByGuild, getTicketByUser, getTicketsByUser,

@@ -14,7 +16,7 @@ import { ActionRowBuilder, ButtonBuilder, ContainerBuilder, TextDisplayBuilder } from "discord.js";

import { ChannelType } from "discord.js"; import { OverwriteType } from "discord.js"; -import { PublicError, errorMessage, getTextChannel, handleError, logger } from "@/lib"; +import { PublicError, errorMessage, getTextChannel, handleError, logger, upsertUser } from "@/lib"; import { useGetTicketData } from "@/middleware"; import { getGuildActor } from "../guild-actor";

@@ -526,6 +528,7 @@ },

async run(interaction, _, { actor }) { if (!actor?.moderator) return errorMessage(interaction, "You must be a moderator to run this command"); + await manageConfig(interaction); }, });

@@ -538,6 +541,7 @@ },

async run(interaction, _, { actor }) { if (!actor?.moderator) return errorMessage(interaction, "You must be a moderator to run this command"); + await manageConfig(interaction); }, });

@@ -550,6 +554,7 @@ },

async run(interaction, _, { actor }) { if (!actor?.moderator) return errorMessage(interaction, "You must be a moderator to run this command"); + await manageConfig(interaction); }, });

@@ -560,6 +565,7 @@ description: "Set the message sent in the entry point channel",

async run(interaction, _, { actor }) { if (!actor?.moderator) return errorMessage(interaction, "You must be a moderator to run this command"); + await manageConfig(interaction); }, });

@@ -569,6 +575,7 @@ description: "Set the message sent in new tickets",

async run(interaction, _, { actor }) { if (!actor?.moderator) return errorMessage(interaction, "You must be a moderator to run this command"); + await manageConfig(interaction); }, });

@@ -625,6 +632,78 @@

await channel.send({ flags: ["IsComponentsV2"], components: [container] }); return interaction.reply({ content: "Prompt sent!", + flags: ["Ephemeral"], + }); + }, + }); + + group.subcommand("add-moderator", { + description: "Add a moderator.", + options: { + user: option.user("The user to add as a moderator", { required: true }), + }, + async run(interaction, { user }, { actor }) { + if (!actor) { + return errorMessage(interaction, "Failed to find you in the database."); + } else if (!interaction.guild) { + return errorMessage(interaction, "This command can only be used in a guild."); + } + + const dbActor = await upsertUser(user, interaction.guild); + if (!dbActor) return errorMessage(interaction, "Failed to add moderator."); + + await editActor(dbActor.id, { + moderator: true, + }); + + await interaction.reply({ + content: "Moderator added!", + flags: ["Ephemeral"], + }); + }, + }); + + group.subcommand("remove-moderator", { + description: "Remove a moderator.", + options: { + user: option.user("The user to remove as a moderator", { required: true }), + }, + async run(interaction, { user }, { actor }) { + if (!actor) { + return errorMessage(interaction, "Failed to find you in the database."); + } else if (!interaction.guild) { + return errorMessage(interaction, "This command can only be used in a guild."); + } + + const dbActor = await upsertUser(user, interaction.guild); + if (!dbActor) return errorMessage(interaction, "Failed to remove moderator."); + + await editActor(dbActor.id, { + moderator: false, + }); + + await interaction.reply({ + content: "Moderator removed!", + flags: ["Ephemeral"], + }); + }, + }); + + group.subcommand("list-moderators", { + description: "List all moderators.", + async run(interaction, _, { actor, guild }) { + if (!actor) { + return errorMessage(interaction, "Failed to find you in the database."); + } else if (!interaction.guild || !guild) { + return errorMessage(interaction, "This command can only be used in a guild."); + } + + const moderators = await getModerators(guild.id); + if (moderators.length === 0) return errorMessage(interaction, "No moderators found."); + + const moderatorList = moderators.map((m) => `<@${m.id}>`).join(", "); + await interaction.reply({ + content: `Moderators: ${moderatorList}`, flags: ["Ephemeral"], }); },