Fortgeschritten6 minAktualisiert: 2026-09-13

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.

Geprüft mit

discord.py
2.x
Python
3.11 / 3.12
Zuletzt geprüft
2026-09-13
Auf dieser Seite
Alle Anleitungen
Lesefortschritt

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"))
Methodenvergleich

Wie setzt man das um?

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.

Wo im Panel? Panel > Service detail > 'Runtime' tab, then pick the Python version.
Schritt für Schritt:
  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.

War diese Anleitung hilfreich?

Feedback geht direkt an das Team, das diese Anleitung pflegt.

Verwandte Anleitungen