유니티에서 디스코드 웹훅을 사용하여 메세지 보내기
서버 -> 채널 만들기
채널 편집 -> 연동 -> 웹후크 -> 웹후크 만들기
'웹 후크 URL 복사' -> 메모장에 저장해두기!
https://nk-studio.github.io/Packages/com.nkstudio.udiscordbot@1.0/manual/index.html
Discord Bot Overview | UDiscord Bot | 1.0.0
Discord Bot Overview 'UDiscord Bot' is a plugin that allows you to send messages to a Discord channel using Discord web hooks in Unity. Features Easily use Discord webhooks with the builder pattern. Designed for quick use by anyone. Provided Features Chang
nk-studio.github.io
UDiscord 플러그인 다운 받기
https://github.com/NK-Studio/UDiscord-Bot/releases
Releases · NK-Studio/UDiscord-Bot
Contribute to NK-Studio/UDiscord-Bot development by creating an account on GitHub.
github.com
패키지 임포트 하기 -> 스크립트(Bot.cs) 만들기
public class Bot : Editor
{
//MonoBehaviour 를 지우고 Editor를 작성해줌
}
카테고리를 만들어주는 스크립트를 생성
public class Bot : Editor
{
[MenuItem("Run/Send Discord")]
public static void Test()
{
DiscordBot.Create("WebHook URL").WithContent("Hello World!").Send();
}
}
WebHookURL 안에 위에서 저장해둔 URL을 넣어주면 유니티 에디터에 [ Run ] 메뉴가 생긴것을 확인 할 수 있다
그리고 SendDiscord 버튼을 클릭하면
다음과 같이 디스코드에 알림이 와있는것을 확인 할 수 있다
Embed.Create()
public class Bot : Editor
{
private const string hookURL =
"https://discordapp.com/api/webhooks/1373850697006579712/-";
[MenuItem("Run/Send Discord")]
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed(Embed.Create()
.WithDescription("Hello, World!") // Add description
.WithColor(Color.yellow) // Change the left line color
.WithTitle("Test Title") // Add title
.WithURL("https://google.com")) // Add link to navigate when the title is clicked
.Send();
}
}
WithTitle
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
)
.Send();
}
WithDescription
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
)
.Send();
}
WithThumbnailURL
구글에서 원하는 이미지 주소를 가져와서 .WithThumbnailURL 에 넣어주었다
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
.WithThumbnailURL("https://i.namu.wiki/i/AI0I3zLiLNNz6lbPjMBSnMuNvmYmMvkB1vYz-sYEw-sVJZI-RNxjsiOBEkjIooHlAklhfFUDhH5YZP3_NfoWsUdCE4lKR9mCBVKiY_5TRQyIGOAHkQFcnFDKlvxSvjUlxQ3T4AN1th0mBX_23TaXqw.webp")
)
.Send();
}
WithColor
.WithColor 메서드는 임베딩의 왼쪽 줄에 대한 색상을 지정합니다.
이 메서드는 Color32 또는 Color 열거를 사용하여 색상을 지정할 수 있습니다. 설명은 임베드 제목 아래에 표시됩니다.
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
.WithThumbnailURL("https://i.namu.wiki/i/AI0I3zLiLNNz6lbPjMBSnMuNvmYmMvkB1vYz-sYEw-sVJZI-RNxjsiOBEkjIooHlAklhfFUDhH5YZP3_NfoWsUdCE4lKR9mCBVKiY_5TRQyIGOAHkQFcnFDKlvxSvjUlxQ3T4AN1th0mBX_23TaXqw.webp")
.WithColor(Color.blue)
)
.Send();
}
WithImage
.WithImage 메서드는 임베드에 이미지를 추가합니다.
참고! 현재 이미지의 너비/높이를 설정할 방법이 없습니다.
[MenuItem("Run/Send Discord")]
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
.WithThumbnailURL("https://i.namu.wiki/i/AI0I3zLiLNNz6lbPjMBSnMuNvmYmMvkB1vYz-sYEw-sVJZI-RNxjsiOBEkjIooHlAklhfFUDhH5YZP3_NfoWsUdCE4lKR9mCBVKiY_5TRQyIGOAHkQFcnFDKlvxSvjUlxQ3T4AN1th0mBX_23TaXqw.webp")
.WithImage("https://i.imgur.com/ZGPxFN2.jpg")
.WithColor(Color.blue)
)
.Send();
}
WithURL
.WithURL 메서드는 임베딩 제목에 클릭 가능한 링크를 설정합니다.
[MenuItem("Run/Send Discord")]
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
.WithThumbnailURL("https://i.namu.wiki/i/AI0I3zLiLNNz6lbPjMBSnMuNvmYmMvkB1vYz-sYEw-sVJZI-RNxjsiOBEkjIooHlAklhfFUDhH5YZP3_NfoWsUdCE4lKR9mCBVKiY_5TRQyIGOAHkQFcnFDKlvxSvjUlxQ3T4AN1th0mBX_23TaXqw.webp")
.WithImage("https://i.imgur.com/ZGPxFN2.jpg")
.WithColor(Color.blue)
.WithURL("https://google.com/")
)
.Send();
}
WithAuthor
.WithAuthor 메서드는 임베드에 작성자를 추가합니다.
제목은 임베드 상단에 표시됩니다.
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
***
//작성자
.WithAuthor(
Author.Create("jisusama")//작성자.Create는 작성자 객체를 생성합니다.
.WithURL("https://www.reddit.com/r/Pizza/")//.WithURL 메서드는 작성자의 이름을 클릭할 때 탐색할 URL을 지정합니다.
.WithIconURL("https://akamai.pizzahut.co.kr/2020pizzahut-prod/public/img/menu/RPPZ1893_RPEG0016_RPDO0003_l.png"))//.WithIconURL 메서드는 작성자 정보에 아이콘을 추가합니다.
)
.Send();
}
WithFooter
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
***
//footer
.WithFooter(
Footer.Create("마무리!")
.WithIconURL("https://akamai.pizzahut.co.kr/2020pizzahut-prod/public/img/menu/RPPZ1893_RPEG0016_RPDO0003_l.png"))
)
.Send();
}
WithTimestamp
.WithTimestamp 메서드는 임베드에 타임스탬프를 추가합니다.
public static void Test()
{
DiscordBot.Create(hookURL)
.WithEmbed
(
Embed.Create()
.WithTitle("테스트 제목!")
.WithDescription("테스트 설명입니다.")
.WithThumbnailURL("https://i.namu.wiki/i/AI0I3zLiLNNz6lbPjMBSnMuNvmYmMvkB1vYz-sYEw-sVJZI-RNxjsiOBEkjIooHlAklhfFUDhH5YZP3_NfoWsUdCE4lKR9mCBVKiY_5TRQyIGOAHkQFcnFDKlvxSvjUlxQ3T4AN1th0mBX_23TaXqw.webp")
.WithImage("https://i.imgur.com/ZGPxFN2.jpg")
.WithColor(Color.blue)
.WithURL("https://google.com/")
//작성자
.WithAuthor(
Author.Create("jisusama")//작성자.Create는 작성자 객체를 생성합니다.
.WithURL("https://www.reddit.com/r/Pizza/")//.WithURL 메서드는 작성자의 이름을 클릭할 때 탐색할 URL을 지정합니다.
.WithIconURL("https://akamai.pizzahut.co.kr/2020pizzahut-prod/public/img/menu/RPPZ1893_RPEG0016_RPDO0003_l.png"))//.WithIconURL 메서드는 작성자 정보에 아이콘을 추가합니다.
//footer
.WithFooter(
Footer.Create("마무리!")
.WithIconURL("https://akamai.pizzahut.co.kr/2020pizzahut-prod/public/img/menu/RPPZ1893_RPEG0016_RPDO0003_l.png"))
//타임스탬프
.WithTimestamp(
Timestamp.Create() //Timestamp.Create는 Timestamp 객체를 생성합니다.
.WithFormat("yyyy-MM-ddTHH:mm:ssZ")//.WithFormat 메서드는 타임스탬프에 형식을 추가합니다
)
)
.Send();
}
https://www.youtube.com/watch?v=U3bD3aOga1c