Yet another Fluxer bot built with TypeScript and Bun
1import { RequireNonBot } from "@/decorators/guards";
2import { Module } from "@/base/ModuleBase";
3import { Command } from "@/decorators/command";
4import type { BotContext, ParsedArgs } from "@/types";
5import type { Message } from "@fluxerjs/core";
6import { arg } from "@/args";
7import { z } from "zod";
8
9// Types
10const echoArgs = {
11 content: arg.restRequired(z.string().min(1).max(2000)),
12} as const;
13
14// Module
15@Module({
16 name: "misc",
17 description: "Miscellaneous commands",
18 guards: [RequireNonBot()],
19})
20export class MiscCommands {
21 @Command({
22 name: "echo",
23 description: "Echoes the provided content",
24 args: echoArgs,
25 })
26 async echo(_ctx: BotContext, message: Message, args: ParsedArgs<typeof echoArgs>): Promise<void> {
27 await message.channel?.send({ content: args.content });
28 }
29
30 @Command({
31 name: "ping",
32 description: "Pings the bot",
33 })
34 async ping(_ctx: BotContext, message: Message): Promise<void> {
35 await message.channel?.send({ content: "Pong!" });
36 }
37}