This project is a Discord bot that provides weather forecasts for specified locations. It utilizes the WeatherAPI for weather data and the Discord API for bot interactions.
- β¨ Features
- βοΈ Prerequisites
- π₯ Installation
- π οΈ Configuration
- π Running the Bot
- π Getting API Keys
- π¬ Commands
- πΈ Preview
- Provides 3-day weather forecasts for a specified location.
- Supports both metric and imperial units.
/forecast
command for fetching weather information./astro
command for fetching astrological information.
- Bun β A fast all-in-one JavaScript runtime and package manager
- TypeScript β A strongly typed programming language built on JavaScript
- Clone the repository:
git clone https://github.com/AdrianTomin/discord-bot.git cd discord-bot
- Install dependencies:
bun install
Create a .env
file in the root of the project and add the required API keys as shown below:
DISCORD_TOKEN=your_discord_token_here
WEATHER_API_KEY=your_weatherapi_key_here
GUILD_ID=your_guild_id_here
CLIENT_ID=your_client_id_here
- Go to WeatherAPI and sign up for a free account.
- Once logged in, navigate to your API key dashboard to retrieve your key.
- Go to the Discord Developer Portal.
- Create a new application or select an existing one.
- Add a bot to your application Under the Bot section, then copy the Token under the "Token" section.
- Open Discord and navigate to your server.
- Right-click on the server name and select Copy ID (make sure Developer Mode is enabled in Discord settings).
- In the Discord Developer Portal, go to your application.
- Copy the Application ID from the General Information section (this is your
CLIENT_ID
).
You can run the bot after setting up your environment variables in the .env
file.
bun run start
The bot should now be online and ready to respond to commands in your Discord server.
Provides a weather forecast for a specified location with options for metric or imperial units.
Option | Type | Description |
---|---|---|
location | String | Required. Specifies the location for the weather forecast. Accepts city name, postal code, or coordinates. |
units | String | Optional. Sets the unit system for the forecast. Options are "metric" (default) or "imperial". |
Provides the moonrise/set and sunrise/set astrological data for a specified location.
Option | Type | Description |
---|---|---|
location | String | Required. Specifies the location for the weather forecast. Accepts city name, postal code, or coordinates. |
Here are some screenshots to give you a glimpse of the Discord Weather Forecast Bot in action!