Multiple Arguments
Let's write a command that receives two arguments:
firstParcelsecondParcel
And returns firstParcel * secondParcel.
Writing the MultiplyCommand#
It'll look like this:
path/to/your/app/src/Commands/MultiplyCommand.ts
Declaring arguments is just as simple as defining a property and marking them with @Argument().
tip
By assigning the type number to an argument, Discapp will guarantee that the argument is a number (1, 2) and not a string ('1', '2').
We will also alert the user if he sents a string but a number was expected.
Testing MultiplyCommand#
Since we did not explicitly defined a code for MultiplyCommand, Discapp automatically assigned the code multiply to it.
So we can test our command by sending the following message in our Discord server:
Output should be 20.