IT/Tools

[Discord] 디스코드 웹훅 설정 및 전송

louky 2022. 9. 5. 12:15
반응형

Slack 또는 Telegram 말고 Discord로 메시지를 보내는 방법이다. 

 

Discord로 메시지를 보내는 방법으로는 slack과 마찬가지로 webhook설정으로 간단하게 메시지를 전송할 수 있다. 

 

discord에 가입하여 서버(채널)를 생성하고 채팅 채널을 만든 후 webhook을 설정하면 된다. 

(기존에 가입된 서버(채널)에서도 바로 가능하다)

 

서버 설정  > 연동 

"웹 후크 만들기" 

 

Bot name과 채널을 선택한다.(기본적으로 "#일반" 채팅 채널이 선택된다.)

 URL를 별도로 표시되지 않고  하단의 "웹 후크 URL복사"를 통해 웹훅 URL을 확인 할 있다. 

 

Curl 명령어를 이용하여, 생성된  Discord 웹훅 URL로 간단히 메시지를  아래와 같이 보낼수 있다. 

 

export WEBHOOK_URL="https://discord.com/api/webhooks/1013261388166737123/ObBOqMXs0mjeKdQnaerR7RXBP_2P8FLPtNSQZ3iABHUZxUumRP2C3C4VGQL86-m7AVXN"
curl \
  -H "Content-Type: application/json" \
  -d "{\"username\": \"test\", \"content\": \"Test Sender\n$(hostname)\"}" \
  $WEBHOOK_URL

 

Curl로 테스트를 해도 되지만  curl이 없는 시스템일 경우 아래 페이지에서도 테스틀 할 수 있다. 

 

사용법은 아주 간단하며 상단 "Clear ALL"을 클릭 한후 위에서 생성한  웹훅 URL을  "Webhook URL" 칸에 붙여 넣고  "Content" 부분에 전송한 message를 작성한 후 "Send" 버튼을 통해 전송 테스트를 할 수 있다. 

 

 

Discohook

The easiest way to personalise your Discord server.

discohook.org

전송할 테스트를 다양하게 꾸미고자 할 경우 아래 페이지에서 확인이 가능하다. 

 

fields - Discord Webhooks Guide

Allows you to use multiple title + description blocks in embed. fields is an array of field objects. Each object includes three values: name - sets name for field object. Required; value - sets description for field object. Required; inline - if true then

birdie0.github.io

 

color - Discord Webhooks Guide

Sets color for webhook's embed. It equals 0 (transparent) by default. Color requires number instead hex code, so you have to convert hexadecimal color code to decimal number. Color can be defined as number 65280 and as string "65280". I recommend to use Sp

birdie0.github.io

 

 

그외 discord 웹훅 관련해서는 discord개발사(?)에서 아주 자세히 설명하고 있다. 

반응형