Skip to content

A Discord bot that tells quotes, gets the weather, and more!

License

Notifications You must be signed in to change notification settings

Team-Gigabyte/quotobot

Repository files navigation

Quotobot

A Discord bot that displays 200+ hand-curated quotes, tells you the weather, fetches stock info, and more!

top.gg stats

Click to invite to your server Number of quotes

CI DeepScan grade DeepSource GitHub license Program Size GitHub release (latest SemVer)

Quotes screenshot Weather screenshot Stock screenshot

Or do you want to host and tweak the bot yourself?

How to set up the config.json

  • Make a copy of config-example.json and call it config.json.

  • Delete the entire line with "instructions" if you want to.

  • Change the prefix if you like (keep it inside the quotes).

  • Where it says "your-token-here", paste in your Discord bot token (also inside the quotes).

  • If you want the bot to output its invite link on startup, change

"clientID-example": "123456789012347",

to

"clientID": "123456789012347",

making sure to change the number to your client ID inside the quotes.

More info about the APIs.

You can add an OpenWeatherMap API key, Finnhub (stocks) key, and a Riot key in the same way. OpenWeatherMap and Finnhub are free and easy to get, but Riot needs you to submit an application to get a key. If any of these keys are missing, the bot won't crash – it'll just let the user know that the feature isn't working if they try to use it.

You can also change the status that the bot shows (it'll be prefixed with Watching, though) by changing the help-domain-example to help-domain (which will also be used by the Share to Twitter link) and adding your text in the value for that. Example complete config file:

{
    "prefix": "&&",
    "token": "abcdrkhjregjl.efghfioeigtj",
    "help-domain": "my-bot-site.qb",
    "clientID": "12343546798",
    "permissionValue": 0,
    "weather-token": "1jf920fk3",
    "weatherTimeout": 2000,
    "stockToken": "FinnhubKey92323032",
    "stockTimeout": 2000,
    "riotKey": "RGAPI-199020190912091",
    "leagueTimeout": 3000
}

The timeouts are optional and set in milliseconds.

Environment Variables instead of config.json

Instead of using the config.json, you can set environment variables. See the .env.example file for the variable names and details.

You can also use a .env file to set environment variables. Just copy the lines you want to use (lines starting with # are ignored) into a file in this same folder called .env. If you use this method, don't keep a config.json file in the same folder.

Note that there is currently no way to change stuff like the client ID this way.

Run the bot

Make sure you have Node.js >= 14 installed and open a command prompt/terminal in the folder where these files are. Then run:

npm install
node index.js

Press Control + C (even on a Mac) to stop the bot.

Run as a Docker container

docker build -t quotobot/quotobot .
  • Run this command to start the container:
docker run --name quotobot1 -d -v ./config.json:/app/config.json quotobot/quotobot

Note that the Dockerfile hasn't been tested so far.

Heroku notes

For Heroku, use the environment variables setup (it's called config vars in Heroku). You'll probably need to turn off the web dyno and turn on the worker dyno.

Keeping your copy up to date

If you used the git clone command to download the bot, just do

git pull origin

to update. If you want to switch to the version you had before, you can use

git checkout tags/v2.1.2

and replace 2.1.2 with whatever version you want. Then, to switch back to the latest code, use

git checkout master

We follow semver, so as long as the first number in the digit is the same as your old release, you shouldn't have to change anything to make the new release work.

Adding quotes

  • Don't modify anything in the quotes.db.csv or the .sql files, since those are auto-generated dumps.

Bulk CSV method (recommended)

You can do all of this from the GitHub web interface.

  1. Put your quotes in db/newQuotes.csv (the first column has the quote, the second is the author). Make sure the first column doesn't say what the columns are.
    • Make sure to not put a space between the fields.
    "This is wrong.", "Example Person"
    "This is right.","Example Person"
    
  2. Go here (link will be different if you're working on a fork) and click Run Workflow. Use the workflow from the master branch.
  3. After that's done (assuming there aren't any errors), check if the quotes are in db/quotes.db.csv. If they are, get rid of the quotes in newQuotes.csv.

JS method (not recommended; sometimes doesn't work)

Click here to see instructions.
  • Use the addQuote.js script, which will prompt you for the required info and add it to db/quotes.db.
  • Make sure to make your quotes the last commits before you push, otherwise you'll get merge conflicts. You can also take a look at the csvToDb.py file and experiment with that. (You'll need Python and SQLite for that, and you need to modify the file name in the script.)

Special thank you to Uddesh

We used part of his weather bot code and modified it for our project.

Tentative Timeline

Publish v1.0 of the bot: August 30 (by the latest): 70+ QUOTES! The quotes will be nice and embedded!

Future releases of the bot: We might periodically add more quotes and features, including general features unrelated to quotes! This is not certain to happen as school will restart and time to work on this project will be limited.

Contribute

Any pull requests are appreciated. If you want to add quotes, you can follow the process above, but only do step 1 and submit the pull request. Or, if you have problems with that process, open a GitHub issue with the quote, author, and a source (website that has the quote).

Future Updates

  • Steam Features: Playercount, Price History, etc.

Technical Notes

Built with JS

This bot mainly uses Node.js and Discord.js. The quotes are stored in an SQLite database and accessed using the sqlite3 module. The weather comes from OpenWeatherMap. (If you want to see the quotes without using SQLite, take a look at the quotes.db.csv file.)

Donate?

Donate today

Thank you for reading to the end. If you learned something from the bot, or have enjoyed using it, please consider donating here. All donations help us continue maintain this, which we have spent countless hours working on. Thank you!