Browse Source

Use new logger for commands

pull/28/head
Abheek Dhawan 3 years ago
parent
commit
ad1f6c3139
Signed by: abheekd GPG Key ID: 7BE81B8C14475B67
  1. 3
      commands/rounds.js
  2. 5
      commands/top.js
  3. 14
      commands/train.js

3
commands/rounds.js

@ -3,6 +3,7 @@ const { MessageEmbed } = require('discord.js');
const axios = require('axios');
const { log } = require('../helpers/log');
const generatedRound = require('../models/generateRound');
module.exports = {
@ -66,7 +67,7 @@ module.exports = {
newGeneratedRound.save((err, round) => {
if (err) {
console.log(err);
log({ logger: 'rounds', content: `Saving round to DB failed: ${err}`, level: 'error' });
return;
}
interaction.reply(`Here's your round: https://api.adawesome.tech/round/${round._id.toString()}`, { ephemeral: true });

5
commands/top.js

@ -1,6 +1,7 @@
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
const { log } = require('../helpers/log');
const userScore = require('../models/userScore');
module.exports = {
@ -14,10 +15,8 @@ module.exports = {
.sort({ score: -1 }) // Sort by descending order
.exec((err, obj) => {
if (err) {
log({ logger: 'top', content: `Getting top players failed: ${err}`, level: 'error' });
console.log(err);
return interaction.reply(
'Uh oh! :( There was an internal error. Please try again.',
);
}
if (obj.length < 10) {
// Need at least 10 scores for top 10

14
commands/train.js

@ -6,6 +6,7 @@ const axios = require('axios');
const userScore = require('../models/userScore');
const { log } = require('../helpers/log.js');
const { updateScore } = require('../helpers/db.js');
module.exports = {
@ -42,7 +43,7 @@ module.exports = {
score = obj.score;
}
else {
console.log(err);
log({ logger: 'train', content: `Getting user score failed: ${err}`, level: 'error' });
}
});
@ -102,7 +103,6 @@ module.exports = {
max: 1,
})
.then(collected => {
console.log(collected.first());
const answerMsg = collected.first();
let predicted = null;
@ -159,11 +159,11 @@ module.exports = {
updateScore(true, score, authorId).then((msgToReply) =>
answerMsg.reply(msgToReply),
);
}).catch(console.error);
}).catch(console.error);
}).catch(err => log({ logger: 'train', content: `Failed to override score: ${err}`, level: 'error' }));
}).catch(err => log({ logger: 'train', content: `Failed to send override message: ${err}`, level: 'error' }));
}
}).catch(console.error);
}).catch(console.error);
}).catch(console.error);
}).catch(err => log({ logger: 'train', content: `${err}`, level: 'error' }));
}).catch(err => log({ logger: 'train', content: `${err}`, level: 'error' }));
}).catch(err => log({ logger: 'train', content: `${err}`, level: 'error' }));
},
};

Loading…
Cancel
Save