Get New, Hot, Trending Links from Steemit
SteemDC is been created by @wehmoen, you can read about it here. I thought of adding features in this bot where you can get new, hot and trending links from Steemit.
The features SteemDC had were !steem, and I have added !hot, !created and !trending. It shows the Pending Payout, Total Votes, Posted Time and the Steemit Link.
To do this I am using Functions in Utils as
utils.getDiscussionByCreated(tag, limit)
- Get limit number of created posts of the tag
utils.getDiscussionByHot(tag, limit)
- Get limit number of hot posts of the tag
utils.getDiscussionByTrending(tag, limit)
- Get limit number of trending posts of the tag
where the underlying function are send as a promise
getDiscussionByCreated: function(tag, limit) {
return new Promise(function (yes, no) {
steem.api.getDiscussionsByCreated({tag: tag, limit: limit}, function (err, result) {
if(err) no(err);
yes(result);
});
})
},
getDiscussionsByHot: function(tag, limit) {
return new Promise(function (yes, no) {
steem.api.getDiscussionsByHot({tag: tag, limit: limit}, function (err, result) {
if(err) no(err);
yes(result);
});
})
},
getDiscussionsByTrending: function(tag, limit) {
return new Promise(function (yes, no) {
steem.api.getDiscussionsByTrending({tag: tag, limit: limit}, function (err, result) {
if(err) no(err);
yes(result);
});
})
}
And for Posting to Discord I am first creating the PrintLink as shown below
printLink: function(result) {
let value = "Pending Payout : " + result.pending_payout_value;
value += "\nTotal Votes : " + result.net_votes;
value += "\nPosted Time : " + time_ago(new Date(result.created) - (1000 * 60));
value += "\nhttps://steemit.com" + result.url;
return value;
}
and post the printLink directly to Discord. However the functionality is greatly improved by @wehmoen and he uses embed function now which display it very nicely on Discord.
GitHub Repo : https://github.com/wehmoen/steemdc Pull Request : https://github.com/wehmoen/steemdc/pull/1
Posted on Utopian.io - Rewarding Open Source Contributors