Add google command

This commit is contained in:
Dragon Fire
2024-05-10 10:06:44 -04:00
parent ae10f35dee
commit d8f596740c
2 changed files with 48 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
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}>
`);
}
};
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "151.0.0",
"version": "151.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"private": true,
@@ -52,6 +52,7 @@
"font-finder": "^1.1.0",
"gifencoder": "^2.0.1",
"gm": "^1.25.0",
"googlethis": "^1.8.0",
"html-entities": "^2.5.2",
"image-to-ascii": "^3.2.0",
"ioredis": "^5.4.1",