SlashCommandBuilder constructor

SlashCommandBuilder(
  1. String name,
  2. String? description,
  3. List<CommandOptionBuilder> options, {
  4. bool canBeUsedInDm = true,
  5. int? requiredPermissions,
  6. Snowflake? guild,
  7. SlashCommandType type = SlashCommandType.chat,
  8. @Deprecated('Use canBeUsedInDm and requiredPermissions instead') bool defaultPermissions = true,
  9. @Deprecated('Use canBeUsedInDm and requiredPermissions instead') List<CommandPermissionBuilderAbstract>? permissions,
  10. Map<Locale, String>? localizationsName,
  11. Map<Locale, String>? localizationsDescription,
  12. bool? isNsfw,
})

A slash command, can only be instantiated through a method on IInteractions

Implementation

SlashCommandBuilder(
  this.name,
  this.description,
  this.options, {
  this.canBeUsedInDm = true,
  this.requiredPermissions,
  this.guild,
  this.type = SlashCommandType.chat,
  @Deprecated('Use canBeUsedInDm and requiredPermissions instead') this.defaultPermissions = true,
  @Deprecated('Use canBeUsedInDm and requiredPermissions instead') this.permissions,
  this.localizationsName,
  this.localizationsDescription,
  this.isNsfw,
}) {
  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");
  }
}