Argument check not working properly

Hello!

Any idea why my webhook argument check isn’t working correctly? If I say !help, it keeps getting sent as the SendWebhookCMD argument, therefore it sends the ChatlogsModule.SendWebhook(contentTable, "WebhookCMD") instead of the HelpRequestModule.

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ChatlogsModule = require(ServerStorage:WaitForChild("WebhookModules"):WaitForChild("ChatlogsModule"))
local HelpRequestModule = require(ServerStorage:WaitForChild("WebhookModules"):WaitForChild("HelpRequestModule"))
local HttpService = game:GetService("HttpService")

Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(message)
		local contentTable = {
			plr.DisplayName;
			plr.Name;
			plr.UserId;
			message;
		}
		local HelpContentTable = {
			plr.DisplayName;
			plr.Name;
			plr.UserId;
		}
		local Argument = ""
		local words = string.split(message, " ")
		local prefix = message:sub(1,1)
		if prefix == ":" or prefix == "!" or prefix == "/" and words[1] ~= "!help" then -- CLASSIC COMMAND
			Argument = "SendWebhookCMD"
		elseif prefix == "!" and words[1] == "!help" then -- HELP REQUEST COMMAND
			Argument = "HelpRequest"
		elseif prefix ~= ":" and prefix ~= "!" and prefix ~= "/" and words[1] ~= "!help" then -- NORMAL MESSAGE
			Argument = "SendWebhook"
		end
		if not plr then return end
		if Argument == "" then return end
		if plr and Argument == "SendWebhook" and contentTable ~= nil then
			ChatlogsModule.SendWebhook(contentTable, "Webhook")
		elseif plr and Argument == "SendWebhookCMD" and contentTable ~= nil then
			ChatlogsModule.SendWebhook(contentTable, "WebhookCMD")
		elseif plr and Argument == "HelpRequest" and HelpContentTable ~= nil then
			HelpRequestModule.SendWebhook(HelpContentTable)
		end
	end)
end)

Here you’re basically saying that.
If the prefix is : or
the prefix is ! or
if the prefix is / and words[1] ~= !help then

It’s not actually checking the “and” for all of em.

so when the player sends !, it meets the requirement and sets the argument as a SendWebhookCMD.

2 Likes

Ah, alright. So what do you suggest me to do? Make another if check under this line (inside the first if check basically), or?

Well, you’re using elseif statements, so I would probably just do the messy solution and…

if prefix == “:” and words[1] ~= “!help” or prefix == “!” and words[1] ~= “!help” or prefix == “/” and words[1] ~= “!help” then

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.