mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
Validate FEN
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
|
const validateFEN = require('fen-validator').default;
|
||||||
|
|
||||||
module.exports = class ChessSetUpCommand extends Command {
|
module.exports = class ChessSetUpCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -12,7 +13,8 @@ module.exports = class ChessSetUpCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'fen',
|
key: 'fen',
|
||||||
prompt: 'What FEN would you like to use for the game?',
|
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;
|
blackPlayer = data.color === 'black' ? msg.author : opponent;
|
||||||
await this.client.redis.del(`chess-${msg.author.id}`);
|
await this.client.redis.del(`chess-${msg.author.id}`);
|
||||||
} catch {
|
} catch {
|
||||||
await msg.reply('An error occurred reading your saved game. Deleting it and aborting...');
|
this.client.games.delete(msg.channel.id);
|
||||||
game = new jsChess.Game();
|
|
||||||
whiteTime = time * 60000;
|
|
||||||
blackTime = time * 60000;
|
|
||||||
whitePlayer = msg.author;
|
|
||||||
blackPlayer = opponent;
|
|
||||||
await this.client.redis.del(`chess-${msg.author.id}`);
|
await this.client.redis.del(`chess-${msg.author.id}`);
|
||||||
|
return msg.reply('An error occurred reading your saved game. Please try again.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
game = new jsChess.Game();
|
game = new jsChess.Game();
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
"emoji-regex": "^9.2.1",
|
"emoji-regex": "^9.2.1",
|
||||||
"eslint": "^7.19.0",
|
"eslint": "^7.19.0",
|
||||||
"expr-eval": "^2.0.2",
|
"expr-eval": "^2.0.2",
|
||||||
|
"fen-validator": "^1.4.1",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"gm": "^1.23.1",
|
"gm": "^1.23.1",
|
||||||
"html-entities": "^2.1.0",
|
"html-entities": "^2.1.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user