Cmdr: A fully extensible and type safe command console for Roblox Developers

The Group property within the CommandDefinition interface serves as a categorization label for commands, functioning much like an identifier. To regulate user access and permissions for specific commands, it is recommended to utilize a BeforeRun hook that evaluates the command’s associated Group.

1 Like

Alright, thank you. Do you know how to get the Group property within the commanddefinition?

return {
	Name = "kick",
	Aliases = {"boot"},
	Description = "Kicks a player",
	Group = {"Creators", "Administrators"}, -- want to get this in my BeforeRun
	Args = {
		{
			Type = "player",
			Name = "target",
			Description = "The player being kicked"
		},
		{
			Type = "string",
			Name = "reason",
			Description = "The reason for kicking this player"
		}
	}
}

Your BeforeRun hook’s callback receives the CommandContext object as a parameter.

It only prints out the first value of my Group CommandDefination, and not both of my command definitions.

it prints:
["Group"] = "Creators",

and not
["Group"] = {"Creators", "Administrators"},

Edit: Code retracted due to the person helping me removed their message;

1 Like

Please provide your code for additional assistance.

1 Like

I found this very useful, But I did (kinda) run into an issue while Making a gravity Command.

It works fine with numbers but I want to it be a
Number or “Default”
I like that It has typechecks, But I want to cram multiple types into one function. Like number|"Default"|"Random"

For now I am just using a ResetGravity function. and CrazyGravity

1 Like

I suggest developing a custom number type tailored to your specific scenario instead of relying on the default number type. You can refer to the Types guide for a detailed example of how to create a custom type that suits your needs.

1 Like

Hello, thank you for taking the time to read my comment.

I do have a question/suggestion and it is regarding future plans for management of team’s;

Is there plans for group permissions and or, management features, such as roles in groups giving specific permissions?

this project seems it would have benefits with more gravitas if it was optimised for group ID’s and rank’s allowing more genuine control over administrative features for multiple users.
Other than this small overlook, I feel this is an extremely powerful resource and I’m intrigued by your project.

From reading, it seems to be an extensive module for intricate customisation via command’s.

I’ll have to look into this further later.

1 Like

It is already possible to establish permissions based on a user’s role in a group using hooks, particularly the BeforeRun hook.

3 Likes

how to make it accesable for mobile players?

1 Like

To toggle the visibility of the console, you can utilize the CmdrClient:Toggle() method. However, you’ll need to develop your own method for detecting user input to determine when to invoke the method.

2 Likes

I have a error when I was making a command.
Error: TreasureName has an unregistered type "treasure"

Here’s Treasure Module:

return {
	Name = "treasure";
	Aliases = {"tr"};
	Description = "Adding/Subbing treasure from player.";
	Group = "Creators";
	Args = {
		{
			Type = "player";
			Name = "Player";
			Description = "The Player whose treasure we want to add/sub";
		},
		{
			Type = "treasure";
			Name = "TreasureName";
			Description = "The name of the treasure we want to modify";
		},
		{
			Type = "addsub";
			Name = "Add/Sub";
			Description = "The string of what we want to do with coins value";
		}
	}
}

Here’s TreasureServer Module:

return function(context, player: Player, ttype, addsub: string)
	local treasuresFound = player:FindFirstChild("leaderstats")["Treasures Found"]
	local treasuresData = player:FindFirstChild("Treasures")
	if not treasuresData and not treasuresFound then return end
	local function removeSpaces(str)
	    return str:gsub(" ","")
	end local str = removeSpaces(ttype)
	if addsub == "Add" or addsub == "add" then
		treasuresData[str].Value = true
		treasuresFound.Value += 1
	elseif addsub == "Sub" or addsub == "sub" then
		treasuresData[str].Value = false
		treasuresFound.Value -= 1
	end
end

Here’s Type Module for the treasure Type:

repeat task.wait() until game:IsLoaded()

local players = game:GetService("Players")
local player = players.LocalPlayer

local trNames = {}
for i,v in pairs(player:WaitForChild("Treasures"):GetChildren()) do
	if v:IsA("BoolValue") then table.insert(trNames,v.Name) end
end
return function(registry)
	registry:RegisterType("treasure", registry.Cmdr.Util.MakeEnumType("TreasureName", trNames))
end

I don’t know if I can asking for help here, if not then I’m sorry.
If someone can help, that would be really appreciated! Thanks.

1 Like

Did you invoke the Cmdr:RegisterTypesIn(path.to.folder) method within your server initialization script?

1 Like

Yeah, here is ServerScript:

local rs = game:GetService("ReplicatedStorage")
local cmdr = require(rs.Modules:WaitForChild("Cmdr"))

local folder = script.Parent
local commands = folder:FindFirstChild("Commands")
local hooks = folder:FindFirstChild("Hooks")
local types = folder:FindFirstChild("Types")

cmdr:RegisterDefaultCommands()
cmdr:RegisterCommandsIn(commands)
cmdr:RegisterTypesIn(types)
cmdr:RegisterHooksIn(hooks)

image

1 Like

I have a question, do you work for Cmdr? I know @evaera created it but you put out an update log soo im confused if you work for Cmdr or not

1 Like

Are there any additional errors in the output window related to your custom type? Providing a screenshot of your complete output window would be greatly appreciated and helpful.

1 Like

image

that’s all errors from Cmdr.

1 Like

Could you provide a screenshot of the error message located above the ones you’ve already shown in the previous screenshots?

1 Like

What do you mean? Sorry. You mean all output or code where error is showing?

1 Like

The entirety of the output window’s contents.

1 Like