Thursday, November 20, 2025

Today's Paper

BREAKING NEWS Gemini 3.0 Released: Everything You Need to Know | MARKET UPDATE NVIDIA Surpasses Apple in Market Cap | TRENDING How to Build Your Own AI Agent in 2025
Tech Analysis Insight

Discord 봇 만들기: AI 통합 완벽 가이드 - MUMULAB

코딩 초보자도 따라 할 수 있는 Discord AI 봇 개발 가이드입니다. 실제 Discord 서버에서 2개월간 운영하며 검증한 완벽한 단계별 튜토리얼을 제공합니다. 프로그래밍 경험이 전혀 없어도 1시간 안에 나만의 AI 봇을 만들 수 있습니다.

M

By MUMULAB

2025-10-26 • 5 min read

Discord 봇 만들기: AI 통합 완벽 가이드 - MUMULAB
🎮 봇2025년 10월 26일

Discord 봇 만들기: AI 통합 완벽 가이드

코딩 초보자도 따라 할 수 있는 Discord AI 봇 개발 가이드입니다. 실제 Discord 서버에서 2개월간 운영하며 검증한 완벽한 단계별 튜토리얼을 제공합니다. 프로그래밍 경험이 전혀 없어도 1시간 안에 나만의 AI 봇을 만들 수 있습니다.

1. Discord Developer Portal 설정 (5분)

단계별 가이드:

  1. Discord 개발자 포털 접속: https://discord.com/developers/applications
  2. New Application 클릭: 봇 이름 입력 (예: MyAI-Bot)
  3. Bot 메뉴 이동: 왼쪽 사이드바 → Bot 클릭
  4. Add Bot 버튼: "Yes, do it!" 확인
  5. Privileged Gateway Intents 활성화: - MESSAGE CONTENT INTENT: 메시지 내용 읽기 - SERVER MEMBERS INTENT: 서버 멤버 정보 접근 - PRESENCE INTENT: 사용자 상태 정보 접근

권한 설정 (OAuth2 → URL Generator):

  • SCOPES: bot, applications.commands
  • BOT PERMISSIONS: Send Messages, Read Messages, Manage Messages, Embed Links
  • 생성된 URL로 봇을 서버에 초대

2. 개발 환경 구축 (10분)

필수 도구 설치:

# Node.js 설치 (https://nodejs.org/)
node --version  # 확인: v18 이상 권장

# 프로젝트 폴더 생성
mkdir discord-ai-bot && cd discord-ai-bot

# 패키지 초기화
npm init -y

# 필수 라이브러리 설치
npm install discord.js openai dotenv

.env 파일 생성 (보안 설정):

DISCORD_TOKEN=여기에_봇_토큰_입력
OPENAI_API_KEY=여기에_OpenAI_API_키_입력

3. 기본 봇 코드 구현 (15분)

index.js 파일 작성:

const { Client, GatewayIntentBits } = require('discord.js');
const OpenAI = require('openai');
require('dotenv').config();

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

// 봇 준비 완료 이벤트
client.once('ready', () => {
  console.log(`✅ ${client.user.tag} 봇이 온라인입니다!`);
});

// 메시지 수신 처리
client.on('messageCreate', async (message) => {
  // 봇 자신의 메시지 무시
  if (message.author.bot) return;

  // !ask 명령어 처리
  if (message.content.startsWith('!ask ')) {
    const question = message.content.slice(5);

    try {
      const response = await openai.chat.completions.create({
        model: 'gpt-4',
        messages: [{ role: 'user', content: question }],
        max_tokens: 500,
      });

      const answer = response.choices[0].message.content;
      message.reply(answer);
    } catch (error) {
      message.reply('❌ AI 응답 생성 중 오류가 발생했습니다.');
      console.error(error);
    }
  }
});

client.login(process.env.DISCORD_TOKEN);

4. 고급 AI 기능 추가

A. 이미지 생성 기능 (DALL-E):

if (message.content.startsWith('!image ')) {
  const prompt = message.content.slice(7);

  const image = await openai.images.generate({
    model: 'dall-e-3',
    prompt: prompt,
    n: 1,
    size: '1024x1024',
  });

  message.reply({
    content: `🎨 생성된 이미지:`,
    files: [image.data[0].url]
  });
}

B. 요약 기능:

if (message.content.startsWith('!summarize ')) {
  const text = message.content.slice(11);

  const summary = await openai.chat.completions.create({
    model: 'gpt-4',
    messages: [{
      role: 'system',
      content: '다음 텍스트를 3줄로 요약해주세요.'
    }, {
      role: 'user',
      content: text
    }],
  });

  message.reply(summary.choices[0].message.content);
}

C. 다국어 번역:

if (message.content.startsWith('!translate ')) {
  const text = message.content.slice(11);

  const translation = await openai.chat.completions.create({
    model: 'gpt-4',
    messages: [{
      role: 'system',
      content: '다음 텍스트를 영어로 번역해주세요.'
    }, {
      role: 'user',
      content: text
    }],
  });

  message.reply(translation.choices[0].message.content);
}

5. 서버 배포 (24/7 운영)

옵션 1: Heroku (무료 → 유료 전환)

  • Heroku CLI 설치 후 프로젝트 푸시
  • 비용: 월 $7 (Eco Dyno)
  • 장점: 간편한 배포, Git 통합

옵션 2: Railway (권장)

  • GitHub 연동으로 자동 배포
  • 비용: 월 $5 (Starter Plan)
  • 장점: 무료 티어 제공, 빠른 배포

옵션 3: AWS EC2 (고급)

  • t2.micro 인스턴스 사용 (1년 무료)
  • PM2로 프로세스 관리
  • 장점: 완전한 제어, 확장 가능

비용 분석

항목 비용 비고
Discord 봇 등록 무료 제한 없음
OpenAI API (GPT-4) $10-30/월 사용량 기준
서버 호스팅 (Railway) $5/월 무료 티어 가능
총 비용 $15-35/월 GPT-3.5 사용 시 $5-15

실전 팁

  • Rate Limiting 구현: 사용자당 1분에 5회로 제한해 API 비용 절감
  • 에러 핸들링: try-catch로 모든 API 호출 감싸기
  • 로깅: Winston 라이브러리로 모든 요청/응답 기록
  • 환경 변수 관리: .env 파일을 .gitignore에 추가 (보안)
  • Discord Slash Commands: ! 대신 /명령어로 업그레이드 권장

문제 해결 가이드

Q: 봇이 메시지를 읽지 못합니다.
A: MESSAGE CONTENT INTENT가 활성화되었는지 확인하세요.

Q: OpenAI API 에러가 발생합니다.
A: API 키가 올바른지, 잔액이 충분한지 확인하세요.

Q: 봇이 오프라인이 됩니다.
A: 서버 호스팅이 24/7 실행 중인지 확인하세요. 로컬 개발 시 컴퓨터를 끄면 봇도 오프라인이 됩니다.

결론: Discord AI 봇 개발은 생각보다 간단합니다. 이 가이드를 따라하면 1시간 안에 작동하는 봇을 만들 수 있으며, 커뮤니티에 즉시 배포할 수 있습니다. 시작은 간단한 질문-답변 봇으로 하고, 점차 이미지 생성, 번역, 요약 기능을 추가하세요. 월 $15-35의 비용으로 수백 명의 사용자에게 AI 서비스를 제공할 수 있습니다.

Did you find this insight helpful?

Share with your colleagues and grow together.