diff --git a/lib/src/internal/_Constants.dart b/lib/src/internal/_Constants.dart index c811736..17281c9 100644 --- a/lib/src/internal/_Constants.dart +++ b/lib/src/internal/_Constants.dart @@ -19,7 +19,7 @@ class _OPCodes { /// The client constants. class _Constants { static const String host = "https://discordapp.com/api/v6"; - static const String version = "0.14.0"; + static const String version = "0.14.1"; /// The gateway OP codes. static const Map opCodes = const { diff --git a/lib/src/internal/_WS.dart b/lib/src/internal/_WS.dart index 06d479e..3d319f1 100644 --- a/lib/src/internal/_WS.dart +++ b/lib/src/internal/_WS.dart @@ -60,7 +60,7 @@ class _WS { } void connectShard(int index) { - this.client.shards.values.toList()[index]._connect(); + this.client.shards.values.toList()[index]._connect(true, true); if (index + 1 != this.client._options.shardIds.length) new Timer(new Duration(seconds: 6), () => connectShard(index + 1)); } diff --git a/lib/src/objects/Guild.dart b/lib/src/objects/Guild.dart index 173e09b..5f0cdda 100644 --- a/lib/src/objects/Guild.dart +++ b/lib/src/objects/Guild.dart @@ -111,10 +111,12 @@ class Guild extends _BaseObj { data['presences'].forEach((Map o) { Member member = this.members[o['user']['id']]; - member.status = o['status']; - if (o['game'] != null) { - member.game = - new Game._new(client, o['game'] as Map); + if (member != null) { + member.status = o['status']; + if (o['game'] != null) { + member.game = + new Game._new(client, o['game'] as Map); + } } }); diff --git a/lib/src/objects/Shard.dart b/lib/src/objects/Shard.dart index 255f922..763cd30 100644 --- a/lib/src/objects/Shard.dart +++ b/lib/src/objects/Shard.dart @@ -26,10 +26,12 @@ class Shard extends _BaseObj { this.onError = new StreamController.broadcast(); } - void _connect([bool resume = true]) { + void _connect([bool resume = true, bool init = false]) { this.ready = false; - if (this._socket != null) { - this._socket.close(); + if (this._socket != null) this._socket.close(); + if (!init) { + new Timer(new Duration(seconds: 2), () => _connect(resume)); + return; } new _WebSocket() .connect('${this._ws.gateway}?v=6&encoding=json', diff --git a/pubspec.yaml b/pubspec.yaml index 55efe45..5b91f5b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: discord -version: 0.14.0 +version: 0.14.1 description: A Discord library for Dart author: Hackzzila homepage: https://hackzzila.github.io/Discord-Dart/