mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 14:45:27 +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');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const Warn = require('../../stores/warn');
|
const { getWarns } = require('../../stores/warn');
|
||||||
const admins = require('../../stores/admin');
|
const admins = require('../../stores/admin');
|
||||||
|
|
||||||
const getWarnsHandler = async ({ message, reply }) => {
|
const getWarnsHandler = async ({ message, reply }) => {
|
||||||
@@ -19,8 +19,12 @@ const getWarnsHandler = async ({ message, reply }) => {
|
|||||||
}
|
}
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const theUser = message.reply_to_message.from;
|
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` +
|
return reply(`⚠️ <b>Warns for</b> ${link(theUser)}:\n\n` +
|
||||||
(await Warn.getWarns(theUser))
|
warns
|
||||||
.map(warn => ++i + '. ' + warn)
|
.map(warn => ++i + '. ' + warn)
|
||||||
.join('\n\n'), replyOptions);
|
.join('\n\n'), replyOptions);
|
||||||
};
|
};
|
||||||
|
@@ -8,7 +8,7 @@ const { logError } = require('../../utils/log');
|
|||||||
const { replyOptions } = require('../../bot/options');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const { nowarns } = require('../../stores/warn');
|
const { getWarns, nowarns } = require('../../stores/warn');
|
||||||
const admins = require('../../stores/admin');
|
const admins = require('../../stores/admin');
|
||||||
|
|
||||||
const nowarnsHandler = async ({ message, reply }) => {
|
const nowarnsHandler = async ({ message, reply }) => {
|
||||||
@@ -21,7 +21,12 @@ const nowarnsHandler = async ({ message, reply }) => {
|
|||||||
|
|
||||||
const messageToUnwarn = message.reply_to_message;
|
const messageToUnwarn = message.reply_to_message;
|
||||||
const userToUnwarn = messageToUnwarn.from;
|
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 {
|
try {
|
||||||
await nowarns(userToUnwarn);
|
await nowarns(userToUnwarn);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Reference in New Issue
Block a user