Help: Cmdr Command Logging

Greetings, Creators! :slight_smile:

I’ve recently been experimenting with the Cmdr Admin system. It’s a fully customizable, advanced admin system designed for experienced developers.

I’ve created a lot of commands so far, but now I’m wondering: how can I log executed commands to a Discord webhook? Cmdr doesn’t have a logging system built in by default.

Thank you in advance for any guidance!

That’s what I love about Cmdr, it’s up to the developer to figure out to do these things. But while I’m not going to spoon-feed you I will give you two things, a snippet of code and the API Page.

It’ll be based off the “AfterRun” hook.
AfterRun Hooks | Cmdr

To start off with is inside your “types” folder create a new module with the name “Logging” or whatever suites your preference and inside that you can paste the snippet of code in. The rest is up to you.

local RunService = game:GetService("RunService")

return function(Registry)
	-- Preventing Client from having this event added since it's not needed.
	if RunService:IsClient() then return end
	
	-- Where you'd wanna add the AfterRun Hook.
	Registry:AddHook("AfterRun", function(context)
		-- Where you would add your logging functionality, you typically want to always return nil as if you return an actual value such as a string it will return that as the response to the command.
	end)
end
1 Like

Thank you very much for your answer! Appreciate it.

Edit: Now scripted it by your template. It worked. Thank you again.

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