Steem Apps Discord Bot - Utopian-io Submission

in #utopian-io5 years ago (edited)

Steemapps Repository
My Dev Repository

This is a submission for a Steem Apps Discord bot, that returns rankings according to several different sort parameters. This is the initial submission, for the setup without all the refinements I've added for @therealwolf while working on this. I wrote this Discord bot in Typescript with Node, using as little as I could package-wise. This only uses request-promise-native, for API request support, and discord.js, as well as the typings for them. The task request is here, a bit late I know, been super busy with work and other things, didn't get around to writing this post.

This merged PR and the commits that precede it are the substance of this submission post.

Discord Bot Features


I've gone through several different iterations, but the main function of this Discord bot is to function within servers to return the ranking of Steem Apps, based on several different sorts. The currently accepted sort parameters include:

  • Time: Daily, Weekly, Monthly
  • Daily Active Users
  • Transactions
  • Volume (SBD or STEEM)
  • Rewards (SBD or STEEM)
  • Rank (according to Steem Apps)

Each of these can be the sort, using the time to determine the range that they are sorted within. Ascending or descending sort available.

The technology behind it is pretty easy; it simply uses discord.js to log into servers, getting messages starting with '$' or '!', and responding after making a request to the Steem Apps API Server, using request-promise-native. It's set up on npm for ease of use, simply run npm start (after dropping a bot token into the empty config file), and you're ready to go!

Future Plans

Are already mostly implemented, updated to try embeds, then webhooks, then embeds again. I'm waiting on therealwolf to accept the PR, then I will send in another submission with the additional work I've done on the bot.

Github

Vote For Me as Your Witness

Cheers, thanks for reading! If you like my tools and content and would like to see more, Vote for me as witness or proxy your votes and I'll pick the best witnesses for you!

My Projects

Pywit- A witness tool-kit built in Python on top of Holger80's Beempy.

Sort:  

Thank you for your contribution @petertag !

  1. The PR has been outside the 14-day window - but you 've made some great work here, so I'd give a few comments.
  2. a few screenshots on discord could be useful for readers to understand how the bot actually works
  3. type == 4, type > 1 - magic numbers, could be replaced with meaningful names.
  4. I'd expect to see some tests here using e.g. mocha or chai, and you could also set up a CI on https://travis-ci.com
  5. could msg.content be null? should there be a null check? Also, you may use a regexp here e.g. `/^[!$].*/ to make your code look nicer.
  6. For background discord bots, you may want to log to files instead of console.log
  7. if (args && Array.isArray(args)) { is the Array.isArray(args) sufficient enough?
  8. color: 12607945 etc could be customized by moving it to a external json config.
  9. Are you sure that inqs[qs.length - 2] , qs is at least 2 elements?

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thanks for the quick response justyy! I figured there would be something like that, just wanted to get this post up before the final-ish PR was accepted. I'll include some more screenshots for usage on the next one, as I don't think the bot is active yet and this PR didn't contain most of the currently working parameters.

  1. I'll add in const declarations in the config, I'll probably keep it in the same file as the bot token, will throw the color in there as well.

  2. Honestly wasn't sure if/how to test a Discord bot, used travis-ci before though, I'll check out mocha or chai

  3. Will add a null check in, missed that, assumed the msg wouldn't show up without content when first setting it up, but realize now that embeds can work without.

  4. True, most of the logs were error checking, the login one I thought was important but you can see the bot is online in Discord anyways.

  5. I believe it is, went over a few stackoverflow answers to ensure errors weren't thrown but it also fully checks.

  6. It is, due to the parseArgs pushing in default arguments for sort type, time, and sort order if they are not passed in, but I should probably make that more clear somewhere.

Cheers!

Thank you for your review, @justyy! Keep up the good work!

Hi @petertag!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @petertag!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.032
BTC 63510.21
ETH 3068.27
USDT 1.00
SBD 3.81