정구리의 우주정복
Python Project 03. 디스코드 봇 만들기 (4) -새로운 접속자가 오면 메세지 보내기 on_member_join 본문
Python Project 03. 디스코드 봇 만들기 (4) -새로운 접속자가 오면 메세지 보내기 on_member_join
Jungry_ 2020. 6. 7. 23:36이번에 만든건 누군가가 나의 디스코드 채널에 새로 들오게 되면
개인 dm(direct message) 를 보내 채널에 대한 설명을 해주고
디스코드 채널에는 안뇽 이라고 인사를 해주는걸 만들었다 !
소스코드
@client.event
async def on_member_join(member):
channel = client.get_channel('718410583396843614')
await member.send('방가방가\n $ 명령어를 통해 다양한 서비스를 제공받을 수 있으니 해보라구 !') #privit 한 메세지를 보내줌
await channel.send('안뇽')
개인에게 privit한 메세지를 보낼 수 있고
모두가 있는 방에 인사를 할수있습니다 :-)
삽질을 엄청 했는데 이유가 get_channel 의 인자로 int 가 들어가야 하는데 str 형태로 넣어서 그거때문에 너무너무 고생했다눈 . .
API 사이트랑 다양하게 활용해보는 예시들이 적혀있는 사이트 ! (도움이 많이 되었음)
https://discordpy.readthedocs.io/en/latest/api.html
API Reference — discord.py 1.4.0a documentation
API Reference The following section outlines the API of discord.py. Note This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere.
discordpy.readthedocs.io
https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-send-a-message-to-a-specific-channel
Frequently Asked Questions — discord.py 1.4.0a documentation
Frequently Asked Questions This is a list of Frequently Asked Questions regarding using discord.py and its extension modules. Feel free to suggest a new question or submit one via pull requests. Questions regarding coroutines and asyncio belong here. A cor
discordpy.readthedocs.io
'PYTHON > PROJECT' 카테고리의 다른 글
Python Project 04. 영화리뷰 긍정부정 예측하기 - 구상 (0) | 2020.12.21 |
---|---|
Python Project 03. 디스코드 봇 만들기 (5) - Embed 와 욕설 필터링 하기 (4) | 2020.06.24 |
Python Project 03. 디스코드 봇 만들기 (3) - A minimal bot (0) | 2020.06.05 |
Python Project 03. 디스코드 봇 만들기 (2) - 시작하기 (1) | 2020.06.05 |
Python Project 03. 디스코드 봇 만들기 (1) - 구상 (0) | 2020.06.04 |