Validate FEN

This commit is contained in:
Dragon Fire
2021-02-07 18:49:55 -05:00
parent a6d220c90b
commit 7cbbf879df
3 changed files with 6 additions and 7 deletions
+3 -1
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const validateFEN = require('fen-validator').default;
module.exports = class ChessSetUpCommand extends Command {
constructor(client) {
@@ -12,7 +13,8 @@ module.exports = class ChessSetUpCommand extends Command {
{
key: 'fen',
prompt: 'What FEN would you like to use for the game?',
type: 'string'
type: 'string',
validate: fen => validateFEN(fen)
}
]
});
+2 -6
View File
@@ -87,13 +87,9 @@ module.exports = class ChessCommand extends Command {
blackPlayer = data.color === 'black' ? msg.author : opponent;
await this.client.redis.del(`chess-${msg.author.id}`);
} catch {
await msg.reply('An error occurred reading your saved game. Deleting it and aborting...');
game = new jsChess.Game();
whiteTime = time * 60000;
blackTime = time * 60000;
whitePlayer = msg.author;
blackPlayer = opponent;
this.client.games.delete(msg.channel.id);
await this.client.redis.del(`chess-${msg.author.id}`);
return msg.reply('An error occurred reading your saved game. Please try again.');
}
} else {
game = new jsChess.Game();
+1
View File
@@ -49,6 +49,7 @@
"emoji-regex": "^9.2.1",
"eslint": "^7.19.0",
"expr-eval": "^2.0.2",
"fen-validator": "^1.4.1",
"gifencoder": "^2.0.1",
"gm": "^1.23.1",
"html-entities": "^2.1.0",