SlashCommandBuilder constructor
SlashCommandBuilder(
- String name,
- String? description,
- List<
CommandOptionBuilder> options, { - bool defaultPermissions = true,
- List<
ICommandPermissionBuilder> ? permissions, - Snowflake? guild,
- SlashCommandType type = SlashCommandType.chat,
A slash command, can only be instantiated through a method on Interactions
Implementation
SlashCommandBuilder(this.name, this.description, this.options,
{this.defaultPermissions = true, this.permissions, this.guild, this.type = SlashCommandType.chat}) {
if (!slashCommandNameRegex.hasMatch(this.name)) {
throw ArgumentError("Command name has to match regex: ${slashCommandNameRegex.pattern}");
}
if (this.description == null && this.type == SlashCommandType.chat) {
throw ArgumentError("Normal slash command needs to have description");
}
if (this.description != null && this.type != SlashCommandType.chat) {
throw ArgumentError("Context menus cannot have description");
}
}