Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
/ gatekeeper Public archive

supercharge your discord commands by gatekeeping them in a flow of reactivity ⛓⚡

Notifications You must be signed in to change notification settings

itsMapleLeaf/gatekeeper

Repository files navigation

This project is deprecated

TL;DR: Use Reacord

I'm moving away from this project's development for a few reasons:

  • The command handling part is limited, and doesn't accomodate the use cases that a decent portion of bots need, e.g. being able to add a command for individual guilds
  • The reactivity part has gaps, and also makes you use it everywhere with no opt-out

For that reason, I split out the reactivity part into a new library: Reacord. It allows you to leverage JSX, react state, as well as the react ecosystem, and is much more powerful than what gatekeeper offers to accomplish the same goal. I would recommend using Reacord if you want declarative, highly interactive messages.

For command handling, I can't recommend a library for that (yet?), but you can build your own simple command handler: (1) (2)

gatekeeper

Gatekeeper is a ✨reactive✨ interaction framework for discord.js!

Install:

# npm
npm install @itsmapleleaf/gatekeeper discord.js

# yarn
yarn add @itsmapleleaf/gatekeeper discord.js

# pnpm
pnpm add @itsmapleleaf/gatekeeper discord.js

Here's a taste of what Gatekeeper looks like:

import { buttonComponent, Gatekeeper } from "@itsmapleleaf/gatekeeper"
import { Client, Intents } from "discord.js"

const client = new Client({
  intents: [Intents.FLAGS.GUILDS],
})

;(async () => {
  const gatekeeper = await Gatekeeper.create({
    client,
  })

  gatekeeper.addSlashCommand({
    name: "counter",
    description: "make a counter",
    run(context) {
      let count = 0

      context.reply(() => [
        `button pressed ${count} times`,
        buttonComponent({
          style: "PRIMARY",
          label: "press it",
          onClick: () => {
            count += 1
          },
        }),
      ])
    },
  })

  await client.login(process.env.BOT_TOKEN)
})()

And a silly example, demonstrating the power of the library. You can find the code here

showcase