Overview


This section will give you a basic guide of the Editor and identify the functions of each part.

Preface

In contrast to the Basic Script Editor, you can use the Advanced Script Editor to harness the full power of our Scripting Engine. However, with such power comes great responsibility. Script kiddies should tread with caution as even coding wizards have been known to succumb to the horrors of async programming and type systems, or more accurately, the lack thereof. Harnessing this volatile force will, however, allow you to do the unthinkable, and walk like a god among men.

TLDR; You can do a lot more with this that you could with the Basic Editor but its easy to fuck up.

Code Panel

This is where your code lives and where you'll be spending most of your time. Any modifications to the source code must be made here. Note that if you switch pages, any changes that you've made will be wiped. For this reason, selecting a different script from the Scripts Panel will alert you if you have any unsaved changes.

Options Panel

This is where you can configure your script. Note that data in this panel is in JSON format and the fields and values here are case sensitive. Here is a breakdown of what each option does:

Description:

This is pretty self explanatory; the description of your script that people will see on the marketplace.

Match Type:

This option determines how your bot should search for the match value below. It can have the following values:

  • command: looks for the prefix followed by match.
  • startswith: looks for match at the start of your message.
  • includes: looks for match anywhere in your message.
  • exactmatch: looks for match to be exactly the same as your message.
  • regex: looks for the regular expression specified in match.

Please note that command, startswith, and includes are case agnostic, while exactmatch and regex are case sensitive.

Name:

Again, pretty self explanatory. Make this short and sweet and make sure it's memorable.

Thumbnail:

The url to an image that will be displayed beside your script on the marketplace.

Match:

This is what our bot looks for in chat to determine if it should run your script.

Here is an example of a pre-filled options json:

{
  "description": "I DON'T LIKE 'EM PUTTIN CHEMICALS IN THE WATER THAT TURN THE FRIGGEN FROGS GAY!'",
  "marketplace_enabled": true,
  "match_type": "command",
  "name": "Alex Jones Quotes",
  "thumbnail": "https://cdn.discordapp.com/attachments/379432139856412682/487594328634425345/unknown.png",
  "match": "alexjones"
}

The preceeding data will be displayed on the marketplace page as follows:

or if you are lucky

Scripts Panel

Here you will see all the scripts that you've made. If there are scripts here already and you havent touched the Advanced Editor before, don't worry. This panel also shows scripts that you've made with the help of the Basic Editor. There is also a new script button that you can click to create (you guessed it!) a new script.

Basic Concepts


This section will guide you through creating and editing a few basic scripts, putting you well on your way to mastering the editor! Note that if you haven't created a script using the Basic Editor yet, now might be a good time to do that as editing an existing script is the easiest way to start working with the editor.

Prerequisites:

  • Basic knowledge of JavaScript and Discord.js.
  • You've created a script with the Basic Editor already so that we can look at its source code.

Viewing a Script

Start by selecting a pre-existing script on in the scripts panel. This should cause the script to become selected, displaying stuff in the code and options panels. The code generated by the Basic Editor is commented so that you can easily follow it. As of update 3.1, you can view the source code for any script directly from the marketplace!

Creating a Script

Start by clicking the 'New Script' button on the scripts panel. This should generate some basic example code in the code panel and an empty json in the options panel that you need to fill out. When you're done filling out the info, you can click the create button to create your new script!

Updating a Script

Start by selecting a pre-existing script on in the scripts panel. This should cause the script to become selected, displaying stuff in the code and options panels. After you've made the desired changes to either the code or options, you can click the update button to update your script. There is also a delete button if you want ot remove your script. Note that this will delete your code forever and you wont be able to get it back. Proceed with caution.

Advanced Concepts


This section will guide you through some of the more advanced concepts required to become a coding wizard.

Prerequisites:

Discord.js

We use Discord.js to interact with the Discord API, and as such, you can use almost all it's features in our editor so go chech out their documentation! You have (almost) complete access to the message object with one exception; you can't acess our token, so don't even try.

Note that in the future, we plan to move away from Discord.js for scripting.

Caveats

There are some JavaScript features that we've disabled to prevent abuse. Here are the noteworthy ones:

  • The script and any loops time out after 2 seconds.
  • Any global JavaScript values that would normally be present are not, such as promises.

Note that in the future, we plan to update our sandbox and make all of these features available.