Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for both LegacyChatService and TextChatService in regards to player targetted binds #322

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Cmdr/BuiltInCommands/Utility/bind.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local UserInputService = game:GetService("UserInputService")
local TextChatService = game:GetService("TextChatService")

return {
Name = "bind",
Expand Down Expand Up @@ -52,17 +53,23 @@ return {
elseif bindType == "bindableResource" then
return "Unimplemented..."
elseif bindType == "player" then
binds[bind] = bind.Chatted:Connect(function(message)
local function RunCommand(message)
local args = { message }
local chatCommand = context.Cmdr.Util.RunEmbeddedCommands(
context.Dispatcher,
context.Cmdr.Util.SubstituteArgs(command, args)
)
context:Reply(
("%s $ %s : %s"):format(bind.Name, chatCommand, context.Dispatcher:EvaluateAndRun(chatCommand)),
Color3.fromRGB(244, 92, 66)
)
end)
local chatCommand = context.Cmdr.Util.RunEmbeddedCommands(context.Dispatcher, context.Cmdr.Util.SubstituteArgs(command, args))
context:Reply(("%s $ %s : %s"):format(
bind.Name,
chatCommand,
context.Dispatcher:EvaluateAndRun(chatCommand)
), Color3.fromRGB(244, 92, 66))
end

if TextChatService.ChatVersion == Enum.ChatVersion.LegacyChatService then
binds[bind] = bind.Chatted:Connect(RunCommand)
else
binds[bind] = TextChatService.SendingMessage:Connect(function(message)
RunCommand(message.Text)
end)
end
end

return "Bound command to input."
Expand Down
Loading