Mention Arguments

Sometimes instead of receiving a value, like a string or a number, argument must be a mention.

In this chapter we will show you how to write the PokeCommand, that will receive the argument:

  • user

The user argument must be a mention. We will then send a private message to the user.

Writing the PokeCommand#

path/to/your/app/src/Commands/PokeCommand.ts
import { Command, BaseCommand, Argument, Mention } from "discapp";
@Command()
export class PokeCommand extends BaseCommand {
@Argument()
public user: Mention;
public execute() {
this.user.send("๐Ÿ‘‰");
}
}
info

The Mention type extends from User of Discord.js so you can use all the methods from it.

Testing PokeCommand#

You can test the PokeCommand by sending:

!poke @(you)

Your bot should send ๐Ÿ‘‰ as a private message.