diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ab42783 --- /dev/null +++ b/.vscode/launch.json @@ -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": [ + "/**" + ], + "program": "${workspaceFolder}/index.js" + } + ] +} \ No newline at end of file diff --git a/commands/random.js b/commands/random.js index fd99b20..d4fb80f 100644 --- a/commands/random.js +++ b/commands/random.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})`); } }; diff --git a/index.js b/index.js index e0c0fa2..0d9bd21 100644 --- a/index.js +++ b/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!'); } }); diff --git a/libFlayer.js b/libFlayer.js index 97c18e8..d2399d9 100644 --- a/libFlayer.js +++ b/libFlayer.js @@ -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); diff --git a/package.json b/package.json index f64da34..f8ddc59 100644 --- a/package.json +++ b/package.json @@ -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" },