Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getgenv().webhookUrl = "" -- put your discord webhook in ""
- local http_request = http_request or request or HttpPost or syn.request
- local function sendToWebhook(message)
- local data = {
- content = message
- }
- local headers = {
- ["Content-Type"] = "application/json"
- }
- local webhookUrl = getgenv().webhookUrl
- if not webhookUrl then
- print("webhookUrl is not set.")
- return
- end
- local success, response = pcall(function()
- return http_request({
- Url = webhookUrl,
- Method = "POST",
- Headers = headers,
- Body = game:GetService("HttpService"):JSONEncode(data)
- })
- end)
- if success then
- print("Message sent to Discord webhook!")
- else
- print("Failed to send message to Discord webhook. Error: " .. response)
- end
- end
- -- Event handler for chat messages
- local function onPlayerChatted(message)
- sendToWebhook(message)
- end
- game.Players.LocalPlayer.Chatted:Connect(onPlayerChatted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement