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
+7 -2
View File
@@ -1,6 +1,7 @@
//@ts-check
const { addxp, STATE, BASE } = require("../db/econ");
const turnManger = require('../turnManager.js');
const { addComplaintButton } = require('../dev only/submitcomplaint');
//#region game lose/win
@@ -8,7 +9,11 @@ function loseGame(user_dbo, xp_collection, message, bot = null) {
return new Promise(function(resolve, reject) {
user_dbo.find({"game": {$exists: true}}).toArray(function(err, docs){
const doc = docs[0];
if (doc == undefined) { return message.reply("Oops! There's been an error! Please contact support if this problem persists!"); }
if (doc == undefined) {
message.reply("Oops! There's been an error, click the ✅ to report this!");
addComplaintButton(bot, message);
return;
}
if (doc.game == null) { return message.reply("You're not even in a game and you're trying to quit! Sad..."); }
var addbal;
@@ -49,7 +54,7 @@ function winGame(client, bot, db, user_dbo, xp_collection, message) {
}
//Delete the bot's record of the game
client.db('B|S' + bot.user.id).collection(user_dbo.s.namespace.db.substr(0, user_dbo.s.namespace.db.length - 6)).drop();
client.db('B|S' + bot.user.id).collection(message.guild.id).drop();
//Update the player with xp