SlashCommandBuilder constructor
SlashCommandBuilder(
- String name,
- String? description,
- List<
CommandOptionBuilder> options, { - bool defaultPermissions = true,
- List<
CommandPermissionBuilderAbstract> ? 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(name)) {
throw ArgumentError("Command name has to match regex: ${slashCommandNameRegex.pattern}");
}
if (description == null && type == SlashCommandType.chat) {
throw ArgumentError("Normal slash command needs to have description");
}
if (description != null && type != SlashCommandType.chat) {
throw ArgumentError("Context menus cannot have description");
}
}