Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@itsmapleleaf/gatekeeper

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itsmapleleaf/gatekeeper

a slash command and interaction framework for discord.js

  • 0.0.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-99.2%
Maintainers
1
Weekly downloads
 
Created
Source

hey

this is a slash command framework for discord.js and it's very not done don't use it

maybe more docs later

usage

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

const commands: CommandHandler[] = [
  // list of commands here
]

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

applyCommands(client, commands)

client.on("ready", () => {
  console.info("bot running ayy lmao")
})

await client.login(process.env.BOT_TOKEN).catch(console.error)

examples

ping

const commands: CommandHandler[] = [
  {
    name: "ping",
    description: "pong",
    async run(context) {
      await context.addReply("pong!")
    },
  },
]

counter

creates a /counter command which responds with a counter button. each counter button has its own count. try running it multiple times!

const commands: CommandHandler[] = [
  {
    name: "counter",
    description: "make a counter",
    async run(context) {
      const reply = await context.addReply("ok one sec")
      let times = 0

      while (true) {
        const counterId = `counter-${Math.random()}`
        const doneId = `done-${Math.random()}`

        await reply.edit(
          `button pressed ${times} times`,
          actionRowComponent(
            buttonComponent({
              style: "PRIMARY",
              label: "press it",
              customId: counterId,
            }),
            buttonComponent({
              style: "PRIMARY",
              label: "i'm bored",
              customId: doneId,
            })
          )
        )

        const interaction = await context.waitForInteraction()

        if (interaction?.customId === counterId) {
          times += 1
        }
        if (interaction?.customId === doneId) {
          break
        }
      }

      await reply.edit("well fine then")
    },
  },
]

FAQs

Package last updated on 14 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc