Command (Structure) — Skript
Addon: Skript · Category: Structure
Syntax
command <.+>Description
Allows creation of true custom commands. See the 'Command Argument' section documentation for a list of supported argument types and how to use them.
Examples
# Rough Syntax
command [/]<commandname> [<arguments>]:
aliases: # [OPTIONAL] list of other names the command can go by (no / in front)
permission: # [OPTIONAL] allows you to set the required permission
permission message: # [OPTIONAL] allows you to define what message will be sent should they not have permission
executable by: # [OPTIONAL] allows you to define who can run the command (player/players/consnole)
condition: # [OPTIONAL] section/expression allows you to return a boolean of whether the sender should have access to the command
subcommand [/]<commandname> [<arguments>]: # [OPTIONAL] works exactly like a command, can have argument/subcommand sections within
arg[ument] <argument>: # [OPTIONAL] allows you to more finely tune or scope an argument. See the Command Argument section documentation for more details
trigger: # [OPTIONAL] all arguments defined on the initial command line will be run inside this section
# Simple Example
command /spawn:
aliases: hub
condition:
if any:
sender isn't a player
sender doesn't have permission "spawn"
then:
return false
return true
trigger:
teleport player to {spawn}
# More Involved Example
command /foo <num: integer>:
aliases: f
condition:
return whether sender has permission "foo"
argument <i: item>:
trigger:
if sender isn't a player:
send "You can't get a foo'd item because you're not a player!" to sender
stop
give player {_num} of {_i}
trigger:
if {_num} isn't set:
send "Usage: /foo <amount> <item>" to sender
stop
loop {_num} times:
send "foo" to sender
send "You have been foo'd %{_num}% times" to sender
# Expected Execution:
# /foo 5 -> prints 'foo' 5 times in the sender's chat and tells them how many times they have been foo'd.
# /foo -> Prints the usage message
# /foo 5 acacia_boat -> Gives the player 5 acacia boats
# /foo 5 acacia_boa (misspell) -> prints 'foo' 5 times in the sender's chat and tells them how many times they have been foo'd.