A Swiss Army knife kind of Discord bot, kind of.
The project implements a Python Discord bot that is hosted on AWS Lambda within a Docker Container. The infrastructure is managed using AWS Cloud Development Kit (CDK).
+----------------+ +----------------+ +--------------------+ +---------------------+
| Discord | HTTP | | | | | |
| (User Input) +------->+ API Gateway +------>+ AWS Lambda +--->+ CloudWatch Logs |
+----------------+ | | | | | |
+----------------+ | +--------------+ | +---------------------+
| | Docker Image | |
| +--------------+ |
| |
+---------+----------+
|
v
+-------------+
| AWS CDK |
+-------------+
- Generate inspirational and philosophical quotes
- Get current weather forecast by location and ISO 3166 country code
- Generate Discord timestamps
- Greet users in various languages
There are a few things that are required and set up before the bot can be used:
- Have Python 3.11 or higher installed
- Install
requirements.txtpip install -r requirements.txt
- Discord server to invite the Discord bot
- Discord API token
- Obtained via Discord Developer Portal by creating Discord app (bot)
- Create a
.envfile in the root project directory and store e.g. your Discord app token like soTOKEN=[your discord app token] - Invite the bot to your Discord server
- Configure AWS Credentials
- Ensure AWS CLI is set up
Required secrets in .env and AWS Lambda:
TOKEN- Discord bot tokenAPPLICATION_ID- Discord application idPUBLIC_KEY- Discord public keyWEATHER_API_KEY- OpenWeather API key
The bot must have application commands (slash commands) registered with Discord.
Run register_commands from the src directory
cd src
python -m commands.register_commands
Bootstrap the CDK
cdk bootstrap
Then, deploy
cdk deploy
The data used for this project were publicly sourced and were cleaned/transformed for this project.
iso_alpharefers to the ISO 3166-1 alpha-2 country code (249 officially assigned)iso_currency_country_namerefers to the country name used in ISO 4217 currency codescommon_namerefers to the name a country is commonly referred to
Countries were renamed to their commonly known names to allow for better usability
- Bolivia (Plurinational State of)
->Bolivia - Cocos (Keeling) Islands
->Cocos Islands - Congo
->Congo-Brazzaville - Democratic Republic of the Congo
->Congo-Kinshasa - Lao People's Democratic Republic
->Laos - Republic of Korea
->South Korea - Svalbard and Jan Mayen Islands -> Svalbard and Jan Mayen
- Syrian Arab Republic
->Syria - United States of America
->United States - Viet Nam
->Vietnam
- Åland Islands
- Côte d'Ivoire
- Curaçao
zone_namerefers to the TZ identifier from the tz database
- BV - Bouvet Island
- HM - Heard Island and McDonald Islands
- EH - Western Sahara
User interactions with the bot requires validation using
X-Signature-Ed25519as a signatureX-Signature-Timestampas a timestamp