SlashCommandBuilder constructor
SlashCommandBuilder(
- String name,
- String? description,
- List<
CommandOptionBuilder> options, { - bool canBeUsedInDm = true,
- int? requiredPermissions,
- Snowflake? guild,
- SlashCommandType type = SlashCommandType.chat,
- @Deprecated('Use canBeUsedInDm and requiredPermissions instead') bool defaultPermissions = true,
- @Deprecated('Use canBeUsedInDm and requiredPermissions instead') List<
CommandPermissionBuilderAbstract> ? permissions, - Map<
Locale, String> ? localizationsName, - Map<
Locale, String> ? localizationsDescription, - 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");
}
}