Skip to content

Commit fb78cc1

Browse files
authored
Merge pull request #93 from muchnameless/master
fix(Game): prevent error on unknown game
2 parents fb7cce6 + fad9499 commit fb78cc1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/structures/Game.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Game {
4444
*/
4545
constructor (game) {
4646
this.game = game;
47-
this.id = (games.find((g) => g.code === this.game || g.id === this.game).id ? games.find((g) => g.code === this.game || g.id === this.game).id : 'Not found');
48-
this.code = (games.find((g) => g.code === this.game || g.id === this.game).code ? games.find((g) => g.code === this.game || g.id === this.game).code : 'Not found');
47+
this.id = (games.some((g) => g.code === this.game || g.id === this.game) ? games.find((g) => g.code === this.game || g.id === this.game).id : 'Not found');
48+
this.code = (games.some((g) => g.code === this.game || g.id === this.game) ? games.find((g) => g.code === this.game || g.id === this.game).code : 'Not found');
4949
}
5050

5151
/**
@@ -54,9 +54,9 @@ class Game {
5454
*/
5555
toString () {
5656
if (isNaN(this.game)) {
57-
return games.find((g) => g.code === this.game) ? games.find((g) => g.code === this.game).name : 'Not found';
57+
return games.some((g) => g.code === this.game) ? games.find((g) => g.code === this.game).name : 'Not found';
5858
} else {
59-
return games.find((g) => g.id === this.game) ? games.find((g) => g.id === this.game).name : 'Not found';
59+
return games.some((g) => g.id === this.game) ? games.find((g) => g.id === this.game).name : 'Not found';
6060
}
6161
}
6262
}

0 commit comments

Comments
 (0)