Skip to content

Commit

Permalink
Catch Unhandled Promise Rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
maisans-maid committed Sep 23, 2020
1 parent 98274de commit 7daa076
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utilities/Add XP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7daa076

Please sign in to comment.