-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCyber1tak.js
31 lines (21 loc) · 997 Bytes
/
Cyber1tak.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import fs from 'fs/promises';
import config from '../../config.cjs';
const handleTakeCommand = async (m, gss) => {
const prefix = config.PREFIX;
const [cmd, ...args] = m.body.startsWith(prefix) ? m.body.slice(prefix.length).split(' ') : ['', ''];
if (cmd !== 'take') return;
const [providedPackname, providedAuthor] = args.join(' ').split('|');
if (!providedPackname || !providedAuthor) {
return m.reply('Usage: /take pkgname|author');
}
global.packname = providedPackname;
global.author = providedAuthor;
const quoted = m.quoted || {};
if (!['imageMessage', 'videoMessage', 'stickerMessage'].includes(quoted.mtype)) {
return m.reply(`Send/Reply with an image or video to use ${prefix + cmd}`);
}
const mediaBuffer = await quoted.download();
if (!mediaBuffer) throw new Error('Failed to download media.');
await gss.sendImageAsSticker(m.from, mediaBuffer, m, { packname: global.packname, author: global.author });
};
export default handleTakeCommand;