A Discord bot that allows users to check weather for multiple locations from a Discord channel. Displays weather information in a clean, visually organized format.
- Both slash commands and text commands supported
- Check weather for specific locations using
/weather [location]or!weather <location> - Save multiple locations to check regularly
- Retrieve weather for all saved locations with
/weatheror!weather - Add new locations with
/addlocation <location>or!addlocation <location> - Remove locations with
/removelocation <location>or!removelocation <location> - List all saved locations with
/listlocationsor!listlocations - Get 5-day weather forecast with
/forecast <location>or!forecast <location> - Schedule automatic weather updates to a channel with
/addscheduleor!addschedule - Manage schedules with
/removeschedule,/listschedules - Get help with
/weatherhelpor!help
- Clean, modern Discord embed format
- Intuitive field-based information layout
- Emoji-based weather indicators
- Dynamic weather colors based on conditions
- Air quality information (when available)
- Interactive weather map links
-
Clone this repository:
git clone https://github.com/yourusername/discord-weather-bot.git cd discord-weather-bot -
Install dependencies:
npm install -
Create a
.envfile in the root directory with the following values:DISCORD_TOKEN=your_discord_bot_token OPENWEATHER_API_KEY=your_openweather_api_key CLIENT_ID=your_application_client_id GUILD_ID=optional_specific_guild_id -
Create a Discord bot and get a token:
- Go to Discord Developer Portal
- Create a new application
- Copy the "Application ID" (this is your CLIENT_ID)
- Navigate to the "Bot" tab and create a bot
- Click "Reset Token" to get your bot token
- Copy the token and add it to your
.envfile - Enable the "Message Content Intent" under Privileged Gateway Intents
- Use the OAuth2 URL Generator with "bot" scope and appropriate permissions to invite the bot to your server
-
Get an OpenWeather API key:
- Sign up at OpenWeather
- Generate an API key
- Add the API key to your
.envfile
-
Deploy slash commands:
npm run deploy-commands -
Start the bot:
npm startFor development with auto-restart:
npm run devTo keep the bot running 24/7:
npm run setup-pm2
/weather- Show weather for all saved locations/weather [location]- Show weather for a specific location/addlocation <location>- Add a location to saved locations/removelocation <location>- Remove a location from saved locations/listlocations- List all saved locations/forecast <location>- Get 5-day weather forecast/addschedule- Schedule automatic weather updates to a channel (options: channel, time, locations, timezone)/removeschedule <id>- Remove a scheduled update/listschedules- List all scheduled updates for this server/weatherhelp- Show help message with available commands
!weather- Show weather for all saved locations!weather <location>- Show weather for a specific location!addlocation <location>- Add a location to saved locations!removelocation <location>- Remove a location from saved locations!listlocations- List all saved locations!forecast <location>- Get 5-day weather forecast!addschedule <#channel> <HH:MM> [timezone] [locations]- Schedule automatic weather updates!removeschedule <id>- Remove a scheduled update!listschedules- List all scheduled updates for this server!help- Show help message with available commands
Shows all critical weather information in a clean, organized layout:
- Current conditions with descriptive emoji
- Temperature with "feels like" reading
- Humidity and wind information
- Cloudiness and visibility readings
- Air quality (when available)
- Links to weather maps
When checking multiple saved locations:
- Each location shows key information at a glance
- Current temperature and conditions
- Humidity and wind data
- Clear visual organization
Shows forecast with:
- Daily temperature ranges
- Precipitation probability
- Weather conditions
- Organized in a 2-column layout for easy reading
The bot stores location data in data/locations.json and schedule configurations in data/schedules.json. These files are created automatically when the first location or schedule is added.
To manage the bot with PM2:
- Start:
npm run setup-pm2 - Stop:
pm2 stop weather-bot - Delete:
pm2 delete weather-bot - Restart:
pm2 restart weather-bot --update-env - View logs:
npm run logs
MIT