Search images on google through discord with the !img <searchQuery> command!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const image_finder = require('image-search-engine');
const {channel_id, content} = context.params.event;
const imgQuery = content.trim().split(' ').slice(1).join(' ');
if (!imgQuery)
return await lib.discord.channels['@0.3.0'].messages.create({
channel_id,
content: 'Please provide a query string.',
});
const randomImgURL = await image_finder.find(imgQuery);
const result = await lib.http.request['@1.1.6']({
method: 'GET',
url: randomImgURL,
});
const file = result.body;
await lib.discord.channels['@0.3.0'].messages.create({
channel_id,
content: '',
attachments: [
{
file,
filename: `RandomImage.jpg`,
description: `Random Image`,
},
],
});