Skip to content

A Discord bot to save memorable quotes from your friends. Currently storing 3,500+ quotes from 150+ servers.

License

Notifications You must be signed in to change notification settings

AlecM33/quote-bot

Repository files navigation

quote-bot

Add this bot to your server here.

/add - add a quote by a specified author.
/random - display a random quote, optionally by author.
/authors - get a sorted list of unique authors of saved quotes.
/search - search for quotes by a string of text.
/delete - Works similarly to /search - find quotes by a word or phrase, and the bot will display buttons to delete the quote of your choice from the results.
/download - (response visible to only the sender) receive a text file containing all your server's quotes.
/wordcloud - Generate a colorful cloud of words from the quotes said in your server! The size of a word is proportional to how often it's been said.
/count - get the number of quotes saved, optionally by author.
/help - (response visible to only the sender) info on the bot and how to use it, the privacy policy, and support resources.
/updates - (response visible to only the sender) latest info on changes to the bot.

image

34ce20f52d819ca29083f77b7e87ebe7-ezgif com-crop

Tech Stack

The bot is written in javascript and makes heavy use of discord.js, which is a wrapper around the Discord API (view the developer documentation).

I currently host the bot using the Heroku Cloud Platform. The bot speaks to a PostgreSQL instance hosted for free using Aiven.

Running your own instance of the bot

Stored quotes are associated with a specific guild, so you can safely add the same instance of the bot to multiple servers.

For the bot to run, you need to populate 3 environment variables referenced within the code. These are process.env.CLIENT_ID, process.env.DATABASE_URL, and process.env.TOKEN. Read below for how to obtain these.

  1. You'll need to create a discord application through the developer portal. Your application will be assigned an "Application ID" (aka client id), which can be referenced in the "General Information" section. This will be the value of process.env.CLIENT_ID.

  2. Within that application, you'll need to add a bot. Within the "Bot" section of the application, you'll see the option to generate a token. This is the authentication token for your bot (and is thus very sensitive data). This will be the value of process.env.TOKEN.


  1. You will need an instance of a PostgreSQL database, preferably version 14 to ensure compatibility with the "citext" extension - see "Database Schema" below. process.env.DATABASE_URL will need to be the value of the connection string for this database. That connection string will be structured like so:

    postgres://your-username:your-password@your-host:your-port/your-database-name.

  2. You'll need to populate the database with the appropriate schema. See the "Database Schema" section.

  3. You'll need to add the bot to your desired server. Within the "Bot" section of your Discord application, you can create a permissions integer that will be added to the OAuth link for a given bot. I recommend, at minimum, the "Send Messages", "Send Messages in Threads", and "Use Slash Commands" permissions, which produce integer 277025392640. The link to add the bot would then be the following, with your application ID substituted in:

    https://discord.com/oauth2/authorize?client_id=your-application-id&permissions=277025392640&scope=bot

  4. Lastly, run the bot on your chosen server with npm start. The bot should log in, and within the server you should see it's slash commands available by simply typing /.

Database Schema

see database/schema.sql.

documentation for the "citext" datatype for PostgreSQL 14: https://www.postgresql.org/docs/current/citext.html

About

A Discord bot to save memorable quotes from your friends. Currently storing 3,500+ quotes from 150+ servers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published