File size: 723 Bytes
bb69f9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const { bot, googleImageSearch } = require('../lib')

bot(
  {
    pattern: 'img ?(.*)',
    desc: 'Download img from google',
    type: 'search',
  },
  async (message, match) => {
    if (!match) return await message.send('*Example :  img bot*\n*img 10 bot*')
    let lim = 3
    const count = /\d+/.exec(match)
    if (count) {
      match = match.replace(count[0], '')
      lim = count[0]
    }
    const result = await googleImageSearch(match)
    lim = (result.length && (result.length > lim ? lim : result.length)) || result.length
    await message.send(`_Downloading ${lim} images of ${match.trim()}_`)
    for (let i = 0; i < lim; i++) {
      await message.sendFromUrl(result[i], { buffer: false })
    }
  }
)