일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 서비스기획
- 개발
- 컴활1급
- 컴퓨터활용능력1급필기
- PL
- 컴퓨터활용능력
- 컴활1급필기합격
- radiobtn
- git
- checkbox
- 필기
- 기획
- 1급
- github
- 컴활
- 피그마
- 체크박스
- 자격증
- 라디오버튼
- 2022
- METAVERSE
- 개발기획
- development
- figma
- radiobutton
- 컴퓨터활용능력1급
- serviceplan
- 메타버스
- 합격후기
- 컴활1급필기
- Today
- Total
I'm shake it shake it
[Discord Bot] HelloBot 만들기 본문
새로운 프로젝트로 Discord에 Bot을 만들어보기로 합니다.
디스코드 봇 생성하기
https://discord.com/developers/applications
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
discord.com
위 링크에 들어가서 새로운 애플리케이션을 생성합니다.
이름 작성하고, 디스코드 개발자 서비스 약관 및 정책에 동의합니다.
Create 생성 클릭
기본적으로 General Information을 보여줄텐데 자유롭게 꾸며보시면 되고요,
상단 왼쪽에 햄버거 메뉴 클릭합니다.
TOKEN 생성 또는 Reset 해주시고, Copy 해서 메모장 같은 곳에 붙여둡니다.
봇 개발 할 때 사용해야 하기 때문이죠.
import discord
discord_token = '{Token을 입력하세요}'
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_ready():
print('We have logged in as {}'.format(client))
print('Bot name: {}'.format(client.user.name))
print('Bot ID: {}'.format(client.user.id))
@client.event
async def on_message(message):
print(message.content)
if message.author == client.user:
return
elif message.content.startswith('hello'):
await message.channel.send('Hello!')
client.run(discord_token)
# 실행결과
도대체 이 메세지를 왜 읽어오지 못하는 걸까요 ??? ...
내가 뭘 잘못했는데
discord.content empty // ... 검색해도 나오지 않습니다.
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal
에러가 길어서 무슨 말인지 모르겠다고 생각했는데,
잘 읽어보니 developer portal에서 승인이 되어있지 않다 이런 말인 것 같습니다.
다시 discord developer portal에 > Bot 중간쯤에 Privileged Gateway Intents > MESSAGE CONTENT INTENT
활성화 해주었습니다.
드디어 답변을 준 이녀석...
'Development (개발) > 2) Python' 카테고리의 다른 글
eval 메소드.. 어디에 쓸까?? (0) | 2023.04.12 |
---|---|
소인수분해.. 어떻게 해? (0) | 2023.04.11 |
Programmers - Lv.1( 50%) (0) | 2023.03.07 |
[Tips] Requirements.txt에 대하여.. (0) | 2023.02.05 |
Programmers - Lv.0 (0) | 2023.01.29 |