SlashCommandBuilder constructor

SlashCommandBuilder(
  1. String name,
  2. String? description,
  3. List<CommandOptionBuilder> options, {
  4. bool defaultPermissions = true,
  5. List<ICommandPermissionBuilder>? permissions,
  6. Snowflake? guild,
  7. 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");
  }
}