A simple and fast Discord bot that fetches real-time weather info for any city using WeatherAPI.
Built with Python and discord.py, and deployable for free on Railway.
- 🌤 Slash command:
/weather [city] - 🌡 Current temperature, humidity, and condition
- 🔐 Secure secrets via
.envor Railway variables - ⚡ Hosted for free using Railway (no port required)
- Python 3.9+
- Discord bot from discord.com/developers
- WeatherAPI key from weatherapi.com
weather-discord-bot/
├── weatherapi_bot.py # Main bot logic
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
└── README.md # Project documentation
-
Clone the repository
git clone https://github.com/YOUR_USERNAME/weather-discord-bot.git cd weather-discord-bot -
Install dependencies
pip install -r requirements.txt
-
Create a
.envfileDISCORD_TOKEN=your_discord_token WEATHER_API_KEY=your_weatherapi_key GUILD_ID=your_guild_id_as_number
-
Run the bot
python weatherapi_bot.py
-
Go to https://railway.app
-
Click “New Project” → “Deploy from GitHub Repo”
-
Choose your
weather-discord-botrepo -
Under the Variables tab, add:
Key Value DISCORD_TOKENYour Discord bot token WEATHER_API_KEYYour WeatherAPI key GUILD_IDYour Discord server ID -
Under Settings, change the Start Command to:
python weatherapi_bot.py
-
Click "Deploy" and check the logs for successful startup.
/weather Tokyo
**Weather for Tokyo, Japan**
🌡 Temperature: 27°C (Feels like 29°C)
💧 Humidity: 60%
☁ Condition: Clear
DISCORD_TOKEN=your_discord_token_here
WEATHER_API_KEY=your_weatherapi_key_here
GUILD_ID=your_guild_id_here
⚠️ Do not commit your real.envfile.
discord.pyweatherapi.compython-dotenv- Railway for hosting
Forks and pull requests are welcome!
MIT — free to use and modify
Created by @qbcx