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',
|
name: 'random',
|
||||||
description: 'Random',
|
description: 'Random',
|
||||||
execute(message, args) {
|
execute(message, args) {
|
||||||
let category = "";
|
var category = "";
|
||||||
let catName = "All";
|
var catName = "All";
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
category = args[0];
|
category = args[0];
|
||||||
catName = category;
|
catName = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.reply(
|
|
||||||
`Random article - loading...
|
|
||||||
Category: ${catName}
|
|
||||||
`
|
|
||||||
);
|
|
||||||
var feedArray = libFlayer.getFeeds(category);
|
var feedArray = libFlayer.getFeeds(category);
|
||||||
var i = Math.floor(Math.random() * (feedArray.length - 0) + 0 );
|
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);
|
client.commands.get(command).execute(message, args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(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 = {
|
var linkData = {
|
||||||
title: `${unescape(item.title)}`,
|
title: `${unescape(item.title)}`,
|
||||||
link: `${unescape(item.link)}`,
|
link: `${unescape(item.link)}`,
|
||||||
category: `${unescape(item.category)}`
|
category: `${unescape(feedBlock.category)}`
|
||||||
}
|
}
|
||||||
linkFlayerMap.push(linkData);
|
linkFlayerMap.push(linkData);
|
||||||
});
|
});
|
||||||
@@ -60,10 +60,11 @@ exports.writeFeed = function (feeds) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
exports.getFeeds = function (feedType) {
|
exports.getFeeds = function (feedType) {
|
||||||
|
var linkFlayerFilteredMap = [];
|
||||||
if (feedType == null || feedType == undefined || feedType == "") {
|
if (feedType == null || feedType == undefined || feedType == "") {
|
||||||
return linkFlayerMap;
|
return linkFlayerMap;
|
||||||
} else {
|
} else {
|
||||||
var linkFlayerFilteredMap = [];
|
|
||||||
linkFlayerMap.forEach(linkFlay => {
|
linkFlayerMap.forEach(linkFlay => {
|
||||||
if (linkFlay.category.toLowerCase().indexOf(feedType.toLowerCase()) > -1) {
|
if (linkFlay.category.toLowerCase().indexOf(feedType.toLowerCase()) > -1) {
|
||||||
linkFlayerFilteredMap.push(linkFlay);
|
linkFlayerFilteredMap.push(linkFlay);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"push": "git push heroku main",
|
"push": "git push heroku main",
|
||||||
"restart": "heroku dyno:restart",
|
"restart": "heroku dyno:restart",
|
||||||
|
"stop": "heroku dyno:stop",
|
||||||
"tail": "heroku logs --tail",
|
"tail": "heroku logs --tail",
|
||||||
"local": "heroku local web"
|
"local": "heroku local web"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user