Skip to content

Your First Script

Nathan Glover edited this page Mar 9, 2018 · 12 revisions

Creating Your Script

JavaScript-Expansions are all written in JavaScript (as the name implies).

Here is an example "Hello, world!" script:

function helloWorld() {
    return "Hello, world!";
}

helloWorld();

As you can see, the scripts return one value.

Using Your Script

To use our hello_world script, first let's save the above as hello_world.js inside the plugins/PlaceholderAPI/javascripts/ folder.

Next, add it to the plugins/PlaceholderAPI/javascript_placeholders.yml file so the expansion knows to load it!

hello_world:
  expression: 'file: hello_world.js'
  type: string

Then, after reloading PAPI (/papi reload) you can use your placeholder!

To test it, run /papi parse %javascript_hello_world%

And ta-da! example

Advanced Scripts

After you've learned the basics of placeholder scripts, head on over to Advanced Scripts to learn what you can fully do!