droff-commands

Command helpers for the droff discord client

Usage no npm install needed!

<script type="module">
  import droffCommands from 'https://cdn.skypack.dev/droff-commands';
</script>

README

droff-commands

Accompanying library to droff for creating message based commands.

It uses lexure for parsing commands.

Usage

import { createClient, Intents } from "droff";
import * as Commands from "droff-commands";
import * as Rx from "rxjs";
import * as RxO from "rxjs/operators";

const client = createClient({
  token: process.env.DISCORD_BOT_TOKEN!,
  gateway: {
    intents: Intents.GUILD_MESSAGES,
  },
});

const command$ = Commands.create(client)("!");

const ping$ = command$({ name: "ping" }).pipe(
  RxO.flatMap(({ reply }) => reply({ content: "Pong!" })),
);

// Subscribe
Rx.merge(client.effects$, ping$).subscribe();