-
Notifications
You must be signed in to change notification settings - Fork 0
Running commands locally
Commands can be run locally on your machine, assuming that the resources needed to run your command are locally available. This means that AWS resources that live in the cloud will need to be manually referenced in the APIs during local-testing, or have an overridable way in which you can pass in their names. Running a command is as simple as running the following command after building the project:
npm run command <json_data>
<json_data>
should be in the format of a IDiscordRequestData
object from the Discord Bot CDK construct, for example: '{"name": "hello"}'
. This structure attempts to mirror an Application Command per Discord's API though note it is not 1-1 at this time. The properties of this data structure at this time are as follows:
Name | Type | Required? | Description |
---|---|---|---|
id | string | Yes | The ID of the the invoked command. |
name | string | Yes | The name of the incoming request, should match the command name. |
options | IDiscordRequestDataOption | No | Additional options included with this command, like inputs to it. |
Name | Type | Required? | Description |
---|---|---|---|
name | string | Yes | The name of the request's option data. |
value | string | No | The value of the request's option data. |
Most commands can be kept pretty simple with the following structure as an example:
{
"name": "add"
"options": [
{
"name": "a",
"value": "1"
},
{
"name": "b",
"value": "1"
}
]
}
Here, we are running an add
command with 2 values: a
which will be equal to 1, and b
which will be equal to 1. Thus, the command bash call would look like this:
npm run command {"name": "add", "options": [{"name": "a", "value": "1"},{"name": "b", "value": "1"}]}
-
I tried to run my command, but it can't be found. Why is that?
- A few things could cause this:
- First, make sure you've built your project with
npm run build
. Commands run the compiled JavaScript code, not the uncompiled TypeScript code. - Second, ensure you have updated the list of commands with your command.
- First, make sure you've built your project with
- A few things could cause this: