2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-31 22:25:15 +00:00

Improve /del

This commit is contained in:
Wojciech Pawlik
2020-02-12 17:25:29 +01:00
parent 11da9c9ba2
commit 096d8fe1ff
4 changed files with 16 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ const masterCommands = `\
const adminCommands = `\
<b>Admin commands</b>:
<code>/del [reason]</code> - Deletes replied-to message.
<code>/warn &lt;reason&gt;</code> - Warns the user.
<code>/unwarn</code> - Removes the last warn from the user.
<code>/nowarns</code> - Clears warns for the user.

View File

@@ -1,8 +1,10 @@
'use strict';
const { parse } = require('../../utils/parse');
const html = require('tg-html');
const R = require('ramda');
const { scheduleDeletion } = require('../../utils/tg');
const { parse } = require('../../utils/parse');
const { link, scheduleDeletion } = require('../../utils/tg');
module.exports = async (ctx) => {
if (ctx.from.status !== 'admin') return;
@@ -21,6 +23,11 @@ module.exports = async (ctx) => {
);
if (reason) {
await ctx.reply(`🗑 ${reason}`);
const emoji = link({
id: R.path([ 'message', 'reply_to_message', 'from', 'id' ], ctx),
first_name: '🗑',
});
await ctx.replyWithHTML(html`${emoji} ${reason}`)
.then(scheduleDeletion());
}
};