Skip to content

Commit d7856d1

Browse files
committed
Support for discord's latest feature
1 parent 56cb66f commit d7856d1

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

lib/src/objects/Game.dart

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of discord;
22

33
/// A game.
4-
class Game extends _BaseObj {
4+
class Game {
55
/// The game name.
66
String name;
77

@@ -11,9 +11,22 @@ class Game extends _BaseObj {
1111
/// The game URL, if provided.
1212
String url;
1313

14-
Game._new(Client client, Map<String, dynamic> data) : super(client) {
15-
this.name = data['name'];
16-
this.url = data['url'];
14+
/// Makes a new game object.
15+
Game(this.name, {this.type: 0, this.url});
16+
17+
Game._new(Client client, Map<String, dynamic> data) {
18+
try {
19+
this.name = data['name'].toString();
20+
} catch (err) {
21+
this.name = null;
22+
}
23+
24+
try {
25+
this.url = data['url'].toString();
26+
} catch (err) {
27+
this.url = null;
28+
}
29+
1730
if (data['type'] is int) {
1831
this.type = data['type'];
1932
} else if (data['type'] is String) {
@@ -24,4 +37,12 @@ class Game extends _BaseObj {
2437
}
2538
}
2639
}
40+
41+
Map<String, dynamic> _toMap() {
42+
Map<String, dynamic> map = new Map<String, dynamic>();
43+
map['name'] = this.name;
44+
map['type'] = this.type;
45+
map['url'] = this.url;
46+
return map;
47+
}
2748
}

0 commit comments

Comments
 (0)