Cannot log bans/warns on discord

Hello, I made an admin panel that is refusing to allow me to log it to discord. It has worked on other places but now I am getting a “HTTP 403 Forbidden” error…

This is the necessary code:

Commands.Ban = function(Username, Staff, Reason)
	
	Commands:Log(Staff, Username, "Ban", tostring(Reason))	
	
	BanStore:SetAsync(game.Players:GetUserIdFromNameAsync(Username), true)
end

function Commands:Log(Staff, Player, Type, Reason, Quantity)
	if Type == "Ban" then
		local pfpLink = "https://www.roblox.com/headshot-thumbnail/image?userId="..game.Players:GetUserIdFromNameAsync(Player).."&width=48&height=48&format=png"
		local pfpLink2 = "https://www.roblox.com/headshot-thumbnail/image?userId="..game.Players:GetUserIdFromNameAsync(Staff.Name).."&width=100&height=100&format=png"
		local Data = {
			["content"] = "",
			["embeds"] = {{
				["author"] = {
					["name"] = "Player was banned by "..Staff.Name,
					["icon_url"] = pfpLink,
					["url"] = ""
				},
				["description"] = "**Banned on:** ["..game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name .. "](https://www.roblox.com/games/" .. game.PlaceId .. ")",
				["color"] = 0xca7600,
				["thumbnail"] = {
					["url"] = pfpLink2
				},
				["fields"] = {
					{
						["name"] = "**__Player__**",	
						["value"] = "["..Player.."](https://www.roblox.com/users/"..game.Players:GetUserIdFromNameAsync(Player).."/profile)",
						["inline"] = true
					};
					{
						["name"] = "**__Staff__**",	
						["value"] = "["..Staff.Name.."](https://www.roblox.com/users/"..Staff.UserId.."/profile)",
						["inline"] = true
					};
					{
						["name"] = "**__Reason__**",	
						["value"] = Reason,
						["inline"] = true
					};
					{
						["name"] = "**__Evidence__**",	
						["value"] = "Attached below by Staff",
						["inline"] = true
					};
					["footer"] = {
						["text"] = DateTime.now():FormatUniversalTime("LL", "en-us")
					}
				}}
			}}
		local newdata = HttpService:JSONEncode(Data)
		HttpService:PostAsync(BanUrl, newdata)
	else
		local pfpLink = "https://www.roblox.com/headshot-thumbnail/image?userId="..game.Players:GetUserIdFromNameAsync(Player.Name).."&width=48&height=48&format=png"
		local pfpLink2 = "https://www.roblox.com/headshot-thumbnail/image?userId="..game.Players:GetUserIdFromNameAsync(Staff.Name).."&width=100&height=100&format=png"
		local Data = {
			["content"] = "",
			["embeds"] = {{
				["author"] = {
					["name"] = "Player was warned by "..Staff.Name,
					["icon_url"] = pfpLink,
					["url"] = ""
				},
				["description"] = "**Warned on:** ["..game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name .. "](https://www.roblox.com/games/" .. game.PlaceId .. ")",
				["color"] = 0xca7600,
				["thumbnail"] = {
					["url"] = pfpLink2
				},
				["fields"] = {
					{
						["name"] = "**__Player__**",	
						["value"] = "["..Player.Name.."](https://www.roblox.com/users/"..game.Players:GetUserIdFromNameAsync(Player.Name).."/profile)",
						["inline"] = true
					};
					{
						["name"] = "**__Staff__**",	
						["value"] = "["..Staff.Name.."](https://www.roblox.com/users/"..Staff.UserId.."/profile)",
						["inline"] = true
					};
					{
						["name"] = "**__Reason__**",	
						["value"] = Reason,
						["inline"] = true
					};
					{
						["name"] = "**__Number of Warnings__**",	
						["value"] = Quantity,
						["inline"] = true
					};
					["footer"] = {
						["text"] = DateTime.now():FormatUniversalTime("LL", "en-us")
					}
				}}
			}}
		local newdata = HttpService:JSONEncode(Data)
		HttpService:PostAsync(WarnUrl, newdata)
	end
end

Commands.Warn = function(Player, Staff, Reason, Quantity)
	
	local Player = game.Players[Player]
	
	print(Staff, Player, "Warn", tostring(Reason), tostring(Quantity))
	
	Commands:Log(Staff, Player, "Warn", tostring(Reason), tostring(Quantity))
	
	local WarnText = Player.PlayerGui.AdminPanel.Warning.Text
	local WarnThingy = Player.PlayerGui.AdminPanel.Warning
	
	WarnThingy.Visible = true

	WarnText = "You have been warned by "..Staff.Name.."\nReason: "..Reason.."\nWarning Number: "..Quantity

	wait(5)

	WarnThingy.Visible = false
	
end

Thank you for help

Are you using a proxy to send the webhook?

No, do I need to? ----------------------

Try replacing discord.com or discordapp.com with webhook.lewistehminerz.dev

3 Likes

To clarify the reasoning on this, Discord has blocked Roblox from using webhooks. Discord is not really intended as a logging service. Personally, I would recommend logging bans somewhere else, for example Cloud Firestore or MongoDB are good options. Maybe even Trello, although that is also should not be used as a database. I have no expirence with webhook.lewistehminerz.dev but it would probably work fine. If it doesn’t you can always try hooks.hyra.io or setting up your own proxy, but I’d recommend checking out other database providers which are intended to be used as databases instead.

2 Likes

Thank you very much! I will give this a try.

+JMJ+