Client Roles

Similar to the Client permissions, Discapp also allows you to verify if your bot has a certain role before executing.

Refactoring CreateChannelCommand#

Let's now refactor the CreateChannelCommand to require the 'admin' role.

path/to/your/app/src/Commands/MakeChannel.ts
import { Command, BaseCommand, Guild, GuildContract, Argument } from "discapp";
@Command({
isGuildOnly: true,
clientRoles: ["admin"],
})
export class MakeChannelCommand extends BaseCommand {
@Argument()
public name: string;
@Guild()
public guild: GuildContract;
public execute() {
this.guild.channels.create(this.name);
}
}