Bot constructor
Bot({})
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();
}