Skip to content

Commit

Permalink
Fix bug where lichess links could show as undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroclutch committed May 22, 2024
1 parent 3364751 commit 6e17c2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
28 changes: 16 additions & 12 deletions games/Chess/classes/Chess.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ export default class Chess extends Game {
return (val.length == 1 ? '0' : '') + val
}
let pgn = `pgn=[Event "Gamebot Online Match"]
[Site "Discord"]
[Date "${_f(today.getUTCFullYear())}.${_f(today.getUTCMonth() + 1)}.${_f(today.getUTCDate())}"]
[Result "${winner}"]
[White "${this.getPlayer('White').user.tag}"]
[Black "${this.getPlayer('Black').user.tag}"]\n\n`
[Site "Discord"]
[Date "${_f(today.getUTCFullYear())}.${_f(today.getUTCMonth() + 1)}.${_f(today.getUTCDate())}"]
[Result "${winner}"]
[White "${this.getPlayer('White').user.tag}"]
[Black "${this.getPlayer('Black').user.tag}"]\n\n`
for(let i = 0; i < this.moves.length; i+=1) {
if(i % 2 === 0) {
pgn += (i / 2 + 1) + '. '
Expand All @@ -307,13 +307,17 @@ export default class Chess extends Game {
}

importGameToLichess(winner) {
this.lichessClient.importGame(this.getPGN(winner)).then(res => this.channel.send({
embeds: [{
title: 'View the computer analysis and game recap.',
description: `The moves and computer analysis are available at ${res.data.url}.`,
color: options.colors.info
}]
}))
this.lichessClient.importGame(this.getPGN(winner)).then(res =>
this.channel.send({
embeds: [{
title: 'View the computer analysis and game recap.',
description: `The moves and computer analysis are available at ${res.data.url}.`,
color: options.colors.info
}]
})
).catch(err => {
logger.error(err)
})
}

async analyzeBoard(side) {
Expand Down
4 changes: 2 additions & 2 deletions games/Chess/classes/LichessAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const LichessAPI = class LichessAPI {
constructor() {
}

async importGame(PGN) {
return await request({
importGame(PGN) {
return request({
method: 'post',
url: 'https://lichess.org/api/import',
data: PGN,
Expand Down

0 comments on commit 6e17c2d

Please sign in to comment.