npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@marshmallow-stoat/mally

v0.2.0

Published

A high-performance, decorator-based command handler for the Stoat ecosystem.

Readme

@marshmallow-stoat/mally

A high-performance, decorator-based command handler for the Stoat ecosystem. Inspired by discordx.

Features

  • Decorator-based - Use @Stoat() and @SimpleCommand() decorators like discordx
  • Guards - Built-in guard system for permissions and checks
  • Cooldowns - Per-command cooldown support
  • Organized - Group multiple commands in a single class
  • Type-safe - Full TypeScript support

Installation

npm install @marshmallow-stoat/mally reflect-metadata
# or
pnpm add @marshmallow-stoat/mally reflect-metadata

Make sure to enable decorators in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Quick Start

1. Create your handler

// index.ts
import 'reflect-metadata';
import { Client } from 'stoat.js';
import { MallyHandler } from '@marshmallow-stoat/mally';

const client = new Client();

const handler = new MallyHandler({
    client, 
    prefix: '!', 
    owners: ['your-user-id']
});

await handler.init();

client.on('messageCreate', (message) => {
  handler.handleMessage(message);
});

client.login('your-token');

2. Create commands

// commands/general.ts
import { Stoat, SimpleCommand, Context } from '@marshmallow-stoat/mally';

@Stoat()
export class GeneralCommands {
  @SimpleCommand({ name: 'ping', description: 'Check bot latency' })
  async ping(ctx: Context) {
    await ctx.reply(`Pong! 🏓`);
  }

  @SimpleCommand({ name: 'hello', aliases: ['hi', 'hey'] })
  async hello(ctx: Context) {
    await ctx.reply(`Hello, <@${ctx.authorId}>!`);
  }
}

That's it! No manual imports needed - decorated command classes are auto-discovered.

Decorators

@Stoat()

Marks a class as a command container. All @SimpleCommand() methods inside will be registered.

@Stoat()
export class MyCommands {
  // commands go here
}

@SimpleCommand(options)

Marks a method as a command.

@SimpleCommand({
  name: 'ban',           // Command name (defaults to method name)
  description: 'Ban a user',
  aliases: ['b'],        // Alternative names
  permissions: ['BanMembers'], // This is currently not implemented, but will be in the future
  cooldown: 5000,        // 5 seconds
  ownerOnly: false,
  nsfw: false,
})
async ban(ctx: Context) {
  // ...
}

@Guard(GuardClass)

Adds a guard check before command execution.

import { Stoat, SimpleCommand, Guard, MallyGuard, Context } from '@marshmallow-stoat/mally';

// Define a guard
class IsAdmin implements MallyGuard {
  run(ctx: Context): boolean {
    return ctx.message.member?.hasPermission('Administrator') ?? false;
  }

  guardFail(ctx: Context): void {
    ctx.reply('You need Administrator permission!');
  }
}

@Stoat()
@Guard(IsAdmin)
export class AdminCommands {
  @SimpleCommand({ name: 'shutdown' })
  async shutdown(ctx: Context) {
    await ctx.reply('Shutting down...');
  }
}

Context

The Context object provides:

interface Context {
  client: Client;          // Stoat client instance
  message: Message;        // Original message
  content: string;         // Raw message content
  authorId: string;        // Author's user ID
  channelId: string;       // Channel ID
  serverId?: string;       // Server/Guild ID
  args: string[];          // Parsed arguments
  prefix: string;          // Prefix used
  commandName: string;     // Command name used
  
  reply(content: string): Promise<void>;
}

Handler Options

interface MallyHandlerOptions {
  client: Client;
  commandsDir?: string;          // Legacy mode: explicitly scan this directory
  discovery?: {
    roots?: string[];            // Default: [process.cwd()]
    include?: string[];          // Glob patterns per root
    ignore?: string[];           // Additional ignore globs
  };
  prefix: string | ((ctx: { serverId?: string }) => string | Promise<string>);
  owners?: string[];             // Owner user IDs
  extensions?: string[];         // File extensions (default: ['.js', '.mjs', '.cjs'])
  disableMentionPrefix?: boolean; // Disable @bot prefix
}

// Default auto-discovery is discordx-like: scans broadly under process.cwd(),
// then registers only files that look like decorated command modules.

Dynamic Prefix

const handler = new MallyHandler({
  client,
  prefix: async ({ serverId }) => {
    // Fetch from database, etc.
    return serverId ? await getServerPrefix(serverId) : '!';
  },
});

// Optional: constrain auto-discovery to specific roots/patterns
const scopedHandler = new MallyHandler({
  client,
  prefix: '!',
  discovery: {
    roots: [process.cwd()],
    include: ['apps/bot/dist/commands/**/*.js'],
  },
});

// TypeScript source discovery is opt-in and requires a TS runtime loader (tsx/ts-node)
const tsRuntimeHandler = new MallyHandler({
  client,
  prefix: '!',
  extensions: ['.ts'],
  discovery: {
    include: ['apps/bot/src/commands/**/*.ts'],
  },
});

All commands are defined through @Stoat() classes and @SimpleCommand() methods.

License

AGPL-3.0-or-later