fixing random patch
This commit is contained in:
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "pwa-node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/index.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,22 +5,17 @@ module.exports = {
|
||||
name: 'random',
|
||||
description: 'Random',
|
||||
execute(message, args) {
|
||||
let category = "";
|
||||
let catName = "All";
|
||||
var category = "";
|
||||
var catName = "All";
|
||||
if (args.length == 1) {
|
||||
category = args[0];
|
||||
catName = category;
|
||||
}
|
||||
|
||||
message.reply(
|
||||
`Random article - loading...
|
||||
Category: ${catName}
|
||||
`
|
||||
);
|
||||
var feedArray = libFlayer.getFeeds(category);
|
||||
var i = Math.floor(Math.random() * (feedArray.length - 0) + 0 );
|
||||
|
||||
message.reply(`Retrieving: [Link](${feedArray[i].link})`);
|
||||
message.reply(`Retrieving: [${catName}](${feedArray[i].link})`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
2
index.js
2
index.js
@@ -64,7 +64,7 @@ client.on('message', message => {
|
||||
client.commands.get(command).execute(message, args);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('there was an error trying to execute that command!');
|
||||
//message.reply('there was an error trying to execute that command!');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ exports.loadFeeds = function() {
|
||||
var linkData = {
|
||||
title: `${unescape(item.title)}`,
|
||||
link: `${unescape(item.link)}`,
|
||||
category: `${unescape(item.category)}`
|
||||
category: `${unescape(feedBlock.category)}`
|
||||
}
|
||||
linkFlayerMap.push(linkData);
|
||||
});
|
||||
@@ -60,10 +60,11 @@ exports.writeFeed = function (feeds) {
|
||||
|
||||
};
|
||||
exports.getFeeds = function (feedType) {
|
||||
var linkFlayerFilteredMap = [];
|
||||
if (feedType == null || feedType == undefined || feedType == "") {
|
||||
return linkFlayerMap;
|
||||
} else {
|
||||
var linkFlayerFilteredMap = [];
|
||||
|
||||
linkFlayerMap.forEach(linkFlay => {
|
||||
if (linkFlay.category.toLowerCase().indexOf(feedType.toLowerCase()) > -1) {
|
||||
linkFlayerFilteredMap.push(linkFlay);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"start": "node index.js",
|
||||
"push": "git push heroku main",
|
||||
"restart": "heroku dyno:restart",
|
||||
"stop": "heroku dyno:stop",
|
||||
"tail": "heroku logs --tail",
|
||||
"local": "heroku local web"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user