Files
xiao/commands/search/google.js
T
Dragon Fire 46349f3363 Fix
2024-05-10 10:11:09 -04:00

47 lines
973 B
JavaScript

const Command = require('../../framework/Command');
const google = require('googlethis');
const { stripIndents } = require('common-tags');
module.exports = class GoogleCommand extends Command {
constructor(client) {
super(client, {
name: 'google',
aliases: ['google-this', 'search'],
group: 'search',
memberName: 'google',
description: 'Searches Google.',
credit: [
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Search Results'
}
],
args: [
{
key: 'query',
type: 'string'
}
]
});
}
async run(msg, { query }) {
const { results } = await google.search(query, {
page: 0,
safe: !msg.channel.nsfw,
parse_ads: false,
additional_params: {
hl: 'en'
}
});
if (!results.length) return msg.reply('Could not find any results.');
const result = results[0];
return msg.reply(stripIndents`
**${result.title}**
${result.description}
<${result.url}>
`);
}
};