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 pathringtone.js
46 lines (44 loc) · 1.29 KB
/
ringtone.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
const {
Function,
ringtone,
isPublic,
prefix,
parsedUrl
} = require("../lib/");
const t = "```";
Function({
pattern: 'ringtone ?(.*)',
fromMe: isPublic,
desc: 'download ringtone',
type: 'download'
}, async (message, match) => {
if (!match) return await message.reply('_Example : ringtone the box_')
const result = await ringtone(match)
if (result) {
const list = [];
let no = 1;
let msg = `${t}Search results for ${match}:${t}\n_To download, please reply with the desired ringtone number._\n\n`;
const indices = new Set();
for (var main = 0; main < result.length; main++) {
const randomIndex = Math.floor(Math.random() * result.length);
if (!indices.has(randomIndex)) {
indices.add(randomIndex);
msg += `${no++}. *${result[randomIndex].title}*\n*link* : ${result[randomIndex].source}\n*mp3* : ${result[randomIndex].audio}\n\n`
}
}
await message.send(msg, { quoted: m.data })
}
})
Function({
pattern: 'upload ?(.*)',
fromMe: isPublic,
desc: 'sendFromUrl',
type: 'download'
}, async (message, match) => {
match = match || message.reply_message.text
if (!match) return await message.reply('_Missing Url!_')
const Url = await parsedUrl(match)
for (let url of Url) {
await message.client.sendFromUrl(message.jid, url, message.data)
}
})