Socket
Socket
Sign inDemoInstall

@danreeves/helper-bot

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @danreeves/helper-bot

A framework around [Discord.js](https://discord.js.org) for implementing simple bot behaviour in bite-sized chunks.


Version published
Weekly downloads
1
Maintainers
1
Install size
1.30 MB
Created
Weekly downloads
 

Readme

Source

Helper Bot 🤖

A framework around Discord.js for implementing simple bot behaviour in bite-sized chunks.

The code

Check out index.js to see how it works ✨. It's really quite simple, so it might be better to read example.js and the provided middlewares to see how to use it.

Usage

const HelperBot = require('@danreeves/helper-bot')

const bot = new HelperBot(process.env.DISCORD_BOT_TOKEN)

bot.use(new Middleware())

bot.start()

API

Constructor

new HelperBot(DISCORD_BOT_TOKEN: string)

The constructor takes the Discord bot token as an argument and returns an instance.

.use

.use(middleware: HelperBotMiddleware)

Add a new middleware to the HelperBot instance. See the Middleware API

.start

.start()

Logs the bot into Discord and begins listening for events.

Middleware

A HelperBot middleware is an object that can implement any of the following methods:

userJoin

userJoin(guildMember, state, kill)

Called when a member joins a server.

See Discord.js docs

message

message(message, state, kill)

Called when a message is recieved.

See Discord.js docs

reactionAdd

reactionAdd(reaction, user, state, kill)

Called when a reaction is added to a message.

See Discord.js docs

reactionRemove

reactionRemove(reaction, user, state, kill)

Called when a reaction is removed from a message.

See Discord.js docs

voiceStateUpdate

voiceStateUpdate(oldUser, newUser)

Called whenever a user changes voice state - e.g. joins/leaves a channel, mutes/unmutes.

See Discord.js docs

Common arguments

The last two arguments to a middleware method are always state and kill.

state is a mutable object that is passed to every middleware in the chain. This lets you pass state down to preceding middleware.

kill is a function that when called will end the middleware chain and prevent preceding middleware from being triggered.

FAQs

Last updated on 18 Nov 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc