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, name, username
will be not null anymore.
Also, if the token
is valid, onReady
gets called.
Otherwise onStartFailed
gets called instead.
If onReady
or onStartFailed
throw an exception,
it is currently only logged in the logger.
Make sure to catch exception if something may fail.
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();
}