all repos — stealth-developers @ 433ff54f586cb201794a95cbd29d81ccdf4fabc5

apps/bot/src/feats/uwuify/index.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
import { option } from "@purrkit/router";
import { editActor } from "@stealth-developers/db";

import { errorMessage, upsertUser } from "@/lib";
import { useGetData } from "@/middleware";

import { uwuify } from "./lib";

const uwuifyGroup = useGetData.command("uwuify", {
	description: "uwuify-wewated commands :3",
});

uwuifyGroup.subcommand("toggle", {
	description: "toggwe uwuify OwO on ow off",
	options: {
		user: option.user("t-the usew to toggle uwuify OwO fow", { required: false }),
	},
	async run(interaction, { user: target }, { actor }) {
		if (target && !actor?.moderator)
			return errorMessage(interaction, "you must be a modewatow to toggle uwuify OwO fow othews.");
		if (!interaction.guild)
			return errorMessage(interaction, "this c-c-command can onwy be used in a sewvew.");

		const uwuifyActor = target ? (await upsertUser(target, interaction.guild))?.actor : actor;
		if (!uwuifyActor) return errorMessage(interaction, "failed to find youw usew data.");

		const isEnabled = uwuifyActor.uwuify;
		await editActor(uwuifyActor.id, {
			uwuify: !uwuifyActor.uwuify,
		});

		const resultString = `uwuify is now ${!isEnabled ? "enabled" : "disabled"} for ${target ? target.displayName : "you"}.`;

		return interaction.reply({
			content: uwuify(resultString),
			flags: ["Ephemeral"],
		});
	},
});

export const uwuifyCommands = [uwuifyGroup];