mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 05:51:35 +02:00
Add titles to google results
This commit is contained in:
@@ -42,10 +42,10 @@ module.exports = class GoogleCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
hrefs = await this.search(query, msg.channel.nsfw || false);
|
hrefs = await this.search(query, msg.channel.nsfw || false);
|
||||||
} catch {
|
} catch {
|
||||||
hrefs = [`http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`];
|
hrefs = [{ href: `http://lmgtfy.com/?iie=1&q=${encodeURIComponent(query)}`, title: 'LMGTFY' }];
|
||||||
}
|
}
|
||||||
if (!hrefs) return msg.say('Could not find any results.');
|
if (!hrefs) return msg.say('Could not find any results.');
|
||||||
return msg.say(hrefs.map(href => `<${href}>`).join('\n\n'));
|
return msg.say(hrefs.map(href => `${href.title}\n<${href.href}>`).join('\n\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(query, nsfw) {
|
async search(query, nsfw) {
|
||||||
@@ -67,7 +67,7 @@ module.exports = class GoogleCommand extends Command {
|
|||||||
const params = new URLSearchParams(href);
|
const params = new URLSearchParams(href);
|
||||||
const url = new URL(params.get('url'));
|
const url = new URL(params.get('url'));
|
||||||
if (nsfw || !this.client.adultSiteList.includes(url.host)) {
|
if (nsfw || !this.client.adultSiteList.includes(url.host)) {
|
||||||
links.push(url.href);
|
links.push({ href: url.href, title: $(h3).text() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user