Skip to content

A bot to share recipes, view your impact as a vegan/vegetarian, and learn about animal agriculture with trivia. Designed for Compassionate Action for Animals student group at the University of Minnesota.

License

Notifications You must be signed in to change notification settings

r-sauers/compassionate-action-for-animals-bot

 
 

Repository files navigation

[IN DEVELOPMENT] Compassionate Action for Animals Discord Bot

This discord bot is for Compassionate Action for Animals, an animal rights student group at the University of Minnesota. It will provide the following features:

  • Trivia [not implemented]
    • Play trivia to have fun and learn more about veganism!
    • Helpful for preparing for outreach/debates.
    • Contains trivia on nutrition, animal welfare, and the environment.
  • Recipes [not implemented]
    • Share recipes in your server!
    • Vote on your favorite recipes!
    • Find out the nutrition content of those recipes!
  • Impact [not implemented]
    • View your personal impact after going vegetarian/vegan! How many animals have you saved? How many trees? How much CO2?
    • View the server's impact as a whole!

Running app locally

This bot is currently only run locally, please follow the instructions adapted from the Discord Example App

Before you start, you'll need to install NodeJS and create a Discord app with the proper permissions:

  • applications.commands
  • bot (with Send Messages enabled)

Configuring the app is covered in detail in the getting started guide.

Setup project

First clone the project:

git clone https://github.com/r-sauers/compassionate-action-for-animals-bot.git

Then navigate to its directory and install dependencies:

cd compassionate-action-for-animals-bot
npm install

Get app credentials

Fetch the credentials from your app's settings and add them to a .env file. You'll need your app ID (APP_ID), bot token (DISCORD_TOKEN), and public key (PUBLIC_KEY).

Fetching credentials is covered in detail in the getting started guide.

🔑 Environment variables can be added to the .env file in Glitch or when developing locally, and in the Secrets tab in Replit (the lock icon on the left).

Install slash commands

The commands for the example app are set up in commands.js. All of the commands in the ALL_COMMANDS array at the bottom of commands.js will be installed when you run the register command configured in package.json:

npm run register

Run the app

After your credentials are added, go ahead and run the app:

node app.js

⚙️ A package like nodemon, which watches for local changes and restarts your app, may be helpful while locally developing.

If you aren't following the getting started guide, you can move the contents of examples/app.js (the finished app.js file) to the top-level app.js.

Set up interactivity

The project needs a public endpoint where Discord can send requests. To develop and test locally, you can use something like ngrok to tunnel HTTP traffic.

Install ngrok if you haven't already, then start listening on port 3000:

ngrok http 3000

You should see your connection open:

Tunnel Status                 online
Version                       2.0/2.0
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://1234-someurl.ngrok.io -> localhost:3000
Forwarding                    https://1234-someurl.ngrok.io -> localhost:3000

Connections                  ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

Copy the forwarding address that starts with https, in this case https://1234-someurl.ngrok.io, then go to your app's settings.

On the General Information tab, there will be an Interactions Endpoint URL. Paste your ngrok address there, and append /interactions to it (https://1234-someurl.ngrok.io/interactions in the example).

Click Save Changes, and your app should be ready to run 🚀

About

A bot to share recipes, view your impact as a vegan/vegetarian, and learn about animal agriculture with trivia. Designed for Compassionate Action for Animals student group at the University of Minnesota.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%