Compare commits
No commits in common. "97cb96d93c6628b31b95d81230d3f10db11dd1ec" and "d2bbf5c0405abd6f2daff79df1e8bdd2cd50d783" have entirely different histories.
97cb96d93c
...
d2bbf5c040
1 changed files with 1 additions and 40 deletions
|
@ -1,7 +1,6 @@
|
|||
const Command = require("../lib/command.js");
|
||||
const CATEGORY = "misc";
|
||||
|
||||
const {librex} = require("../../config.json");
|
||||
const {
|
||||
hastebin,
|
||||
safeString,
|
||||
|
@ -180,9 +179,7 @@ gimg.callback = async function (msg, line) {
|
|||
url: image.url,
|
||||
},
|
||||
footer: {
|
||||
text: `Image ${Number(index) + 1}/${
|
||||
images.length
|
||||
}. Rerun to get a different image.`,
|
||||
text: `Image ${index}/${images.length}. Rerun to get a different image.`,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -545,39 +542,3 @@ generate.callback = async function (msg, line) {
|
|||
return out;
|
||||
};
|
||||
hf.registerCommand(generate);
|
||||
|
||||
const search = new Command("search");
|
||||
search.category = CATEGORY;
|
||||
search.helpText = "Search, powered by LibreX";
|
||||
search.addAlias("g");
|
||||
search.addAlias("google");
|
||||
search.addAlias("ddg");
|
||||
search.callback = async function (msg, line) {
|
||||
if (!librex) return "LibreX instance not defined.";
|
||||
|
||||
const query = encodeURIComponent(line);
|
||||
|
||||
if (line.startsWith("!")) {
|
||||
const url = `https://api.duckduckgo.com/?q=${query}&format=json`;
|
||||
const res = await fetch(url);
|
||||
if (res.url != url) return res.url;
|
||||
}
|
||||
|
||||
const res = await fetch(librex + "/api.php?q=${query}&p=0&t=0");
|
||||
const results = await res.json().splice(0, 5);
|
||||
|
||||
let out = `__Results for \`${safeString(line)}\`__\n`;
|
||||
for (const result of results) {
|
||||
if (result.special_response) {
|
||||
out += "> " + result.special_response.response.split("\n").join("\n> ");
|
||||
out += `\n<${result.special_response.source}>`;
|
||||
} else {
|
||||
out += `**${result.title}** - <${result.url}>`;
|
||||
out += `\n> ${result.description}`;
|
||||
}
|
||||
out += "\n\n";
|
||||
}
|
||||
|
||||
return out.trim();
|
||||
};
|
||||
hf.registerCommand(search);
|
||||
|
|
Loading…
Reference in a new issue