Search the web with a simple and easy slash command! To make the command read the comments on lines 3 and 4. Credit to Hakiki for his google img snippet which I use in this code
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const gis = require('g-i-s');
//IMPORTANT: To make the slash command do this, Create a command and name it google
//IMPORTANT: Then make a string option and name that search, then click save and you're done!
let search = context.params.event.data.options[0].value
let imageQuery = context.params.event.data.options[0].value
let actualSearch = search.split(' ').join('-')
await new Promise((resolve, reject) => {
gis(`${imageQuery}`, async function findImage(err, res) {
await lib.discord.channels['@0.2.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `<@${context.params.event.member.user.id}>`,
embeds: [{
type: `rich`,
title: ``,
description: `Here are the results for your search ${context.params.event.member.user.username}...\n\nSearch: ||${search}||\n\nLink: [Click Here](https://www.google.com/search?q=${actualSearch})`,
color: 0xFFFFFF,
author: {name: `Google Search Query`, icon_url: `https://cdn.discordapp.com/attachments/890358551682355210/916916322640752650/Google.png`},
image: {url: `${res[0].url}`}
}]
});
})
})