Coder Social home page Coder Social logo

hybrid-bot's Introduction

hybrid-bot

This is a serverless/serverful Discord bot in Redwood.

Discord bots need a process running, with a client connection. It is a lot like pgbouncer which provides a serverless application access to the database.

Running

First, copy .env.example to .env, and set DATABASE_URL and TEST_DATABASE_URL.

Then, create a bot on Discord with the send messages permission, and copy the bot token, and place it in .env.

To run the bot, run yarn rw build api && yarn workspace api start-bot.

How it works

The bot runs inside of the API. It is not a serverless function, but is in lib.

The Discord.js client library is installed in the API using Yarn workspaces:

yarn workspace api add discord.js

The server is in api/src/lib/bot/index.js. The following line in it loads the .env and initializes Redwood:

import '@redwoodjs/api'

This is added to scripts in api/package.json:

  "scripts": {
    "start-bot": "node dist/lib/bot"
  }

Todo

  • Use the Redwood app, including serverless functions, to do something useful, and show them running neatly side-by-side!
  • Document deployment of the serverless portion to Netlify/Vercel and the serverful portion to DigitalOcean/Vultr
  • Add deployment to the build step
  • Keep track of the bot status in the database, and let admin administrate it in the app
  • Add a word about making the entire app serverful
  • Investigate self-hosted serverless with OpenFaaS

Demo

There is a bot called @hybrid-bot running in the Resources.co Discord community. It will reply when you mention it.

hybrid-bot's People

Contributors

benatkin avatar

Stargazers

 avatar Cole Townsend avatar

Watchers

 avatar James Cloos avatar

Forkers

cyberflamego

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.