2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-29 05:07:49 +00:00
the-guard-bot/actions/batchBan.js

19 lines
519 B
JavaScript
Raw Normal View History

2019-01-31 20:19:39 +01:00
'use strict';
const { batchBan, ensureExists } = require('../stores/user');
const { displayUser, escapeHtml } = require('../utils/tg');
module.exports = async ({ admin, reason, targets }) => {
const by_id = admin.id;
const date = new Date();
await Promise.all(targets.map(ensureExists));
const banned = await batchBan(targets, { by_id, date, reason });
const bannedString = banned.map(displayUser).join(', ');
return `${admin.first_name} <b>banned</b> ${bannedString} <b>for:</b>
2019-01-31 20:19:39 +01:00
${escapeHtml(reason)}`;
};