Giter VIP home page Giter VIP logo

discord-bot's Introduction

Rod of Discord

Rod 2.0 is released! You can check out https://rodbot.io/ for reference and guides.

Join the discord: https://discord.gg/MvdRurG

For Developers

I'm going to sort of assume you know how to program and have used Rod before for the next bit, and just do a high-level overview. Rod2 uses an express.js type of structure to handle messages and is backed by a Mongo database, which we access with the Mongoose driver.

Discord message received
   |
   |
   V
Create RodRequest and RodResponse objects
   |
   |
   V
Determine if bot should process message
via escape char etc.
   |
   |
   V
Run pre-processing middleware
   |
   |
   V
Run the handler
   |
   |
   V
Run post-processing middleware
   |
   |
   V
Send message response

Middleware and handlers are auto-detected by just dropping the files in the corresponding folders. You'll see a message on start-up about what's been detected.

RodRequest and RodResponse

RodRequest holds all the information about the incoming message. The actual message object, the author, the server it was sent on, etc. The RodResponse object hold everything about the message we're going to send in response (if any).

Handlers

Handlers in Rod2 are groups of commands with similar functionality, but if you so chose, each command could have their own handler. You'll also see a few of the handlers are subclasses of MultiCommandHandler, which just abstracts away some of the nitty gritty about processing the commands.

Middleware

Middleware is processing that happens to a message before the command (if there is one) is processed. This is where logic like "is this author supposed to be talking as an alias" sort of things are processed. Negative priority middleware is simply processed after the handler goes. For instance the "call" middleware runs after the handler because it wants to detect rolls after they've been processed.

Questions

If you have any questions, hop in the Discord and ask.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.