Yet another Fluxer bot built with TypeScript and Bun
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore(fmt): format files

+14 -19
+3 -7
src/commands/ping.ts
··· 1 1 import type { Message } from "@fluxerjs/core"; 2 2 import { Command } from "../decorators/command"; 3 3 import { RequireNonBot } from "../decorators/guards"; 4 - import type { ICommand } from "../types"; 4 + import type { BotContext, ICommand } from "../types"; 5 5 6 - @Command({ 7 - name: "ping", 8 - aliases: ["p"], 9 - description: 'Replies with "Pong!"' 10 - }) 6 + @Command({ name: "ping", aliases: ["p"], description: 'Replies with "Pong!"' }) 11 7 @RequireNonBot() 12 8 export class PingCommand implements ICommand { 13 - async execute(message: Message, _args: string[]): Promise<void> { 9 + async execute(_: BotContext, message: Message): Promise<void> { 14 10 await message.reply("Pong!"); 15 11 } 16 12 }
+1 -1
src/decorators/command.ts
··· 11 11 export function Command(meta: CommandMeta): ClassDecorator { 12 12 return (target) => { 13 13 Reflect.defineMetadata(COMMAND_META_KEY, meta, target); 14 - } 14 + }; 15 15 }
+6 -6
src/decorators/guards.ts
··· 2 2 import type { Message } from "@fluxerjs/core"; 3 3 4 4 export const GUARDS_KEY = Symbol("fluxer:guards"); 5 - export type Guard = (msg: Message) => boolean | Promise<boolean> 5 + export type Guard = (msg: Message) => boolean | Promise<boolean>; 6 6 7 7 export function RequireNonBot(): ClassDecorator { 8 8 return (target) => { 9 - const guards: Guard[] = Reflect.getMetadata(GUARDS_KEY, target) ?? [] 9 + const guards: Guard[] = Reflect.getMetadata(GUARDS_KEY, target) ?? []; 10 10 guards.push((msg) => !msg.author.bot); 11 - Reflect.defineMetadata(GUARDS_KEY, guards, target) 12 - } 11 + Reflect.defineMetadata(GUARDS_KEY, guards, target); 12 + }; 13 13 } 14 14 15 15 export function RequirePrefix(prefix: string): ClassDecorator { 16 16 return (target) => { 17 - const guards: Guard[] = Reflect.getMetadata(GUARDS_KEY, target) ?? [] 17 + const guards: Guard[] = Reflect.getMetadata(GUARDS_KEY, target) ?? []; 18 18 guards.push((msg) => msg.content.startsWith(prefix)); 19 19 Reflect.defineMetadata(GUARDS_KEY, guards, target); 20 - } 20 + }; 21 21 }
+3 -3
src/env.ts
··· 4 4 export const env = createEnv({ 5 5 server: { 6 6 FLUXER_BOT_TOKEN: z.string(), 7 - PREFIX: z.string().min(1).default("!") 7 + PREFIX: z.string().min(1).default("!"), 8 8 }, 9 - runtimeEnv: process.env 10 - }) 9 + runtimeEnv: process.env, 10 + });
-1
src/index.ts
··· 2 2 3 3 // Main entry, while it looks stupidly short, it only takes few lines anyway. 4 4 new Bot().start(); 5 -
+1 -1
tsconfig.json
··· 25 25 "noUnusedLocals": false, 26 26 "noUnusedParameters": false, 27 27 "noPropertyAccessFromIndexSignature": false, 28 - 28 + 29 29 // Experimental features 30 30 "experimentalDecorators": true, 31 31 "emitDecoratorMetadata": true