discord_bot container based on python
95
A lightweight, containerized base environment designed for building and running Discord bots with database connectivity. This image provides the essential dependencies, allowing you to easily plug in your own custom bot logic.
shinejh0528/python:3.13.8discord.py >= 2.3.0mysqlclient >= 2.2.0PyYAML >= 6.0gcc, pkg-config, default-libmysqlclient-dev).The container is designed to stay alive in the background upon execution. You can run the container and then execute your bot script inside it.
1. Run the container:
docker run -d --name agent_discord_bot shinejh0528/discode_bot:1.0.0
2. Execute your bot script:
Once your Python script is inside the container (e.g., via volume mount or docker cp), run it directly:
docker exec -it agent_discord_bot python your_bot_script.py
Here is a basic structural example of how to configure your discord.py script to run in this environment. You can manage your bot token and database connections using your preferred method (e.g., YAML config files or direct assignment) since environment variables are not strictly enforced.
import discord
from discord.ext import commands
# 1. Setup Intents
intents = discord.Intents.default()
intents.message_content = True
# 2. Initialize Bot
bot = commands.Bot(command_prefix='!', intents=intents)
# 3. Define Events
@bot.event
async def on_ready():
print(f'[INFO] Bot online as : {bot.user}')
@bot.event
async def on_message(message):
# Ignore messages from the bot itself
if message.author.bot:
return
print(f'#{message.channel.name} | {message.author.name} : {message.content}')
# Process other custom commands
await bot.process_commands(message)
# 4. Define Custom Commands
@bot.command(name='ping')
async def cmd_ping(ctx):
await ctx.send('pong!')
# 5. Run the Bot
if __name__ == "__main__":
# Insert your Discord bot token here
bot.run('YOUR_BOT_TOKEN')
Content type
Image
Digest
sha256:3944d9dd5…
Size
396.8 MB
Last updated
5 months ago
docker pull shinejh0528/discord_bot:1.0.0