From 7daa076d8da3e8084b7407bf004fe7fd1edc8b81 Mon Sep 17 00:00:00 2001 From: Mai Sakurajima Date: Thu, 24 Sep 2020 03:30:08 +0800 Subject: [PATCH] Catch Unhandled Promise Rejection --- utilities/Add XP.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities/Add XP.js b/utilities/Add XP.js index 2e0adb53..68411f03 100644 --- a/utilities/Add XP.js +++ b/utilities/Add XP.js @@ -17,11 +17,11 @@ module.exports = (guildID, userID, xp) => { return new Promise((resolve,reject)=>{ xpSchema.findOne({ guildID, userID }, async (err,data) => { - if (err) reject('Unable to connecto to database') + if (err) return reject('Unable to connecto to database') if (!data) data = await new xpSchema({ guildID, userID }).save().catch(()=>null) - if (!data) reject('Unable to save new document') + if (!data) return reject('Unable to save new document') let cap = 150 * (data.level * 2) let next = cap * data.level