28 lines
700 B
JavaScript
28 lines
700 B
JavaScript
|
const command = {
|
||
|
name: "google",
|
||
|
desc: "google search",
|
||
|
restricted: false,
|
||
|
mod: false,
|
||
|
run: async (client, msg, splitted) => {
|
||
|
const data = await fetch(
|
||
|
`https://searx.chocoflan.net/search?q=${splitted[2]}&format=json&engines=google`
|
||
|
)
|
||
|
.then((res) => res.json())
|
||
|
.catch((err) => console.log(err));
|
||
|
|
||
|
if (data.results.length < 1) {
|
||
|
await client.say(
|
||
|
msg.channelName,
|
||
|
`${msg.displayName}, no results found or api is down`
|
||
|
);
|
||
|
}
|
||
|
|
||
|
await client.say(
|
||
|
msg.channelName,
|
||
|
`${msg.displayName}, First result for query ${splitted[2]}: ${data.title} - ${data.content} ${data.url}`
|
||
|
);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
module.exports = { command };
|