How To Create This Web-hook For Discord?

Hello Developher Hub Community!
I’ve always been wanting to get into Discord webhooks, but I have little understanding to how they work. I understand how to create one, but when it comes to scripting it in Roblox, I have no clue what to do. I’ve also been looking for useful Roblox Webhook ideas for my game.

For now, I am looking to keep it simple. I would like a webhook that creates a message in a channel on Discord whenever someone joins the game, mentioning that person in the message. (Pinging them.)
I have no idea where to start on this. I would appreciate any resources I can use, and any explanations/scripts that you can use to help me understand this.
Thanks!

Have you made any attempt at looking at any documentation? That would help you.

local HttpService = game:GetService('HttpService');
local WebhookUrl = '';

local data = HttpService.JSONEncode(HttpService, {
    content = 'Some string',
    username = 'Override the current username',
    avatar_url = 'Override the current avatar',
    tts = 'Should the message be a Text To Speech Message',
    file = 'Send a file',
    embeds = {
        {
            title = 'some title',
            type = 'Always `rich`',
            description = 'some description',
            ... -- Not bothered to fill the rest,
                -- Refer to https://discord.com/developers/docs/resources/channel#embed-object
        }
    }, -- This is an array 
    payload_json = 'See https://discord.com/developers/docs/resources/channel#create-message',
    allowed_mentions = 'allowed mentions for the message'
})

HttpService.PostAsync(HttpService, WebhookUrl, data, Enum.HttpContentType.ApplicationJson)

3 Likes

You could use these:

https://developer.roblox.com/en-us/api-reference/class/HttpService
https://developer.roblox.com/en-us/api-reference/function/HttpService/PostAsync

1 Like

Thank you! This will really help me on the Roblox side of things. Just what I was looking for!

1 Like

Thanks! This will be great for some reference code, and for future-use/reference.