Skip to content

AntonVanAssche/joke-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Joke-bot

Simple Discord bot to tell random jokes.
· Report Bug · Request Feature

preview

How it works

Currently the bot uses five different APIs to get the jokes, memes and pickup lines. One of which is the JokeAPI used to get the random jokes. This API is a highly customizable API, open source and free to use for everyone. It allows you to fetch random jokes from a variety of categories, such as programming, misc, dark, pun, spooky and christmas, making it the perfect API for this bot.

The second API used is a Reddit API that returns Reddit posts in JSON format. This is a basic API that I made myself, you can find it on GitHub. This API is intended to be hosted locally, so there is no remote URL to use.

The third API used is the pickup-lines-api. This is a free API that can be used to get random pickup lines. The only downside is that it requires an API key, which you can get for free by signing up on RapidAPI.

The fourth API used is the Evil Insult Generator. This API is used by the !insult command to get a random insult.

The last API used is the complimentr. This API is used by the !compliment command to get a random insult.

Commands

Underneath you will find a list of commands that the bot can perform.

Command Description Usage
help Shows a help message !help
ping Show the bot latency !ping
stats Show the bot's statistics !stats
joke Shows a random joke !joke
category Shows a random joke from a specific category !category <category>
Categories:
  • programming
  • misc
  • dark
  • pun
  • spooky
  • christmas
pickup-line Shows a random pickup line !pickup-line
insult Shows a random insult, or insults a mentioned user !insult
!insult @username
compliment Shows a random compliment, or compliments a mentioned user !compliment
!compliment @username
pp-size Shows the size of a mentioned user's "pp" (or yours if no user is mentioned) !pp-size
!pp-size @user
how-gay Shows the level of gayness of a mentioned user (or yours if no user is mentioned) !how-gay
!how-gay @usern
lovemeter Shows the love level between two mentioned users, or between you and a mentioned user !lovemeter @user1 @user2
!lovemeter @user
8ball Ask the magic 8-ball a question !8ball <question>
meme Shows a random meme from Reddit !meme

Note: The default prefix is a !, this can be changed within the config.json file.

Do you have a recommendation for a new command? Feel free to submit them here.

Installation

There are two ways to use the bot, either by running it directly on your machine or by running it within a Docker container. Regardless of the method you choose, you'll need to follow these initial steps:

  1. Clone the repository by running the following command in your terminal:
$ git clone https://github.com/AntonVanAssche/joke-bot.git
$ cd joke-bot
  1. Update the config.json file, located within the source directory (src/), with your bot token. You can find the token in the Bot Settings of your bot under the Bot tab. If you wish to change the prefix of the bot, you can do so in the config.json file. This is by default !.
{
    "prefix": "---YOUR-BOT-PREFIX---",
    "token": "---PLACE-YOUR-TOKEN-HERE---"
}
  1. Since the pickup-lines-api requires an API key, you will have to create a .env file in the root directory of the project. This file will contain the API key. You can get the API key by signing up on RapidAPI.
$ echo "RAPID_API_TOKEN='<YOUR-API-TOKEN>'" > ./src/.env

Running the bot directly

If you choose to run the bot directly, follow these additional steps:

  1. Install the dependencies by running the following command in your terminal:
$ npm install
  1. Start the bot by running the following command in your terminal:
$ cd src/
$ node ./index.js

Running the bot within a Docker container

If you choose to run the bot within a Docker container, follow these additional steps:

  1. Build the Docker image by running the following command in your terminal:
$ docker run joke-bot        # Run the bot in the foreground.
$ docker run -d joke-bot     # Run the bot in the background.

That's it! You can now use the bot by sending a message to the bot with the !joke command. If you encountered any issues while installing the bot, feel free to report them.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag enhancement. Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for more information.

Feedback

This project isn't perfect, therefore suggestions/improvements are always welcome!