MockBot is a fun and interactive Discord bot that mocks users by alternating the case of their messages. It is hosted on Azure Container Instances (ACI) and deployed using Docker. This project demonstrates my skills in Python, Docker, Azure, and DevOps.
- Mock Command: Mocks a user's last message in the current channel.
- Slash Commands: Built using
py-cordfor seamless integration with Discord. - Azure Hosting: Deployed on Azure Container Instances for scalability and reliability.
- Dockerized: Containerized for easy deployment and environment consistency.
- Programming Language: Python
- Libraries:
py-cord(Discord API wrapper) - Cloud Platform: Microsoft Azure
- Azure Container Instances (ACI)
- Azure Container Registry (ACR)
- Containerization: Docker
- Version Control: Git/GitHub
- The bot listens for the
/mock @Usercommand or/mock [message]in a Discord channel. - It fetches the last 20 messages in the channel and finds the most recent message from the specified user.
- The bot mocks the message by alternating uppercase and lowercase letters.
- The mocked message is sent back to the channel.
-
Clone the Repository:
git clone https://github.com/your-username/mockbot.git cd mockbot -
Install Dependencies:
pip install -r requirements.txt
-
Set Environment Variables: Create a
.envfile in the root directory:DISCORD_TOKEN=your_discord_bot_token -
Run the Bot Locally:
python bot.py
-
Build the Docker Image:
docker build -t mockbot . -
Run the Docker Container Locally:
docker run -e DISCORD_TOKEN=your_discord_bot_token mockbot
-
Create an Azure Container Registry (ACR):
az acr create --resource-group <YourResourceGroup> --name <YourRegistryName> --sku Basic
-
Log in to ACR:
az acr login --name <YourRegistryName>
-
Tag and Push the Docker Image:
docker tag mockbot <YourRegistryName>.azurecr.io/mockbot:latest docker push <YourRegistryName>.azurecr.io/mockbot:latest
- There can be issues with Azure Container Instance reconizing your OS in docker. You may need to specify the Linux architecture like I did:
docker buildx build --platform linux/amd64 -t mockbotregistry.azurecr.io/mockbot:v2 --push .
-
Create an Azure Container Instance (ACI):
az container create \ --resource-group Discord.bot \ --name mockbot-container \ --image mockbotregistry.azurecr.io/mockbot:latest \ --cpu 1 \ --memory 1 \ --registry-login-server mockbotregistry.azurecr.io \ --registry-username mockbotregistry \ --registry-password your_password --environment-variables DISCORD_TOKEN=your_discord_bot_token/ --restart-policy Always \ --location your_server_location --os-type Linux
-
Verify Deployment: Check the status of your container instance:
az container show --resource-group <YourResourceGroup> --name mockbot --query "instanceView.state"
- Python 3.9 or higher
- Docker installed locally
- Azure account (free tier available)
- Discord bot token (from the Discord Developer Portal)
- Clone the Repository:
git clone https://github.com/your-username/mockbot.git cd mockbot