registerGlobal method

  1. @override
Future<void> registerGlobal(
  1. Bot bot
)
override

Implementation

@override
Future<void> registerGlobal(Bot bot) async {
  final List<CommandBuilder> globalCommands = _getContext(
    CommandContextType.global,
  );
  final payload = _serializeCommand(globalCommands);

  final req = Request.json(
    endpoint: '/applications/${bot.id}/commands',
    body: payload,
  );

  // Routed through the rate-limit bucket (not `_dataStore.client`
  // directly) so backoff and bucket accounting apply, and any non-success
  // status raises instead of completing as a silent success (#470).
  await _dataStore.requestBucket.put<dynamic>(
    req,
    onError: (response) =>
        _registrationFailure(response, scope: 'application ${bot.id}'),
  );
}