mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Google Autofill
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
const { Command } = require('discord.js-commando');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
|
||||||
|
module.exports = class GoogleAutofillCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'google-autofill',
|
||||||
|
aliases: ['google-autocomplete', 'autofill', 'autocomplete'],
|
||||||
|
group: 'other',
|
||||||
|
memberName: 'google-autofill',
|
||||||
|
description: 'Gets a list of Google Autofill results for a particular query.',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What would you like to search for?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const { text } = await snekfetch
|
||||||
|
.get('https://suggestqueries.google.com/complete/search')
|
||||||
|
.query({
|
||||||
|
client: 'firefox',
|
||||||
|
q: query
|
||||||
|
});
|
||||||
|
const data = JSON.parse(text)[1];
|
||||||
|
if (!data.length) return msg.say('Could not find any results.');
|
||||||
|
return msg.say(data.join('\n'));
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "46.0.0",
|
"version": "46.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user