Developing Async Python Discord Bots with discord.py and 24/7 Hosting
Build modern slash command bots using discord.py 2.0+, virtual environments, and continuous daemon supervision.
Intermedio6 minActualizado:13 de septiembre de 2026
Verificado: discord.py 2.xPython 3.11 / 3.12
En esta página
En esta página
Discord Bots guías
Modern Python Discord bot development leverages `discord.py` 2.0+ with asyncio concurrency. Using a clean virtual environment (`venv`) prevents library collisions across server workloads.
1. Modern Slash Command Template#
bot.py
import os
import discord
from discord import app_commands
from discord.ext import commands
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
await bot.tree.sync()
print(f"Bot aktif: {bot.user}")
@bot.tree.command(name="ping", description="Gecikme süresini ölçer")
async def ping(interaction: discord.Interaction):
latency = round(bot.latency * 1000)
await interaction.response.send_message(f"Pong! Gecikme: {latency}ms")
bot.run(os.getenv("DISCORD_TOKEN"))Comparación de métodos
¿Cómo implementar esto?
Clodo Control Panel Quick Method
Runtime selection in the panelThe Python runtime is selected in the panel; you do not install an OS or manage pip by hand.
¿Dónde en el panel? Panel > Service detail > 'Runtime' tab, then pick the Python version.
Ejecución paso a paso:
- 1Pick the Python version on the 'Runtime' tab.
- 2Upload bot.py and requirements.txt from the 'SFTP & Files' tab.
- 3Dependencies are installed from requirements.txt on boot, so keep that file current.
- 4Start the service and follow the logs in the panel console.
¿Te ha resultado útil esta guía?
Los comentarios van directamente al equipo que mantiene esta guía.
¿No encontró una solución?
Puede abrir una solicitud al equipo de soporte desde el panel.

