mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 21:55:17 +00:00
getwarns and nowarns now check if there are warnings
This commit is contained in:
@@ -7,7 +7,7 @@ const { link } = require('../../utils/tg');
|
||||
const { replyOptions } = require('../../bot/options');
|
||||
|
||||
// DB
|
||||
const Warn = require('../../stores/warn');
|
||||
const { getWarns } = require('../../stores/warn');
|
||||
const admins = require('../../stores/admin');
|
||||
|
||||
const getWarnsHandler = async ({ message, reply }) => {
|
||||
@@ -19,8 +19,12 @@ const getWarnsHandler = async ({ message, reply }) => {
|
||||
}
|
||||
let i = 0;
|
||||
const theUser = message.reply_to_message.from;
|
||||
const warns = await getWarns(theUser);
|
||||
if (warns.length < 1) {
|
||||
return reply(`✅ <b>no warns for:</b> ${link(theUser)}`, replyOptions);
|
||||
}
|
||||
return reply(`⚠️ <b>Warns for</b> ${link(theUser)}:\n\n` +
|
||||
(await Warn.getWarns(theUser))
|
||||
warns
|
||||
.map(warn => ++i + '. ' + warn)
|
||||
.join('\n\n'), replyOptions);
|
||||
};
|
||||
|
@@ -8,7 +8,7 @@ const { logError } = require('../../utils/log');
|
||||
const { replyOptions } = require('../../bot/options');
|
||||
|
||||
// DB
|
||||
const { nowarns } = require('../../stores/warn');
|
||||
const { getWarns, nowarns } = require('../../stores/warn');
|
||||
const admins = require('../../stores/admin');
|
||||
|
||||
const nowarnsHandler = async ({ message, reply }) => {
|
||||
@@ -21,7 +21,12 @@ const nowarnsHandler = async ({ message, reply }) => {
|
||||
|
||||
const messageToUnwarn = message.reply_to_message;
|
||||
const userToUnwarn = messageToUnwarn.from;
|
||||
const warns = await getWarns(userToUnwarn);
|
||||
|
||||
if (warns.length < 1) {
|
||||
return reply(`ℹ️ ${link(userToUnwarn)} <b>already has no warnings.</b>`,
|
||||
replyOptions);
|
||||
}
|
||||
try {
|
||||
await nowarns(userToUnwarn);
|
||||
} catch (err) {
|
||||
|
Reference in New Issue
Block a user