getConfirmation method

  1. @override
Future<bool> getConfirmation(
  1. MessageBuilder builder,
  2. {Map<bool, String> values = const {true : 'Yes', false : 'No'},
  3. Map<bool, ButtonStyle> styles = const {true : ButtonStyle.success, false : ButtonStyle.danger},
  4. bool authorOnly = true,
  5. ResponseLevel? level,
  6. Duration? timeout}
)
inherited

Present the user with two options and return whether the positive one was clicked.

If styles is set, the style of a button presenting a given option will depend on the value set in the map. values can also be set to change the text displayed on each button.

If timeout is set, this method will complete with an error after timeout has passed.

If authorOnly is set, only the author of this interaction will be able to interact with a button.

level will change the level at which the message is sent, similarly to respond.

Implementation

@override
Future<bool> getConfirmation(
  MessageBuilder builder, {
  Map<bool, String> values = const {true: 'Yes', false: 'No'},
  Map<bool, ButtonStyle> styles = const {true: ButtonStyle.success, false: ButtonStyle.danger},
  bool authorOnly = true,
  ResponseLevel? level,
  Duration? timeout,
}) =>
    getButtonSelection(
      [true, false],
      builder,
      toButton: (value) => ButtonBuilder(
        style: ButtonStyle.primary,
        label: values[value] ?? (value ? 'Yes' : 'No'),
        customId: '',
      ),
      styles: styles,
      authorOnly: authorOnly,
      level: level,
      timeout: timeout,
    );