typical-developers / oaklands-feedback

Give feedback about Oaklands!
2 stars 0 forks source link

Make chat commanders hide messages in chat #969

Open kalrnlo opened 2 days ago

kalrnlo commented 2 days ago

Roblox Username

kalrnlo

What do you think can have quality-of-life improvements?

chat commander

How do you think things can be improved?

Currently when ever a player says a trigger word, the message is visible in chat. Ideally trigger words would be hidden in chat, by having a ShouldDelieverCallback registered to every chat channel under the TextChannels folder in TextChatService thats created at runtime.

code example because this api originally confused me with how its explained

local TextChatService = game:GetService("TextChatService")

-- using boolean? because its not guaranteed for a command to already be registered, and also using a set for O1 acess times because players can register any amount of commands
local PLAYER_COMMANDS = {} :: { [number]: { [string]: boolean? } }
local TEXT_CHANNELS: Folder = TextChatService:WaitForChild("TextChannels")  :: any

local function should_deliever(message: TextChatMessage): boolean
    local source = message.TextSource
    local is_command = PLAYER_COMMANDS[source.UserId][message.Text]

    return is_command == nil
end

TEXT_CHANNELS.ChildAdded:Connect(function(channel: TextChannel)
    channel.ShouldDelieverCallback = should_deliever
end :: any)

for _, channel in TEXT_CHANNELS:GetChildren() do
    channel.ShouldDelieverCallback = should_deliever
end
kalrnlo commented 2 days ago

Alternatively TextChatCommands could be used, but those block any message that includes an alias for the command. But could probably be worked around via messing with TextChatService.SendingMessage to then manually trigger TextChannel:SendAsync() if the player doesnt have that command registered.

HooferDevelops commented 2 days ago

I don't think this would work because commanders can be used by any player in the server (intentionally). I've been trying to think of a solution, my only idea is a new component but I'm not sure about that.