Skip to content

A Discord bot to assist with all things theme parks.

Notifications You must be signed in to change notification settings

eric-vo/themeparkify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Themeparkify

A Discord bot to assist with all things theme parks.

image

How to Run:

  1. Create a new Discord application, or use an existing one. Invite the application's bot to your desired Discord server with bot and application.commands scopes.
  2. Ensure you have Python installed., and make sure it is added to PATH.
  3. Clone this repository.
  4. Open your terminal and navigate to the newly cloned repository.
  5. Create a file in the root directory of the cloned repository named .venv with the following:
    DISCORD_TOKEN=<YOUR_TOKEN>
    GUILD_ID=<YOUR_SERVER_ID>
    STATUS_CHANNEL_ID=<YOUR_CHANNEL_ID>
    WEATHER_API_KEY=<YOUR_API_KEY>
    
    where <YOUR_TOKEN> is your bot's token, <YOUR_SERVER_ID> is your desired Discord server's ID, <YOUR_CHANNEL_ID> is the ID of the channel you want status updates in, and <YOUR_API_KEY> is your OpenWeatherMap API key.
  6. Execute pip install -r requirements.txt in your terminal.
  7. Open your terminal and navigate to the newly cloned repository.
  8. Execute python bot.py in your terminal.

Description:

Themeparkify is a Discord bot that assists users with everything they need to plan their next trip to a theme park.

The bot includes features such as viewing the wait times, return times, operating hours, and wait forecasts for attractions. Users can also track when the wait time for a certain attraction reaches a certain threshold as well as get the weather forecast for a certain destination to get a sense of how hot/cold it may be.

This project revolves around the idea of adding destinations in which the user searches through to get the information they want. This improves the user experience so that the user doesn't have to worry about search errors resulting from attractions with the same name in different parks (e.g. Peter Pan's Flight in Disneyland California versus Disneyland Paris). Additionally, approaching the project this way improves searching times by reducing the number of destinations that must be searched.

To begin, bot.py is the bot's main entry point, containing all its registered commands. After initializing the bot with its token, it then begins the loop of checking attractions' wait times against the users' wait thresholds in the themeparkify.db database in the tracks table.

This process is facilitated by the helpers/track_attractions.py file, which loops through each attraction in the tracks table, gets the wait time associated with that attraction, then notifies the user if the wait time has reached their specified threshold. To add to the user experience, the location is also provided to differentiate between attractions in different destinations that may have the same name.

The bot's primary source for attraction data is the ThemeParks API, which contains useful information about theme parks, such as attractions, locations, and more. In this project, the API is accessed through various helper methods in the helpers/themeparks.py file, which add the ability to search for certain entities as well as access them directly.

commands/attraction.py houses all the code executed by commands pertaining to attractions. For example, there are commands for getting information for an attraction, tracking and untracking an attraction, viewing the attractions currently tracked, and clearing all tracked attractions. Getting information for an attraction uses the API to retrieve information like wait time and operating hours.

An interesting feature in attraction data for Disney theme parks is the wait forecast, which provides predicted wait times by hour. When getting attraction information, a graph of this forecast will also be provided if it is available, using Matplotlib to easily generate a graph through Python.

commands/destination.py works similarly to commands/attraction.py in where there is the ability to add and remove a destination, view added destinations, and clear all added destinations.

commands/sync.py allows the bot to sync its commands with the guild, as this must be manually done. It cannot be done on bot startup due to rate limits that may affect its ability to do so.

commands/weather.py includes the code for performing weather forecasts. This file uses the OpenWeatherMap API to retrieve future weather data based on a provided latitude and longitude, which is provided from destinations by the ThemeParks API. Based on the provided destination name, the code searches through a user's list of destinations for the destination, gets the latitude and logitude, makes an API request for the weather, then generates a graph of the weather for the next five days at that location using Matplotlib.

helpers/database.py offers helper methods for interacting with the themeparkify.db database using CS50's SQL module. Adding on to the original ability to execute SQL code, commonly repeated code such as getting the user's destination IDs and tracked attractions is also bundled into helper methods in this file.

helpers/decorators.py includes a decorator that checks if the user has any added destinations. This is useful when the user wants to search for an attraction or get the weather as it will notify the user that the command will not work without any added destinations.

helpers/embed.py contains useful functions for creating and modifying Discord embeds, such as generating errors or adding entities and their locations to the embed as fields.

.env contains information like tokens, IDs, and API keys necessary for the bot to function. This file is declared in .gitignore.

.gitignore ignores any non-important or sensitive files that should not be committed to the Git repository.

requirements.txt lists the necessary pip modules for this project to work. These dependencies can be installed using pip install -r requirements.txt.

themeparkify.db is the database that contains users' added destinations and tracked attractions.

In the future, features such as showtime and attraction return time reminders as well as restaurant information may be added. Including the travel time from one destination to another may also prove to be useful to users.