Средний6 minОбновлено: 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.

Проверено на

discord.py
2.x
Python
3.11 / 3.12
Последняя проверка
2026-09-13
На этой странице
Все руководства
Прогресс чтения

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"))
Сравнение способов

Как это сделать?

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.

Где в панели? Panel > Service detail > 'Runtime' tab, then pick the Python version.
Пошагово:
  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.

Было ли руководство полезным?

Отзыв сразу попадает команде, которая ведёт это руководство.

Похожие руководства