Introducing DiscordSteem! | A Cool New Discord Bot

in #utopian-io6 years ago

Discord

Image Source

Hello everyone! This is my first contribution after changing my account from @rodus to @rodux due to some difficulties. I've been working on this for some time. I started this bot while creating tutorials. In tutorials, I created commands but I wanted to improve it and here I am after improving it. If you don't know about this then here's a brief introduction for you.

<h3>Github Repository <p dir="auto"><span><a href="https://github.com/Rodux7/DiscordSteem" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/Rodux7/DiscordSteem <h3>Introduction <p dir="auto">DiscordSteem is a bot built in Python language, using two main libraries. The first one is "Beem" and the second one is "Discord.py". This bot has many cool commands that you can use to get quick access to posts, comments, or even specifically contributions. <h3>Commands <p dir="auto">Here are commands that bot has at the moment. I will be adding more commands in the future but these are the ones that are present at the moment. <ul> <li>Blog Command <li>Feed Command <li>Comments Command <li>Contributions Command <li>Info Command <li>Ticker Command <li>Notes Commands <h4>Blog Command <p dir="auto">The first command is Blog Command. You will be able to get blog posts of any user using this command. Usage of this command is <code>!blog <user> <amount>. There is one required parameter and the other one is optional. The required parameter is the "user", and this will be the username of any Steemit user whose blog you want. The second parameter which is optional is "amount" which is going to be the amount of posts you want. By default, this amount is set to 3. Here's how it looks like when it is working!<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmaDWo1zDqjQicUghG9AHRKDZUiaaw25mXwJ7HRnnAVGJN" alt="Screenshot from 2018-09-12 19-59-11.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmaDWo1zDqjQicUghG9AHRKDZUiaaw25mXwJ7HRnnAVGJN 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmaDWo1zDqjQicUghG9AHRKDZUiaaw25mXwJ7HRnnAVGJN 2x" /><br /> Clicking on "Check out this post!" will take you to the original post on Steemit. You can also assign the amount of post like down in the below image.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmTsyPw6XmxP8JYjLwaaaiq52iCAA5tWvuwP2keFAMAJAv" alt="Screenshot from 2018-09-12 20-04-18.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmTsyPw6XmxP8JYjLwaaaiq52iCAA5tWvuwP2keFAMAJAv 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmTsyPw6XmxP8JYjLwaaaiq52iCAA5tWvuwP2keFAMAJAv 2x" /> <h4>Feed Command <p dir="auto">You will be able to get feed of any user using this command. Usage of this command is very similar to the last command. You can use this command by typing <code>!feed <user> <amount>. Again, there are two parameters that you can assign and out of those two parameters, one is required while other is not. Amount is set to 3 by default like last one. Here's how it looks when it is working.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmdyqJXdLSyH1K3u5xgMx4Cdip67MmH9J1vwngzxfnTyUX" alt="Screenshot from 2018-09-12 20-11-10.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmdyqJXdLSyH1K3u5xgMx4Cdip67MmH9J1vwngzxfnTyUX 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmdyqJXdLSyH1K3u5xgMx4Cdip67MmH9J1vwngzxfnTyUX 2x" /><br /> Here's how it looks when we assign the custom amount.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmPSFFjcoaet2mRPF7kFbvX1mfiYUHr2vGTPNPt61FFhAM" alt="Screenshot from 2018-09-12 20-13-37.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmPSFFjcoaet2mRPF7kFbvX1mfiYUHr2vGTPNPt61FFhAM 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmPSFFjcoaet2mRPF7kFbvX1mfiYUHr2vGTPNPt61FFhAM 2x" /> <h3>Comments Command <p dir="auto">Using this command you will be able to get last comments of any user. Usage of this command is also very similar to last ones. Usage of this command is <code>!comments <user> <amount>. User will be any Steem user and it is required. The amount is optional and is set to 3 by default. Here's how it works!<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmZzCgWkKuc52bgK6NrHD5R6MrYpokqCTfqC5iYcFHgLsB" alt="Screenshot from 2018-09-12 20-27-05.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmZzCgWkKuc52bgK6NrHD5R6MrYpokqCTfqC5iYcFHgLsB 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmZzCgWkKuc52bgK6NrHD5R6MrYpokqCTfqC5iYcFHgLsB 2x" /><br /> Since comments don't actually have it's own title and I can't show full comment due to character limit, I used the title of the post in which comment was made. Here's how it works when we assign the amount.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmRF8a7sxUDeAkXP2kFRGw8cAsrMzC5Vaw5sNXXwxjBCyR" alt="Screenshot from 2018-09-12 20-29-04.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmRF8a7sxUDeAkXP2kFRGw8cAsrMzC5Vaw5sNXXwxjBCyR 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmRF8a7sxUDeAkXP2kFRGw8cAsrMzC5Vaw5sNXXwxjBCyR 2x" /> <h4>Contributions Command <p dir="auto">Using this command, user will be able to check anyone's contributions that they have submitted through Utopian. This command will also be used like other commands <code>!contributions <user> <amount>. User will be any Steem username and amount will be any number. By default, is is 3.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/Qma4Fs1EJxun1noy4j3waSqSXq7Lmf9aKpvDhNqjTB7JjF" alt="Screenshot from 2018-09-12 20-34-22.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/Qma4Fs1EJxun1noy4j3waSqSXq7Lmf9aKpvDhNqjTB7JjF 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/Qma4Fs1EJxun1noy4j3waSqSXq7Lmf9aKpvDhNqjTB7JjF 2x" /><br /> <em><span>Shoutout to <a href="/@scipio">@scipio for making awesome tutorials! <h4>Info Command <p dir="auto">This command will give general information about any account like how many followers it has, how many people is account following, how many witnesses is account voting for and more. You can use this command by typing <code>!info <user>. User will be any Steem username and this is required. Here's how it works.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmXGB5zhr3gbLGjj2X18wS38UAkX4hDJuXEaWsfX7EwKxq" alt="Screenshot from 2018-09-12 20-39-12.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmXGB5zhr3gbLGjj2X18wS38UAkX4hDJuXEaWsfX7EwKxq 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmXGB5zhr3gbLGjj2X18wS38UAkX4hDJuXEaWsfX7EwKxq 2x" /> <h4>Ticker Command <p dir="auto">This command can be used to get price of different coins in different currencies. You can use this command by typing <code>!ticker <coin> <currency>. Coin is necessary, while currency is set to USD by default. These currencies are supported at the moment. <blockquote> <p dir="auto">"AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR" <p dir="auto">Here's how command looks when it working and correct parameters are assigned. As you can see in the below image, there should be full name of the coin. Short forms won't work.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmcUvcj46oB3PXLBTFTwiEq3bchzMYx4wkQdrfpkLCexbX" alt="Screenshot from 2018-09-12 20-48-36.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmcUvcj46oB3PXLBTFTwiEq3bchzMYx4wkQdrfpkLCexbX 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmcUvcj46oB3PXLBTFTwiEq3bchzMYx4wkQdrfpkLCexbX 2x" /><br /> You can assign different currencies and coins like done in the image below.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmXJJp4LqRKMBcyb9DvkSf4HpJmRckrTsEJaNzDohja1rQ" alt="Screenshot from 2018-09-12 20-51-09.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmXJJp4LqRKMBcyb9DvkSf4HpJmRckrTsEJaNzDohja1rQ 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmXJJp4LqRKMBcyb9DvkSf4HpJmRckrTsEJaNzDohja1rQ 2x" /> <h4>Notes Commands <p dir="auto">Notes commands are actually three commands that you can use to add, recall or delete notes. I have used PyMongo to store the notes in case the script stops. The three commands are <code>!addnote "<note>", <code>!note and <code>!delnote. When you add note, make sure that it is in quotation marks.<code>!note will recall notes and <code>!delnote will delete all the notes.<br /> <center><img src="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmWtKq3EbyETKQh3UZGJHwStDrdTnJQE2TkVouSJbQQNuK" alt="Screenshot from 2018-09-12 21-56-32.png" srcset="https://images.hive.blog/768x0/https://ipfs.busy.org/ipfs/QmWtKq3EbyETKQh3UZGJHwStDrdTnJQE2TkVouSJbQQNuK 1x, https://images.hive.blog/1536x0/https://ipfs.busy.org/ipfs/QmWtKq3EbyETKQh3UZGJHwStDrdTnJQE2TkVouSJbQQNuK 2x" /> <h3>How To Set It Up To Be Used In Server <p dir="auto">First of all open the terminal and type <code>git clone https://github.com/Rodux7/DiscordSteem. This will clone the github repository, make sure you have the "git" installed. <p dir="auto">After cloning the repository, run this command in the terminal <code>sudo apt-get install build-essential libssl-dev python-dev. This is necessary for the installation of Beem which is required for the bot to function properly. Now proceed to the directory by typing <code>cd DiscordSteem. Inside it type <code>pip install -r requirements.txt. This will install other necessary things. <p dir="auto">Now go to <a href="https://discordapp.com/developers" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Discord Developer Page and login. Create a new application and get the token. You can learn in depth from <a href="https://steemit.com/utopian-io/@rodus/bots-in-python-2-or-creating-discord-bot-that-uses-beem-to-get-information-or-discordsteem-or-part-1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here. Replace the token in the DiscordSteem file. Add the bot to the discord server which is also present in <a href="https://steemit.com/utopian-io/@rodus/bots-in-python-2-or-creating-discord-bot-that-uses-beem-to-get-information-or-discordsteem-or-part-1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">this link. You can now run the bot by typing <code>python DiscordSteem.py and this will make the bot online and commands will be working! <h3>Tutorials <p dir="auto">If anyone of you are curious into looking how basic commands of this bot were made, you should look into the tutorials that are present below. <ul> <li><a href="https://steemit.com/utopian-io/@rodus/bots-in-python-2-or-creating-ticker-and-notes-commands-or-discordsteem-or-part-3-1535188272667" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">DiscordSteem (Part 3) <li><a href="https://steemit.com/utopian-io/@rodus/bots-in-python-2-or-removing-improving-and-adding-commands-or-discordsteem-or-part-2" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">DiscordSteem (Part 2) <li><a href="https://steemit.com/utopian-io/@rodus/bots-in-python-2-or-creating-discord-bot-that-uses-beem-to-get-information-or-discordsteem-or-part-1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">DiscordSteem (Part 1) <h3>Have Fun!
Sort:  

Very cool to see you make this bot! I like it :D I got some feedback for you anyways.
I would probably make the info command show a lot more information. For one part I do think that you should display at least one more digit to the reputation as especially when you are in the higher range, your reputation doesn't change for a long time, and it would be disappointing to only see the full number ;)
Also, I would highly recommend you to show the SBD and STEEM in the savings as well for the info command. You could make this for example by making it like that (as a return to ?info steemit in the STEEM Balance field): 2,000,000.580 (2,806,644.632) STEEM

Now a little coding advice for you, that you could make use of in the future. Consider using the logging module (documentation) instead of printing the different things to the console. That makes it way more flexible and you'll just have a more convenient experince with logging stuff in the execution of your program.
Also, as far as I know, it's recommended to use other string formatting methods as they are easier to read and maybe have some other advantages as well. Instead of "These are last %s comments of %s" % (amount, username) you could just make it look that way: f"These are last {amount} comments of {username}"
On a final note: why did you change your name? "Some difficulties" isn't that much information ;)
Thank you for reading that wall of text,
Schwein
PS: I'm not a professional developer, and if any of the information I provided is wrong, please forgive me. :) I think the vested balance is also a very important piece of information on the steem blockchain that should be included in an info command. e.g. @utopian-io doesn't really look that "good" if you only see it's balance, but not it's SP :P. I think this is way more readable and highly improves your code look. @scipio made a tutorial on that way of formatting strings, and there is plenty of documentation for it as well if you want to look into it more. :)

Thanks for writing this feedback. I just added another commit, bot now uses F-Strings. I have also added that you can now see SP using the !info command as well. I haven't used logging yet because I don't have that much experience in it but I will consider it in future. Thanks again : )


Hey @flugschwein Here's a tip for your valuable feedback! @Utopian-io loves and incentivises informative comments.

Contributing on Utopian
Learn how to contribute on our website.

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

Vote for Utopian Witness!


If you follow me, I will also follow you in return!
@rodux, I gave you a vote!Enjoy some !popcorn courtesy of @nextgencrypto!

Congratulations @rodux! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@rodux" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 2x" /> Award for the number of upvotes received <p dir="auto"><sub><em>Click on the badge to view your Board of Honor.<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto">To support your work, I also upvoted your post! <p dir="auto"><strong><span>Do not miss the last post from <a href="/@steemitboard">@steemitboard: <table><tr><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-witness-update-2018-09-07" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/7CiQEO.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/64x128/http://i.cubeupload.com/7CiQEO.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/64x128/http://i.cubeupload.com/7CiQEO.png 2x" /><td><a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-witness-update-2018-09-07" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard - Witness Update <blockquote> <p dir="auto">Support <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project! <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!

Wow, this looks like a really cool bot. I would love to use that for the 1UP platform that I am building and include our communties there. They are usually based on tags which should be simple to pull the data from. Why don't why talk about this on Discord? Come over to our 1UP channel if you have time. You might earn some UP bounties . :)

Economy.@rodux, First of all it's unfortunate to hear that you faced difficulties in your previous account because, we put so much effort to develop our profile in an competitive

Congratulations and want to appreciate your work regrading the DiscordSteem and it sounds really effective Bot so i wish that this Bot will bring the Productive results.

And the list of Commands which we are reading in this post, is reflecting as really important aspects when we talk about the Discord and good to hear that you are working on more.

And the Tutorial of commands is really appreciable because in that way people can understand in what respect these Commands will work.

Wishing you an great day and stay blessed. 🙂

Congratulations @rodux! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@rodux" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstcomment.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstcomment.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstcomment.png 2x" /> You made your First Comment<br /> <a href="http://steemitboard.com/@rodux" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 2x" /> Award for the number of upvotes received <p dir="auto"><sub><em>Click on the badge to view your Board of Honor.<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">Support <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project! <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!

Congratulations @rodux! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@rodux" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png 2x" /> You got your First payout<br /> <a href="http://steemitboard.com/@rodux" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/payout.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/payout.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/payout.png 2x" /> Award for the total payout received <p dir="auto"><sub><em>Click on the badge to view your Board of Honor.<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">Support <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project! <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!