Why does everything I do not work?! | Roblox Webhook to Discord

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Make my darn webhooks work in-game

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried soo many darn solutions I could find on dev forum, none of them work, and the last post I made about this was no use of help at all.

Script 1:

local HttpService = game:GetService("HttpService")
ReplicatedStorage = game.ReplicatedStorage

script.Parent.Changed:Connect(function()
	if script.Parent.Occupant then
		local plr = game.Players:FindFirstChild(script.Parent.Occupant.Parent.Name)
		if plr then
			local new = script.Parent.ScreenGui:Clone()
			new.Parent = plr.PlayerGui
			new.Enabled = true
		end
	end
end)

function LogToDiscord(user, signed)
	local success = pcall(function()
		local data = {
			["content"] = user.Name .. " has "..signed.." the Recruit Desk! (BY SIGNING YOUR NAME BELOW, YOU ARE AGREEING TO TERMS OF GIVING YOUR SERVICE TO THE USMC AND EVERYTHING YOU DO WILL BE WATCHED DURING THIS COURSE OF TRAINING).";
			["username"] = user.Name;
			["avatar_url"] = game.Players:GetUserThumbnailAsync(user.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100);
		}
		HttpService:PostAsync("https://discord.osyr.is/api/webhooks/869301241291894875/xxxxxxxxxxxxxxxxxxxxxxxxx-Iu-QV0BN2yvHTHez_IVzVBJp33s6qterrOSphyY_C-O6c", HttpService:JSONEncode(data))
	end)
end

ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(user)
	if user then
		LogToDiscord(user, "signed")
	end
end)

I don’t get how it doesn’t work?!

My other scripts don’t seem to log to my discord as well via webhook, and HTTPS is enabled.

First of all, don’t show your webhook link.
Also, I don’t think username and avatar_url are fields, so put your stuff in content.
If that doesn’t work then just try running the PostAsync alone with proper arguments.

1 Like
  1. Webhook link blurred out
  2. username and avatar_url are fields, because this used to work a few months ago when I used these scripts for a game, so it must be roblox that broke them lol

And if I take a free modeled webhook script from public, some of them are around 2019-2021 date and use avatar_url and they work when I test those public webhooks, which proves my point.

This is the discord documentation for messages

1 Like

avatar_url and username are no longer fields, at least not now.
here’s some working fields i use though.

local Data = HttpService:JSONEncode({
	["embeds"] = {{
	   ["description"] = Message,
	   ["color"] = tonumber(Color),
	   ["image"] = {
		  ["url"] = "http://www.roblox.com/Thumbs/Asset.ashx?format=png&width=75&height=75&assetId="..PetImage
	   }
    }}
})

example:
image
image

Okay, then explain how this works LOL:

--[[

Thank you for getting this! Put this script in Adonis_Loader > Config > Plugins

Don't forget to fill in the variables below!

]]

local WebhookURL = "https://discord.osyr.is/api/webhooks/xxxxxxxxxxxxxx/0-fCe_GkBu8436xGVLxFcqQHMkpjZ-Y4wc5IRcNdPQwUq0TbMMX6OWkp2FHPeykeso3A" -- Put this with your full Webhook URL

--[[

Do not edit below this unless you know what you are doing!

Made by happxiier - Contact happxiier#6085 if you have any concerns!

]]

server = nil 
service = nil

local PlaceName = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId).Name
local HTTPS = game:GetService("HttpService")

return function()
    service.Events.CommandRan:Connect(function(player, Data)

        local Level = nil
        local command = nil
        local success = nil

        for i,v in pairs(Data) do
            if i == "Success" then
                success = v
            end
            if i == "Message" then
                command = v
            end
            if type(v) == "table" then
                for e,n in pairs(v) do
                    if e == "Level" then
                        if n == 4 then 
                            Level = "Creator"
                        elseif n == 3 then
                            Level = "Owner"
                        elseif n == 2 then
                            Level = "Admin"
                        elseif n == 1 then
                            Level = "Mod"
                        else
                            Level = "Player"
                        end
                    end
                end
            end
        end

        local WebhookMessage = {
            ["username"] = "Admin Logs",
            ["avatar_url"] = "https://cdn.discordapp.com/attachments/748517845117173850/780294630499549184/remxz_company_logo.png",
            ["content"] = "",
            ["embeds"] = {{
                ["title"] = "",
                ["description"] = "",
                ["type"] = "rich",
                ["color"] = tonumber(0xffffff),
                ["fields"] = {
                    {
                        ["name"] = "User",
                        ["value"] = tostring(player.Name),
                        ["inline"] = false
                    },
                    {
                        ["name"] = "Admin Level",
                        ["value"] = tostring(Level),
                        ["inline"] = true
                    },

                    {
                        ["name"] = "Command",
                        ["value"] = tostring(command),
                        ["inline"] = false
                    },
                    {
                        ["name"] = "Timestamp",
                        ["value"] = tostring(service.GetTime()),
                        ["inline"] = false
                    },
                    {
                        ["name"] = "Game",
                        ["value"] = "["..tostring(PlaceName).."](https://www.roblox.com/games/"..(tostring(game.PlaceId))..")",
                        ["inline"] = false
                    },
                }
            }
            }

        }
        WebhookMessage = HTTPS:JSONEncode(WebhookMessage)
        if success then
            HTTPS:PostAsync(WebhookURL, WebhookMessage)
        end
    end)
end

image
image

Are you receiving any HTTP error code? if so can you send what the error is.

There’s no error/warnings outputting into the developer console.

Try to remove the pcall and see if it logs the HTTP error code

You have it looped through a pcall function but not using it

Just check if it successfully goes through, and see what the output gives you

So I removed local success = pcall(function(), and it gave me HttpError: DnsResolve when I activate the alarms which then completely breaks the whole script.

That means the domain you tried to post to isnt on a DNS server aka meaning the domain is invalid.

Okay, I’ll change them, hold on, yeah soo… I got HTTP 400 after changing them back to https://discord.com/

HTTP 400 (Bad Request)

HTTP 400 means you provided invalid syntax to the server

I would say try to post ["content"] = "Test" as embeds get tricky sometimes

is this what you’re trying to achieve?
image

It looks like you are using Osryis’s proxy server. From their post it says that the service is shutting down. Are you sure you are using a correct domain?

Also, it looks like you are sending the request to discord.com and getting 400 Bad Request. are you sure you are following the API and sending to the correct URL/giving right arguments?

If so, your error is here:

["avatar_url"] = game.Players:GetUserThumbnailAsync(user.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100);

Try using:

local HttpService = game:GetService("HttpService")
ReplicatedStorage = game.ReplicatedStorage

script.Parent.Changed:Connect(function()
	if script.Parent.Occupant then
		local plr = game.Players:FindFirstChild(script.Parent.Occupant.Parent.Name)
		if plr then
			local new = script.Parent.ScreenGui:Clone()
			new.Parent = plr.PlayerGui
			new.Enabled = true
		end
	end
end)

function LogToDiscord(user, signed)
	local success = pcall(function()
		local data = {
			["content"] = user.Name .. " has "..signed.." the Recruit Desk! (BY SIGNING YOUR NAME BELOW, YOU ARE AGREEING TO TERMS OF GIVING YOUR SERVICE TO THE USMC AND EVERYTHING YOU DO WILL BE WATCHED DURING THIS COURSE OF TRAINING).";
			["username"] = user.Name;
			["avatar_url"] = "https://www.roblox.com/bust-thumbnail/image?userId="..user.UserId.."&width=100&height=100&format=png" 
		}
		HttpService:PostAsync("https://discord.osyr.is/api/webhooks/869301241291894875/xxxxxxxxxxxxxxxxxxxxxxxxx-Iu-QV0BN2yvHTHez_IVzVBJp33s6qterrOSphyY_C-O6c", HttpService:JSONEncode(data))
	end)
end

ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(user)
	if user then
		LogToDiscord(user, "signed")
	end
end)

Instead, hope this works

1 Like

Somewhat, however, I believe it has to do something with GetUserThumbnailAsync not being workable anymore.

I referred to:

Hello! I have experience working with webhooks and you need to make sure that the

[“avatar_url”] = string.format(“https://www.roblox.com/headshot-thumbnail/image?userId=%s&width=150&height=150&format=png”, player.UserId),

is the last line of code within the embed before the closing } for it to work. It should end up looking like this: https://gyazo.com/88755f6d81b218194769679ceca1490d This code will make the Profile Picture of the Webhook on Discord a snippet of the Player’s Roblox Avatar.

Thank you, please reply to me if you have any further issues!

Please don’t bump this thread, after 29 days.