초기 설정하기
기본 공식 문서는 다음에서 확인 가능
Welcome to discord.py
discordpy.readthedocs.io
- 개발자 포털 이동
Discord Developer Portal - API Docs for Bots and Developers
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
2. 좌측 Application → New Application 디스코드 애플리케이션 프로젝트 이름 생성.(디스코드 봇의 이름이 아니고, 프로젝트 이름을 정하는 것.)
3. Bot → Add Bot → Yes do it 클릭 이후 Reset Token 버튼을 눌러 토큰 생성.
4. OAuth2 Url Generator → bot 체크 권한은 사용자에 맞게 설정. 주소를 복사하여 웹에 복붙
5.서버에 추가 확인 후 디스코드에 봇이 들어와 있는지 확인.
VS Code에서 설정
- VS Code에서 다음 명령어 입력
pip install discord.py - 아래 예시코드로 동작 확인 토큰은 파일을 따로 만들어서 저장. (토큰의 보안을 위함. 형식은 Token=”토큰”). 토큰을 저장하는 파일의 이름은 사용자 임의로 지정.
import discord
from discord.ext.commands import Bot
from dico_token import Token
client = discord.Client()
# 사용자가 명령어 입력 시 ./를 입력하고 명령어 입력
client = commands.Bot(command_prefix='./')
# on_ready는 시작할 때 한번만 실행.
@client.event
async def on_ready():
print('Login...')
print(f'{client.user}에 로그인하였습니다.')
print(f'ID: {client.user.name}')
await client.change_presence(status=discord.Status.online, activity=discord.Game('VS Code로 개발'))
@client.event
async def on_message(message):
# message.content.startswith()는 해당 문자로 시작하는 단어에 대해서
# 인식하여 메시지 전송. ==로 비교 시 해당 문자만 인식
if message.content.startswith('테스트'):
await message.channel.send("{} | {}, 안녕!".format(message.author, message.author.mention))
if message.content == '테스트':
# 채널에 메시지 전송
await message.channel.send("{} | {}, 어서오세요!".format(message.author, message.author.mention))
# 아래 코드는 개인 메시지로 전송
await message.author.send("{} | {} 유저님, 환영합니다.".format(message.author, message.author.mention))
# 아래 코드들은 client.event의 on_message를 주석 처리하고 실행
@client.command(aliases=['hi'])
async def hello(ctx):
await ctx.send("안녕하세요!")
@client.command(aliases=['로그인', '접속하기'])
async def login(ctx):
await ctx.channel.send("{} | {}님, 어서오세요!".format(ctx.author, ctx.author.mention))
client.run(Token)
# dico_token.py
Token="토큰을 여기에"
- ctx → context의 줄임말
- context와 관련된 내용 확인은 API 설명 페이지
API Reference
The following section outlines the API of Pycord’s prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
docs.pycord.dev
디스코드에서 실행 결과 확인
명령어 및 API 리스트 사이트
API Reference
The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as i
discordpy.readthedocs.io
- commands list는 위 사이트에서 확인 가능.
Discord Developer Portal - API Docs for Bots and Developers
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
- 디스코드 개발자 포럼
Discord Developer Portal - API Docs for Bots and Developers
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
- 디스코드 개발자 공식 API 문서
API 레퍼런스
경고 봇의 메세지과 개인 이벤트는 이 이벤트를 통해 전송됩니다.봇이 프로그래밍된 방식에 따라, <재귀> 현상이 발생할 수 있습니다.따라서, 봇 자신에 응답하지 않게할려면, 사용자ID 확인을
discordpy-ko.github.io
- API 레퍼런스 한글 문서, 일부만 한글화
The Pycord Guide
The official guide for making bots and other Discord applications using the Pycord library.
guide.pycord.dev
- 디스코드의 각종 UI 정보와 예제가 수록되어 있는 사이트
https://github.com/Rapptz/discord.py
GitHub - Rapptz/discord.py: An API wrapper for Discord written in Python.
An API wrapper for Discord written in Python. Contribute to Rapptz/discord.py development by creating an account on GitHub.
github.com
- Discord.py의 공식 개발자 깃허브.
https://github.com/discord-py-ui/discord-ui
GitHub - discord-py-ui/discord-ui: A discord.py extension for sending, receiving and handling ui interactions in discord
A discord.py extension for sending, receiving and handling ui interactions in discord - GitHub - discord-py-ui/discord-ui: A discord.py extension for sending, receiving and handling ui interactions...
github.com
- Discord-ui의 공식 깃허브
Components - discord-ui 5.2.0 documentation
Components — discord-ui 5.2.0 documentation
© Copyright 2021, 404kuso, RedstoneZockt. Revision 00b11df3.
discord-ui.readthedocs.io
- discord-ui의 공식 문서
https://autocode.com/tools/discord/embed-builder/
- Discord Embed Builder
Discord's Branding Guidelines
Learn about Discord's branding guidelines.
discord.com
- 디스코드 공식 로고
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
discordjs.guide
- 디스코드 js 공식 사이트
'Discord > Discord Bot Python' 카테고리의 다른 글
Discord 봇 만들기 - Link and Search (0) | 2023.06.21 |
---|---|
Discord 봇 만들기 - Dropdown (0) | 2023.06.16 |
디스코드 봇 개발 시 Error 관련 (7) | 2023.05.30 |
Discord Bot 만들기 - 유튜브 음악 재생 봇 (18) | 2023.05.18 |
Discord Bot 만들기 - 음성 채널 입장하기 (8) | 2023.05.16 |