디스코드 봇 만들어보기

김정민·2023년 10월 30일

토이프로젝트

목록 보기
3/3

어쩌다가...

친구들과 디스코드에서 화상대화를 하던중 음성채널에 친구들이 들어왔을때 알람을 받고 싶었다.

일단

  1. discord 개발자 포털(https://discord.com/developers/applications)로 들어가서 새로운 애플리케이션을 생성
  2. 코드 작성
  3. 배너 생성 기능 추가하기
  4. 봇 실행하기

코드

import discord
from discord.ext import commands

intents = discord.Intents.default() 
intents.message_content = True


bot = commands.Bot(command_prefix='#',intents=discord.Intents.all())
 
@bot.event
async def on_ready():
    print(f'Login bot: {bot.user}')

# @bot.event
# async def on_ready():


@bot.command("마")
async def hello(message):
    await message.channel.send('어어 왔나')

@bot.command("입장")
async def join(ctx):    
	if ctx.author.voice and ctx.author.voice.channel:
		channel = ctx.author.voice.channel
		await channel.connect()
	else:        
		await ctx.send("음성 채널이 존재하지 않습니다.")


bot.run('MTE2ODQ1OTEwNTk1NDk2NzYwNQ.GHDBjp.xoXzbgGCCFf0oWtD8nQH1vuwB_Ua2-FSGoigZg')

<현재 봇 생성과 음성채팅입장 기능 까지 구현>

git

git@github.com:jmk445/discord_notifier_bot.git

레퍼런스

https://scvtwo.tistory.com/197

https://kante-kante.tistory.com/35

profile
computer science engineering

0개의 댓글