2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-03 07:35:17 +00:00

Logging fix

This commit is contained in:
Thomas Rory Gummerson
2017-07-24 15:41:16 +02:00
parent 9bd52ba77f
commit d20c9e8b57
2 changed files with 17 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ bot.use(async (ctx, next) => {
`${link(ctx.from)} <b>banned</b>!\n` +
`Reason: ${banned}`,
replyOptions))
.catch(logError)
.catch(logError(DEBUG))
.then(next);
}
return next();
@@ -50,7 +50,7 @@ bot.command('warn', async ({ message, chat, reply }) => {
return;
}
if (!message.reply_to_message) {
return;
return reply('Reply to a message');
}
const messageToWarn = message.reply_to_message;
@@ -66,6 +66,7 @@ bot.command('warn', async ({ message, chat, reply }) => {
bot.telegram.deleteMessage(chat.id, messageToWarn.message_id),
bot.telegram.deleteMessage(chat.id, message.message_id)
];
if (warnCount < 3) {
promises.push(reply(
`${link(userToWarn)} warned! (${warnCount}/3)\n` +
@@ -81,7 +82,18 @@ bot.command('warn', async ({ message, chat, reply }) => {
replyOptions));
}
return Promise.all(promises).catch(logError);
return Promise.all(promises).catch(logError(DEBUG));
});
bot.command('unwarn', async ({ message }) => {
if (!await admins.isAdmin(message.from)) {
return;
}
if (!message.reply_to_message) {
return reply('Reply to a message');
}
});
bot.startPolling();

View File

@@ -2,8 +2,8 @@
const { inspect } = require('util');
const logError = err =>
console.error(`${err.name}: ${err.message}`);
const logError = log => err =>
log && console.error(`${err.name}: ${err.message}`);
const print = value =>
console.log(inspect(value, { colors: true, depth: null }));