mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Validate FEN
This commit is contained in:
@@ -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)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user