diff --git a/stores/admin.js b/stores/admin.js index e1a7865..9acabfb 100644 --- a/stores/admin.js +++ b/stores/admin.js @@ -1,5 +1,8 @@ 'use strict'; +// Utils +const { logError } = require('../utils/log'); + const Datastore = require('nedb-promise'); const Admin = new Datastore({ @@ -16,13 +19,15 @@ const admin = user => Admin.insert({ first_name: user.first_name, user_id: user.id, - }); + }) + .catch(logError(process.env.DEBUG)); const allAdmins = () => Admin.find({}); const unadmin = user => - Admin.remove({ user_id: user.id }); + Admin.remove({ user_id: user.id }) + .catch(logError(process.env.DEBUG)); const isAdmin = user => Admin.findOne({ user_id: user.id }); diff --git a/stores/ban.js b/stores/ban.js index 9d0956b..32a2386 100644 --- a/stores/ban.js +++ b/stores/ban.js @@ -1,5 +1,8 @@ 'use strict'; +// Utils +const { logError } = require('../utils/log'); + const Datastore = require('nedb-promise'); const Ban = new Datastore({ @@ -13,10 +16,12 @@ Ban.ensureIndex({ }); const ban = (user, reason) => - Ban.insert({ reason, user_id: user.id }); + Ban.insert({ reason, user_id: user.id }) + .catch(logError(process.env.DEBUG)); const unban = user => - Ban.remove({ user_id: user.id }); + Ban.remove({ user_id: user.id }) + .catch(logError(process.env.DEBUG)); const isBanned = user => Ban.findOne({ user_id: user.id }).then(bannedUser => diff --git a/stores/groups.js b/stores/groups.js index 14cef7e..9fe9337 100644 --- a/stores/groups.js +++ b/stores/groups.js @@ -1,5 +1,8 @@ 'use strict'; +// Utils +const { logError } = require('../utils/log'); + const Datastore = require('nedb-promise'); const groups = new Datastore({ @@ -13,7 +16,8 @@ groups.ensureIndex({ }); const addGroup = group => - groups.insert(group); + groups.insert(group) + .catch(logError(process.env.DEBUG)); const listGroups = () => groups.find({}); diff --git a/stores/user.js b/stores/user.js index 3a116d6..46eeedd 100644 --- a/stores/user.js +++ b/stores/user.js @@ -1,5 +1,8 @@ 'use strict'; +// Utils +const { logError } = require('../utils/log'); + const Datastore = require('nedb-promise'); const User = new Datastore({ @@ -13,7 +16,8 @@ User.ensureIndex({ }); const addUser = ({ id, first_name = '', last_name = '', username = '' }) => - User.insert({ first_name, id, last_name, username }); + User.insert({ first_name, id, last_name, username }) + .catch(logError(process.env.DEBUG)); const isUser = ({ id }) => User.findOne({ id }); diff --git a/stores/warn.js b/stores/warn.js index e45439c..2a17b90 100644 --- a/stores/warn.js +++ b/stores/warn.js @@ -1,5 +1,8 @@ 'use strict'; +// Utils +const { logError } = require('../utils/log'); + const Datastore = require('nedb-promise'); const Warn = new Datastore({ @@ -21,7 +24,8 @@ const warn = (user, reason) => Warn.update( { user_id: loadedUser.user_id }, { $push: { reasons: reason } }) - .then(() => loadedUser.reasons.length + 1)); + .then(() => loadedUser.reasons.length + 1)) + .catch(logError(process.env.DEBUG)); const unwarn = user => Warn.findOne({ user_id: user.id }) @@ -30,15 +34,16 @@ const unwarn = user => lastWarn && Warn.update( { user_id: user.id }, { $pop: { reasons: 1 } }) - .then(() => lastWarn)); + .then(() => lastWarn)) + .catch(logError(process.env.DEBUG)); const nowarns = user => Warn.findOne({ user_id: user.id }) .then(isUser => isUser && Warn.update( { user_id: user.id }, { $set: { reasons: [] } }) - .then(updatedUser => updatedUser) - ); + .then(updatedUser => updatedUser)) + .catch(logError(process.env.DEBUG)); const getWarns = user => Warn.findOne({ user_id: user.id })