Client Permissions

It's a good pratice to check if your bot has the required permissions for executing.

Discapp provides a quick way of doing this.

Improving the CreateChannelCommand#

In the Guild-only Command chapter chapter we have built the CreateChannelCommand, this command creates a channel, but creating a channel requires that the client have the 'MANAGE_CHANNELS' permission.

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

By adding this Discapp will ensure your bot have the permission for creating a channel before executing.