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:
26
handlers/commands/del.js
Normal file
26
handlers/commands/del.js
Normal 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}`);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user