GithubHelp home page GithubHelp logo

radityaharya / ryo Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 577 KB

Ryo is a Discord bot that uses the Discord Interactions API. Built with Hono for Cloudflare Workers

Dockerfile 1.19% JavaScript 10.81% TypeScript 87.99%
discord-bot discord-interactions discord-email honojs

ryo's Introduction

Ryo

Ryo is a Discord bot that uses the Discord Interactions API to respond to slash commands. It's built using Hono for Cloudflare Workers, which allows you to run serverless functions at the edge of Cloudflare's network.

Features

  • Slash commands
  • Reddit Hot Posts from a Subreddit
  • Forwards Email to Discord using Cloudflare Email Routing

Configuring project

Before starting, you'll need a Discord app with the following permissions:

  • bot with the Send Messages and Use Slash Command permissions
  • applications.commands scope

⚙️ Permissions can be configured by clicking on the OAuth2 tab and using the URL Generator. After a URL is generated, you can install the app by pasting that URL into your browser and following the installation flow.

Email to Discord

This bot also has the ability to forward emails to a Discord channel. The worker will be registered as an Email Routing rule in Cloudflare. When an email is sent to the custom email address, it will be forwarded to the Discord channel using the Webhook URL (how to get Webhook URL [Doc])

Prerequisites:

  1. Have email routing enabled on a cloudflare Website [Doc]
  2. Authenticated Wrangler CLI setup [Doc]

Setup:

  1. Adding Webhook URL as Secret
  • Using Wrangler CLI
    wrangler secret put DISCORD_WEBHOOK_URL
    Paste Webhook URL
    ? Enter a secret value: ›
  1. Setting Worker as a rule for custom address
    1. In Cloudflare dashboard go to Email > Email Routing > Routes.
    2. Select Create address.
    3. In Custom address, enter the custom email address you want to use (for example, 'ryo').
    4. In the Action drop-down menu, choose "send to worker"
    5. Select "ryo" as the destination

Deploying

git clone https://github.com/radityaharya/ryo.git
cd ryo

To install the dependencies, run the following command:

npm install

Set up your environment variables by creating a .env file in the root of the project. You can use the example.env file as a template.

To deploy the app, you'll need to install the Wrangler CLI. Once installed, you can deploy the app using the following command:

wrangler deploy

The credentials in .env are only applied locally. The production service needs access to credentials from your app:

wrangler secret put DISCORD_TOKEN
wrangler secret put DISCORD_PUBLIC_KEY
wrangler secret put DISCORD_APPLICATION_ID
wrangler secret put DISCORD_WEBHOOK_URL
wrangler secret put BOT_SECRET

Setting up the bot

After deploying the app, you'll need to register the bot with Discord. You can do this by inputting your interactions URL into the Interactions Endpoint URL field in the General Information tab of the Discord Developer Portal.

Registering Commands

Commands should be registered with Discord using the register command after the bot has been deployed or when commands are updated.

npm run register

ryo's People

Contributors

radityaharya avatar dependabot[bot] avatar

Stargazers

yistc avatar  avatar Jonathan Beardstone avatar

Watchers

 avatar

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.