@danreeves/helper-bot

0.2.1 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @danreeves/helper-bot

Weekly Downloads

0

Version

0.2.1

License

none

Unpacked Size

12.6 kB

Total Files

14

Last publish

Collaborators

  • danreeves