REST Commands
REST Data Commands can be used to interface with external APIs in a variety of ways.
Last updated
REST Data Commands can be used to interface with external APIs in a variety of ways.
Last updated
Specify the API Url to set what REST endpoint will be called when executing the command. As of this moment you can choose from POST / PUT / PATCH / DELETE / GET
The URL used also accepts dynamic URL that are driven by the parameter name using the same syntax as the Message Template Engine. Anything wrapped in ${} will be replaced with the matching value for the given parameter name.
In the event you are using a parameter for a dynamic URL the response, the parameter that matches parameter mapping will go unused. Anything can be put into this.
In the example below I am target the public Star Wars API to allow fetching of any available endpoints and their matching ID parameters. https://swapi.py4e.com/
The header configurable allows you to set custom headers that may be required for the REST endpoint to work as expected
Add a new header by clicking the "Add Header" button. You can then enter the name and value for that header
Any set headers will overwrite default headers.
Create up to 25 parameters of different types. This determines how they are formatted when building the JSON to send to the specified URL
There are various types that have different JSON mapping behavior.
String
A plain text parameter that allows any plain text characters. There is little to no validation around this parameter
Number
Parameter must be a numeric value. Allows decimals. Validation is handled by Discord. Will be sent as a number in the JSON object
Integer
Parameter must be a whole number. Decimals are not allowed. Validation is handled by Discord. Will be sent as a number in the JSON object
Boolean
Parameter must be true or false. Options are pre-populated by Discord in the parameter for quickly being able to select. Validation is handled by Discord. Will be sent as a boolean in the JSON object.
Default data can be used to add any additional information that is not captured in a parameter. This allows you to have static information that may be required for every request to that endpoint.
For this example I am going to assume you have read the above and understand how to make properties and then show you an example and how it would behave for the data mapping.
Let's take the following parameters as an example
Using the above parameters you will have a generation JSON that looks like the following:
Note that the name of the parameter does not matter. See how param3's mapping has someObject.boolean and the name "param3" is not present anywhere.
Configuration Option | Explanation |
---|---|
Configuration Option | Explanation |
---|---|
Name | Value | Type | Mapping |
---|---|---|---|
param1
something
string
someObject.param1
param2
1.50
number
param2
param3
true
boolean
someObject.boolean
param4
5
integer
someObject.anotherObject.param4
Name
This is the name of the parameter in the discord command. This is not used in the data mapping
Description
This is the description of the parameter for the discord command. This is not used in the data mapping
Type
View below for information on types
Mapping
Name
This is just used for you to better know what these are used for. These are for you only.
Type
View below for information on types
Mapping
Value
The value to be inserted into the data.
The dot notation form to map the parameter values to the generation JSON data. Refer to
The dot notation form to map the parameter values to the generation JSON data. Refer to