Custom Commands
Create your own commands to extend Technified Admin's functionality.
Registering a Command
Use the global API to register custom commands:
_G.Technified.RegisterCommand({
Name = "mycommand",
Aliases = {"mc", "mycmd"},
Description = "Description of what the command does",
Usage = ":mycommand <player> [optional]",
Category = "Custom",
Permission = 2, -- Minimum level required
Execute = function(player, args, context)
-- Your command logic here
return true, "Command executed successfully!"
end
})Command Definition
Required Fields
| Field | Type | Description |
|---|---|---|
Name | string | Primary command name |
Description | string | What the command does |
Permission | number | Minimum permission level |
Execute | function | Command logic |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
Aliases | table | Alternative names | |
Usage | string | auto | Usage example |
Category | string | "Custom" | Command category |
Cooldown | number | 1 | Seconds between uses |
Args | table | Argument definitions |
Execute Function
The Execute function receives:
function(player, args, context)
-- player: The player who ran the command
-- args: Table of parsed arguments
-- context: Additional context data
-- Return: success (bool), message (string)
return true, "Success message"
-- or
return false, "Error message"
endContext Object
context = {
rawArgs = "original argument string",
commandName = "mycommand",
prefix = ":",
Services = {
Moderation = ModerationService,
Permission = PermissionService,
-- etc.
},
Utils = UtilityFunctions,
}Example Commands
Simple Announcement
_G.Technified.RegisterCommand({
Name = "welcome",
Description = "Send a welcome message",
Permission = 2,
Execute = function(player, args, context)
_G.Technified.Announce(
"Welcome!",
"Welcome to our server, " .. player.Name .. "!",
"info",
5
)
return true, "Welcome message sent"
end
})Player Targeting
_G.Technified.RegisterCommand({
Name = "sparkles",
Aliases = {"sp"},
Description = "Add sparkles to a player",
Usage = ":sparkles <player>",
Permission = 2,
Execute = function(player, args, context)
-- Get target player
local targetName = args[1]
if not targetName then
return false, "Please specify a player"
end
local target = context.Utils.FindPlayer(targetName)
if not target then
return false, "Player not found"
end
-- Check permission hierarchy
if not _G.Technified.CanTarget(player, target) then
return false, "Cannot target this player"
end
-- Add sparkles
local character = target.Character
if character then
local sparkles = Instance.new("Sparkles")
sparkles.Parent = character:FindFirstChild("HumanoidRootPart")
end
return true, "Added sparkles to " .. target.Name
end
})With Duration
_G.Technified.RegisterCommand({
Name = "superspeed",
Description = "Give temporary super speed",
Usage = ":superspeed <player> <duration>",
Permission = 3,
Execute = function(player, args, context)
local targetName = args[1]
local duration = context.Utils.ParseDuration(args[2]) or 60
local target = context.Utils.FindPlayer(targetName)
if not target then
return false, "Player not found"
end
local character = target.Character
local humanoid = character and character:FindFirstChild("Humanoid")
if not humanoid then
return false, "Player has no character"
end
local originalSpeed = humanoid.WalkSpeed
humanoid.WalkSpeed = 100
-- Reset after duration
task.delay(duration, function()
if humanoid and humanoid.Parent then
humanoid.WalkSpeed = originalSpeed
end
end)
return true, string.format(
"Gave %s super speed for %d seconds",
target.Name,
duration
)
end
})With Logging
_G.Technified.RegisterCommand({
Name = "customban",
Description = "Custom ban with special handling",
Permission = 4,
Execute = function(player, args, context)
local targetName = args[1]
local reason = table.concat(args, " ", 2) or "No reason"
local target = context.Utils.FindPlayer(targetName)
if not target then
return false, "Player not found"
end
-- Use built-in ban function
local success = _G.Technified.Ban(
target.UserId,
reason,
0, -- permanent
{
userId = player.UserId,
name = player.Name
}
)
if success then
-- Log to API
_G.Technified.LogAction(
player.UserId,
"customban",
"moderation",
target.UserId,
{ reason = reason, custom = true }
)
return true, "Custom ban applied to " .. target.Name
end
return false, "Failed to ban player"
end
})Using Built-in Functions
Access Technified's functions in your commands:
-- Moderation
_G.Technified.Ban(userId, reason, duration, moderator)
_G.Technified.Kick(player, reason, moderator)
_G.Technified.Mute(userId, reason, duration, moderator)
_G.Technified.Warn(userId, reason, moderator)
_G.Technified.Unban(userId, moderator)
_G.Technified.Unmute(userId, moderator)
-- Checks
_G.Technified.IsBanned(userId)
_G.Technified.IsMuted(userId)
_G.Technified.IsStaff(player)
_G.Technified.GetPermissionLevel(player)
_G.Technified.CanTarget(executor, target)
-- UI
_G.Technified.Notify(player, title, message, type)
_G.Technified.Announce(title, message, type, duration)
-- Logging
_G.Technified.LogAction(userId, actionType, category, targetId, data)Argument Parsing
Define expected arguments:
_G.Technified.RegisterCommand({
Name = "example",
Args = {
{ Name = "player", Type = "player", Required = true },
{ Name = "amount", Type = "number", Required = true },
{ Name = "reason", Type = "string", Required = false },
},
Execute = function(player, args, context)
local target = args.player -- Parsed Player object
local amount = args.amount -- Parsed number
local reason = args.reason -- String or nil
-- ...
end
})Argument Types
| Type | Description |
|---|---|
player | Resolves to Player object |
players | Resolves to table of Players |
number | Parses as number |
string | Raw string |
duration | Parses duration (5m, 1h, etc.) |
boolean | true/false, yes/no, on/off |
Best Practices
Validate Input
Always validate arguments before using:
if not args[1] then
return false, "Missing required argument"
endCheck Permissions
Use CanTarget for player-targeting commands:
if not _G.Technified.CanTarget(player, target) then
return false, "Cannot target this player"
endHandle Errors
Wrap risky code in pcall:
local success, error = pcall(function()
-- Risky code
end)
if not success then
return false, "Error: " .. tostring(error)
endLog Important Actions
Log significant actions to the API:
_G.Technified.LogAction(
player.UserId,
"custom_action",
"custom",
targetId,
{ details = "..." }
)Use Notifications
Provide feedback to users:
_G.Technified.Notify(player, "Success", "Action completed!", "success")