Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Log only certain messages through webhooks?

Asked by 4 years ago
Edited 4 years ago

Hi! So I have this script:

` local url = "MyDiscordWebhook"

local http = game:GetService("HttpService")

game.Players.PlayerAdded:Connect(function(player) player.Chatted:connect(function(msg)

    local data = {
        ['embeds'] = {{
            color = 00000,
            title = "**Code logger**",
            fields = {
                {
                    name = player.Name,
                    value = msg,
                }
            }
        }}
    }
    local newdata = http:JSONEncode(data)
    http:PostAsync(url,newdata)
end)

end) `

I'm quite new with scripting, this logs every single message sent, however, is it possible to make it so it only logs when a certain message is said? For example, it'll only log when someone says "ABCD"

1 answer

Log in to vote
0
Answered by 4 years ago

Use if statements, if you want to log if it finds the word use :find, but if you want it only to log if its a certain word check if the message is equal to your word To check is the message is equal to the word

local url = "MyDiscordWebhook" 
local http = game:GetService("HttpService")
local wordtocheck = "" -- put your word here
game.Players.PlayerAdded:Connect(function(player) 
player.Chatted:connect(function(msg)
if msg:lower() == wordtocheck:lower() then
    local data = {
        ['embeds'] = {{
            color = 00000,
            title = "**Code logger**",
            fields = {
                {
                    name = player.Name,
                    value = msg,
                }
            }
        }}
    }
    local newdata = http:JSONEncode(data)
    http:PostAsync(url,newdata)
end
end)
end)

To check if a word you given is there

local url = "MyDiscordWebhook" 
local http = game:GetService("HttpService")
local wordtocheck = "" -- put your word here
game.Players.PlayerAdded:Connect(function(player) 
player.Chatted:connect(function(msg)
if msg:lower():find(wordtocheck:lower()) then
    local data = {
        ['embeds'] = {{
            color = 00000,
            title = "**Code logger**",
            fields = {
                {
                    name = player.Name,
                    value = msg,
                }
            }
        }}
    }
    local newdata = http:JSONEncode(data)
    http:PostAsync(url,newdata)
end
end)
end)

If this helped mark this as your answer!

Ad

Answer this question