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

Add /del; closes #83

This commit is contained in:
Wojciech Pawlik
2020-02-06 12:20:49 +01:00
parent 8e557eca2b
commit 661941b0aa

26
handlers/commands/del.js Normal file
View File

@@ -0,0 +1,26 @@
'use strict';
const { parse } = require('../../utils/parse');
const { scheduleDeletion } = require('../../utils/tg');
module.exports = async (ctx) => {
if (ctx.from.status !== 'admin') return;
const { flags, reason } = parse(ctx.message);
if (!(flags.has('msg_id') || ctx.message.reply_to_message)) {
// eslint-disable-next-line max-len
await ctx.replyWithHTML(' <b>Reply to a message you\'d like to delete</b>').then(scheduleDeletion());
return;
}
await ctx.tg.deleteMessage(
flags.get('chat_id') || ctx.chat.id,
flags.get('msg_id') || ctx.message.reply_to_message.message_id
);
if (reason) {
await ctx.reply(`🗑 ${reason}`);
}
};