Commands

A more detailed guide on making commands with Skript.

Introduction

To declare a command, you need to type 'command', followed by the command name, seperated by a space. Optionally, you can include a / before the command name. Right after your command name, you'll need a :

command /wow:

After you've declared the command, you'll need to press enter, and start typing on the next line. You'll need to indent first. I myself prefer tabs, but its completely your preference. Once you've indented, you'll need to type 'trigger' followed by a colon once more.

command /wow:
trigger:

The basic layout of a command is as follows.

command /<command name> <arguments>:
  aliases:
  executable by:
  usage:
  description:
  permission:
  permission message:
  cooldown: <timespan>
  cooldown message:
  cooldown bypass:
  cooldown storage: <variable>
  trigger:
    <the code to run>

The lines of code above our trigger, are called properties. These define certain aspects of your command. Lets go over the properties.

Aliases

Some commands can have one, or multiple Aliases. Its basicly like having an alternative command name for a command.

command /hello:
aliases: /hi, /hey
trigger:
send "Hello World!"

In the example above, I've declared the /hello command. The command sends "Hello World!" to the player who executes it. Instead of typing /hello, I could type /hi, or /hey, and it would still execute as if I had typed the /hello command. In simple terms, It is still the same command.

Usage

Usage is simple. This is the message sent to the command execute when they're misusing the command. Either not including arguments or typing a player's name in an [<offline player>] argument field. Again in simple terms, it sends them this message when they're not using it right.

Permission and Permission Message

The permission property defines the permission node required to use the command. The permission message is the message sent to the command executer when they don't have permission to use the command.

command /hello:
permission: command.hello
permission message: &cYou're not allowed to use this command!
trigger:
send "Hi!"

Reference the above example. When using the /hello command, you would need to have the command.hello permission node. If you tried to use the command without that permission, you would be sent the permission message, "You're not allowed...". The permission message supports color and formatting codes. You can also optionally use quotes.

Cooldown

Cooldown is easily done. The command cooldown is the time you must wait before command usages. The cooldown message is the message sent to you're still on cooldown for the command. Cooldown bypass is the permission node(s) required to bypass the command cooldown. The cooldown storage property is useful if you want to store the time remaining on your command cooldown in a local variable. A bit advanced for beginners, but easy to figure out.

command /hello:
cooldown: 1 hour
cooldown message: "&cYou need to wait 1 hour in between usages!"
cooldown bypass: permission.node
cooldown storage: {_var}
trigger:
send "Hey!"

As seen in the above example command, once you use the command, you would need to wait 1 hour before using it again. To bypass the command cooldown, you would need the permission.node permission.

Other

As you probably noticed, we didn't cover the executable by and description properties. The executable by property defines who can use the command. Some acceptable values for the command are player, and console. Description is exactly what you think. Its a simple description of the command.

command /hello:
executable by: console
description: A command to use when you are feeling lonely.
trigger:
send "Hello!"

In the above example, the command can only be used on the server console.

Finished!

You've learned the basics of Custom Commands in Skript!