mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-03 15:45:20 +00:00
Logging fix
This commit is contained in:
18
index.js
18
index.js
@@ -35,7 +35,7 @@ bot.use(async (ctx, next) => {
|
|||||||
`${link(ctx.from)} <b>banned</b>!\n` +
|
`${link(ctx.from)} <b>banned</b>!\n` +
|
||||||
`Reason: ${banned}`,
|
`Reason: ${banned}`,
|
||||||
replyOptions))
|
replyOptions))
|
||||||
.catch(logError)
|
.catch(logError(DEBUG))
|
||||||
.then(next);
|
.then(next);
|
||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
@@ -50,7 +50,7 @@ bot.command('warn', async ({ message, chat, reply }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return;
|
return reply('Reply to a message');
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageToWarn = message.reply_to_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, messageToWarn.message_id),
|
||||||
bot.telegram.deleteMessage(chat.id, message.message_id)
|
bot.telegram.deleteMessage(chat.id, message.message_id)
|
||||||
];
|
];
|
||||||
|
|
||||||
if (warnCount < 3) {
|
if (warnCount < 3) {
|
||||||
promises.push(reply(
|
promises.push(reply(
|
||||||
`${link(userToWarn)} warned! (${warnCount}/3)\n` +
|
`${link(userToWarn)} warned! (${warnCount}/3)\n` +
|
||||||
@@ -81,7 +82,18 @@ bot.command('warn', async ({ message, chat, reply }) => {
|
|||||||
replyOptions));
|
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();
|
bot.startPolling();
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
const { inspect } = require('util');
|
const { inspect } = require('util');
|
||||||
|
|
||||||
const logError = err =>
|
const logError = log => err =>
|
||||||
console.error(`${err.name}: ${err.message}`);
|
log && console.error(`${err.name}: ${err.message}`);
|
||||||
|
|
||||||
const print = value =>
|
const print = value =>
|
||||||
console.log(inspect(value, { colors: true, depth: null }));
|
console.log(inspect(value, { colors: true, depth: null }));
|
||||||
|
Reference in New Issue
Block a user