프로그래밍/파이썬
파이썬 디스코드 웹훅으로 메세지 보내기
젤리씨
2021. 11. 11. 00:34
728x90
파이썬 디스코드 웹훅으로 메세지 보내기
import requests
discord="디스코드 웹훅 주소"
headers = {
'Content-Type': 'application/json',
}
data = '{"content": "메세지 내용을 입력"}'
response = requests.post(discord, headers=headers, data=data)
위와 같이 입력을 하면 웹훅 url로 메세지 전송이 가능
또는 아래처럼 requests 가 아닌 discord_webhook 를 이용하며 된다.
from discord_webhook import DiscordWebhook
webhook = DiscordWebhook(url='your webhook url', content='Webhook Message')
response = webhook.execute()
728x90