mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
Add google command
This commit is contained in:
@@ -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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "151.0.0",
|
"version": "151.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
"font-finder": "^1.1.0",
|
"font-finder": "^1.1.0",
|
||||||
"gifencoder": "^2.0.1",
|
"gifencoder": "^2.0.1",
|
||||||
"gm": "^1.25.0",
|
"gm": "^1.25.0",
|
||||||
|
"googlethis": "^1.8.0",
|
||||||
"html-entities": "^2.5.2",
|
"html-entities": "^2.5.2",
|
||||||
"image-to-ascii": "^3.2.0",
|
"image-to-ascii": "^3.2.0",
|
||||||
"ioredis": "^5.4.1",
|
"ioredis": "^5.4.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user