Hello fellow developers, I’m having an issue with this discord webhook where I’m logging when a player joins this training game and log the chat, as it’s not even sending a message when a player joins/chats, it worked on my own game but not on this one.
Here is some details
This is being done in team create.
Both HTTP/API service is enabled.
The game was published once the script was done.
Both webook/discord were made half an hour ago.
I’m not the owner of the game
I’l getting this error:
local joinsurl = "https://discordapp.com/api/webhooks/url"
local chaturl = "https://discordapp.com/api/webhooks/url"
local http = game:GetService("HttpService")
-- For when player joins:
game.Players.PlayerAdded:Connect(function(plr)
local data = {
["embeds"] = {
{
["title"] = "**Player Joined!**",
["description"] = plr.Name.."#"..plr.UserId.." has joined the game!"
}
}
}
local finaldata = http:JSONEncode(data)
http:PostAsync(joinsurl, finaldata)
end)
-- For when player leaves
game.Players.PlayerRemoving:Connect(function(plr)
local data = {
["embeds"] = {
{
["title"] = "**Player left!**",
["description"] = plr.Name.."#"..plr.UserId.." has left the game)"
}
}
}
local finaldata = http:JSONEncode(data)
http:PostAsync(joinsurl, finaldata)
end)
-- When player chats
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
local data = {
content = "**[.."..player.Name"..]>**"..msg,
}
local data = http:JSONEncode(data)
http:PostAsync(chaturl, data)
end)
end)
Discord is not a logging service Your code does not consider the rate limits of the API and the staff may delete your webhook and/or terminate your account if you hit the limits frequently.
I acknowledge that but this game is only meant for maximum of 3 players each session, and chat is rarely used to our regulations, that’s why I took the choice and made it.
Actually I might delete the chat logger, and keep only joins, it’s just around 3 messages a day or so.
Only people with a certain rank in our group can join the game, also tried what you said and didn’t work, I assume I need to wait some time, I asked a friend and he said this forbidden error is happening in some studios.
I searched for the meaning of 403 when posting to a webhook and it could mean that the webhook is no longer valid, the data being passed is not formatted properly or discord blocked the webhook.
I don’t see how data isn’t being passed or not formatted properly, this is my code:
local joinsurl = "https://discordapp.com/api/webhooks/url"
local http = game:GetService("HttpService")
-- For when player joins:
game.Players.PlayerAdded:Connect(function(plr)
local data = {
["embeds"] = {
{
["title"] = "**Player Joined!**",
["description"] = plr.Name.."#"..plr.UserId.." has joined the game!"
}
}
}
local finaldata = http:JSONEncode(data)
http:PostAsync(joinsurl, finaldata)
end)
-- For when player leaves
game.Players.PlayerRemoving:Connect(function(plr)
local data = {
["embeds"] = {
{
["title"] = "**Player left!**",
["description"] = plr.Name.."#"..plr.UserId.." has left the game)"
}
}
}
local finaldata = http:JSONEncode(data)
http:PostAsync(joinsurl, finaldata)
end)