본문으로 건너뛰기

가이드 · 디스코드 봇

Python 봇 올리기 (discord.py)

main.py + .env 올리기 → 시작.

1. 준비

2. 파일 두 개

main.py

import os
import discord
from discord import app_commands
from dotenv import load_dotenv

load_dotenv()
client = discord.Client(intents=discord.Intents.default())
tree = app_commands.CommandTree(client)

@tree.command(name="ping", description="응답 속도")
async def ping(interaction: discord.Interaction):
    await interaction.response.send_message(f"pong {round(client.latency * 1000)}ms")

@client.event
async def on_ready():
    await tree.sync()
    print(f"로그인: {client.user}")

client.run(os.getenv("TOKEN"))

.env (토큰은 코드에 넣지 않습니다)

TOKEN=복사한_토큰

3. 올리기 · 시작

  1. 서비스 화면 → 패널 열기 → 파일 → 올리기 (.env는 새 파일로 만들어도 됨).
  2. 콘솔 → 시작.
  3. 콘솔에 코드에서 쓰는 패키지를 설치합니다: discord.py python-dotenv → 봇을 시작합니다: main.py → 로그인: ….
  4. 디스코드에서 /ping. 처음에는 명령이 보이기까지 몇 분 걸릴 수 있습니다.

4. 자동으로 해 주는 것

  • 시작 파일: main.py → bot.py → app.py → index.py · run.py · start.py → .py가 하나면 그것.
  • 패키지: import한 것 중 없는 것 설치 (discord → discord.py, dotenv → python-dotenv). requirements.txt가 있으면 바뀔 때마다 설치.
  • 직접 정하기: 패널 시작 설정 → 시작 파일 · 추가 패키지.
  • venv · __pycache__는 올리지 않습니다.

5. 메시지 읽는 봇 (접두사 명령)

  1. Developer Portal → 내 앱 → Bot → Message Content Intent 켜기.
  2. 코드: intents = discord.Intents.default() → intents.message_content = True.

6. GitHub에서 받기 (선택)

  • 패널 시작 설정 → Git 주소 · Git 브랜치 (비공개면 Git 사용자 이름 · Git 토큰).
  • 서버 파일이 비어 있을 때 설정 → 서버 재설치 → 저장소를 받습니다.
  • 자동 업데이트 1 → 시작할 때마다 git pull.
  • .env는 저장소에 넣지 말고 패널 파일에 따로 만듭니다.

가이드 전체 디스코드 봇 요금제 문의하기

제휴 봇 제작 외주 이어드림 커스텀 봇 · 컴포넌트 V2 · 웹 · 프로그램 · 로고 · 배너 · UI/UX 디스코드에서 문의