import { option } from "@purrkit/router"; import { editActor } from "@stealth-developers/db"; import { errorMessage, upsertUser } from "@/lib"; import { useGetData } from "@/middleware"; import { glorpify, uwuify } from "./lib"; const proxyGroup = useGetData.command("proxy", { description: "uwuify & glorpify related commands", }); const proxyConfigurations: { name: "glorpify" | "uwuify"; formatter: (text: string) => string; }[] = [ { name: "glorpify", formatter: glorpify }, { name: "uwuify", formatter: uwuify }, ]; for (const { name, formatter } of proxyConfigurations) { proxyGroup.subcommand(name, { description: formatter(`Enable ${name}`), options: { user: option.user(formatter(`The user to enable ${name} for`), { required: false }), }, async run(interaction, { user: target }, { actor }) { if (target && !actor?.moderator) return errorMessage( interaction, formatter(`You must be a moderator to enable ${name} for another user.`), ); if (!interaction.guild) return errorMessage(interaction, formatter(`This command can only be used in a server.`)); const proxyActor = target ? (await upsertUser(target, interaction.guild))?.actor : actor; if (!proxyActor) return errorMessage(interaction, formatter(`Failed to find your user data.`)); await editActor(proxyActor.id, { proxy: name, }); return interaction.reply({ content: formatter(`Enabled ${name} for ${target ? target : "you"}`), flags: ["Ephemeral"], }); }, }); } proxyGroup.subcommand("disable", { description: "Disable proxy", options: { user: option.user("The user to disable proxy for", { required: false }), }, async run(interaction, { user: target }, { actor }) { if (target && !actor?.moderator) return errorMessage( interaction, `You must be a moderator to disable proxy for another user.`, ); if (!interaction.guild) return errorMessage(interaction, `This command can only be used in a server.`); const proxyActor = target ? (await upsertUser(target, interaction.guild))?.actor : actor; if (!proxyActor) return errorMessage(interaction, `Failed to find your user data.`); await editActor(proxyActor.id, { proxy: null, }); return interaction.reply({ content: `Disabled proxy for ${target ? target : "you"}`, flags: ["Ephemeral"], }); }, }); export const proxyCommands = [proxyGroup];