Passer au contenu
Clodo

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.

Intermédiaire6 minMis à jour :13 septembre 2026
Vérifié : discord.py 2.xPython 3.11 / 3.12

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"))
Comparaison des méthodes

Comment implémenter cela ?

Clodo Control Panel Quick Method

Runtime selection in the panel

The Python runtime is selected in the panel; you do not install an OS or manage pip by hand.

Où dans le panneau ? Panel > Service detail > 'Runtime' tab, then pick the Python version.
Exécution étape par étape :
  1. 1Pick the Python version on the 'Runtime' tab.
  2. 2Upload bot.py and requirements.txt from the 'SFTP & Files' tab.
  3. 3Dependencies are installed from requirements.txt on boot, so keep that file current.
  4. 4Start the service and follow the logs in the panel console.

Ce guide vous a-t-il été utile ?

Les retours sont directement transmis à l'équipe qui maintient ce guide.

Vous n’avez pas trouvé de solution ?

Vous pouvez ouvrir une demande auprès de notre équipe d’assistance depuis le panneau.

Ouvrir une demande