forked from A-d-i-t-h-y-a-n/hermit-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.js
62 lines (52 loc) · 1.72 KB
/
cmd.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const {
Function,
setCmd,
delCmd,
prepareCmd,
getCmdList,
isPublic
} = require("../lib/");
Function({
pattern: 'setcmd ?(.*)',
fromMe: true,
desc: 'To set audio/image/video as a command',
type: 'user'
}, async (message, match, client) => {
if (!message.quoted) return await message.reply('_Reply to an image/video/audio/sticker_');
if (!match) return await message.reply('_Example: setcmd ping_');
if (!message.quoted.data.message[message.quoted.mtype].fileSha256) return await message.reply('_Failed_');
const setcmd = await setCmd(message, match);
if (!setcmd) return await message.reply('_Failed_');
await message.reply('_Success_');
});
Function({
pattern: 'delcmd ?(.*)',
fromMe: true,
desc: 'To delete audio/image/video command',
type: 'user'
}, async (message, match, client) => {
if (!message.quoted) return await message.reply('_Reply to an image/video/audio/sticker_');
let hash = message.quoted.data.message[message.quoted.mtype].fileSha256.toString('base64');
if (!hash) return await message.reply('_Failed_');
const delcmd = await delCmd(message);
if (!delcmd) return await message.reply('_Failed_');
await message.reply('_Success_');
});
Function({
pattern: 'listcmd ?(.*)',
fromMe: true,
desc: 'To get list of commands',
type: 'user'
}, async (message) => {
const cmd = await getCmdList();
await message.reply(cmd);
});
const mediaTypes = ['audio', 'sticker', 'video', 'image'];
mediaTypes.forEach(type => {
Function({
on: type,
fromMe: isPublic
}, async (message) => {
await prepareCmd(message);
});
});