From 8d5b93fd5798516f43551d883227698ae3a7ca84 Mon Sep 17 00:00:00 2001 From: Krcnos Date: Mon, 4 Mar 2024 13:50:50 -0600 Subject: [PATCH 1/2] Added support for both LegacyChatService and TextChatService in regards to player targetted binds --- Cmdr/BuiltInCommands/Utility/bind.lua | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Cmdr/BuiltInCommands/Utility/bind.lua b/Cmdr/BuiltInCommands/Utility/bind.lua index b18229f9..bee740b1 100644 --- a/Cmdr/BuiltInCommands/Utility/bind.lua +++ b/Cmdr/BuiltInCommands/Utility/bind.lua @@ -1,4 +1,5 @@ local UserInputService = game:GetService("UserInputService") +local TextChatService = game:GetService("TextChatService") return { Name = "bind", @@ -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." From fb666309e0b0006c1be729f269447b93aecf48d0 Mon Sep 17 00:00:00 2001 From: Krcnos Date: Wed, 6 Mar 2024 06:28:03 -0600 Subject: [PATCH 2/2] Ran stylua --- Cmdr/BuiltInCommands/Utility/bind.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Cmdr/BuiltInCommands/Utility/bind.lua b/Cmdr/BuiltInCommands/Utility/bind.lua index bee740b1..cfcf170e 100644 --- a/Cmdr/BuiltInCommands/Utility/bind.lua +++ b/Cmdr/BuiltInCommands/Utility/bind.lua @@ -55,14 +55,16 @@ return { elseif bindType == "player" then 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)) + 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