updating to discord v13
This commit is contained in:
@@ -1,64 +1,20 @@
|
||||
var libFlayer = require("../libFlayer.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'search',
|
||||
description: 'Search RSS Sources',
|
||||
execute(message, args) {
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
message.reply(`Missing arguments`);
|
||||
return;
|
||||
}
|
||||
|
||||
var search = args.join(" ");
|
||||
var found = false;
|
||||
|
||||
let i = 0;
|
||||
let iSave = 0
|
||||
let count = 0;
|
||||
var feedArray = libFlayer.getFeeds();
|
||||
var searchString = "";
|
||||
var foundError = false;
|
||||
feedArray.forEach(linkFlay => {
|
||||
try {
|
||||
if (linkFlay.title.toLowerCase().indexOf(search.toLowerCase()) > -1) {
|
||||
iSave = i;
|
||||
found = true;
|
||||
console.log(linkFlay.title);
|
||||
searchString += `Use !get ${i} to view: ${linkFlay.title} \n`;
|
||||
count++;
|
||||
if (count > 5) {
|
||||
message.reply(searchString);
|
||||
searchString = "";
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} catch (error) {
|
||||
foundError = true;
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (foundError) {
|
||||
message.reply("Error in search");
|
||||
return;
|
||||
} else {
|
||||
message.reply(searchString);
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
//message.channel.send('Displaying 1 result');
|
||||
//message.channel.send('!get '+iSave);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
message.reply(`No results found for: ${search}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
message.reply(error.toString());
|
||||
}
|
||||
name: 'search',
|
||||
description: 'Search',
|
||||
async execute(message, args) {
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
message.reply(`Please use in !search [question] format`);
|
||||
return;
|
||||
}
|
||||
var question = encodeURIComponent(args.join(" "));
|
||||
|
||||
var answerData = await libFlayer.search(question);
|
||||
message.reply(`**Question**: ${decodeURIComponent(question)}\n\n**Answer**: ${answerData.text}\n\n **Source**: ${answerData.source}`);
|
||||
} catch (err) {
|
||||
message.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user