Added error reporting functionality, fixed bugs in the various game's code and tidied up a bit

This commit is contained in:
ION606
2022-07-19 15:41:49 +03:00
parent 4e1214a312
commit 0b13f6db29
13 changed files with 259 additions and 79 deletions
+5 -2
View File
@@ -108,7 +108,7 @@ function postActionBar(interaction, user_dbo, board, won, initial = false) {
}
}
console.log(componentlist);
// console.log(componentlist);
if (initial) {
interaction.send({ content: `Your turn <@${user_dbo.s.namespace.collection}>!`, components: componentlist });
@@ -124,12 +124,15 @@ async function handle(client, db, dbo, other, bot, thread, command, doc, interac
let board = ["", "", "", "", "", "", "", "", ""];
postActionBar(thread, dbo, board, false,true);
} else {
//Change the board
let square = Number(interaction.customId.split('|')[1]);
let symbol = doc.symbols[doc.turn];
let board = doc.board;
board[square] = symbol;
client.db('B|S' + bot.user.id).collection(dbo.s.namespace.db.substr(0, dbo.s.namespace.db.length - 6)).updateOne({'board': {$exists: true}}, {$set: {board: board}});
const gamedbo = client.db('B|S' + bot.user.id).collection(interaction.guildId);
gamedbo.updateOne({$or: [ {0: interaction.user.id}, {1: interaction.user.id} ], 'board': {$exists: true}}, {$set: {board: board}});
//Check if the game is over
let won = isTerminal(board);