How to disable @ in text button GUI?

There is this free model feedback bot with one flaw.
If you want to send feedback with the discord server, you can put @everyone or @here,
which is a big issue which i want to patch

Webhook script: (Which may help?)

local webhook = "placeholder..."
local filteringFunction = game.ReplicatedStorage.FilteringFunction 
local HTTP = game:GetService("HttpService")
 
function filteringFunction.OnServerInvoke(player, msg)
    local payload = HTTP:JSONEncode({
        content = msg,
        username = player.Name.." - (#"..player.UserId..")"
    })
   
	HTTP:PostAsync(webhook, payload)
	
	
    return "Feedback recieved, if its a raid attempt we'll know who you are and we'll ban you"
end
2 Likes

Don’t let their role ping @everyone or @here

1 Like

No matter what i do, whether disable the “@everyone” ping it still doesnt work

Capture

well you could match the output for @everyone and @here and remove the ‘@

I tried making the code:

msg = string.gsub(msg,"@everyone","everyone")
msg = string.gsub(msg,"@here","here")
2 Likes

Not an expert with discord servers, but try to give it a role that doesn’t allow it to ping everyone.

1 Like

Take a look at allowed_mentions.

    local payload = HTTP:JSONEncode({
        content = msg,
        username = player.Name.." - (#"..player.UserId..")",
        allowed_mentions = {
            parse = {}
        }
    })

This allows your message to still contain “@everyone” without actually pinging anyone. :slight_smile:

3 Likes

Here is the answer to your question, no need to change the permissions of your bot:
Similar to DamSam’s approach, but this will remove any tag.

message = string.gsub(message, "%@", '(@)')
print(message)
-- Output:
-- (@)everyone wow I accidentally tagged everyone!

local message2 = "@everyone wow I accidentally tagged everyone!"
message2 = string.gsub(message, "%@", '')
print(message2)
-- Output:
-- everyone wow I accidentally tagged everyone!
1 Like

A simpler way to do this is just to find any matches that there’s an @ itself in the message sent using string.find

local webhook = "placeholder..."
local filteringFunction = game.ReplicatedStorage.FilteringFunction 
local HTTP = game:GetService("HttpService")
 
function filteringFunction.OnServerInvoke(player, msg)

    if string.find(msg,'@') then -- if an @ is found, return
     return "You cannot use the character '@' in your feedback!" 
    end

    local payload = HTTP:JSONEncode({
        content = msg,
        username = player.Name.." - (#"..player.UserId..")"
    })
   
	HTTP:PostAsync(webhook, payload)
	
	
    return "Feedback recieved!"
end
1 Like

oh its a webhook, u cant give it roles

thank you very much for your help

Can’t exploiters run that function whenever they like when firing an event?

Yup they can, I was only basing the code off what the poster provided.