Bot constructor

Bot({
  1. required String token,
  2. int timeout = 10,
  3. FutureOr onReady(
    1. Bot
    )?,
  4. FutureOr onStartFailed(
    1. Bot,
    2. Object,
    3. StackTrace
    )?,
  5. List<UpdateType>? allowedUpdates,
})

Create a new bot with the given token. As soon as bot is created, a getMe is called to validate the given token.

If the token is valid, id, username, name will be not nullable anymore.

Also, if the token is valid, onReady gets called. Otherwise onStartFailed gets called instead.

If onReady or onStartFailed throws an exception, it is currently only logged in the logger, make sure to catch exception if something may file

Implementation

Bot({
  required String token,
  int timeout = 10,
  FutureOr Function(Bot)? onReady,
  FutureOr Function(Bot, Object, StackTrace)? onStartFailed,
  this.allowedUpdates,
})  : _onReadyEvent = onReady,
      _timeout = timeout,
      _onStartFailedEvent = onStartFailed {
  this.token = token;
  _setup();
}