LuniBot for Discord
Displays market info for the LUNI/LUNA token on the Terra Blockchain (Webscrape method currently scraping CoinMarketCap). Will evolve over time :)
Install
--Install Dependencies
pip3 install bs4 discord dotenv flask requests
--Add a .env file to the repository and add the following line within it:
token = REPLACEWITHTOKEN <---- Discord Bot token, obtained HERE DO NOT SHARE THIS TOKEN WITH ANYONE
Set up your bot in the given link above and click "Bot" on the left menu to see the "Token" section underneath the Username input.
That is where you will copy and replace the code above with your Bot Token.
This is a private key to your Bot, so make sure not to leave it anywhere someone you dont trust can get it. They could potentially mess with your server.
Add Discord Bot to your server
Click "OAuth2" on the left menu on the Discord Developer Portal
Go to the second section, "URL Generator"
Assign the permissions you wish the bot to have, make sure to know what youre giving it access to, as too much control can be screwy.
Copy the given link on the bottom of the page, should look something like "https://discord.com/api/oauth2/authorize?client_id=??????????".
Go to that link in a new tab and assign the server you want it to have access to (you will have to confirm some permissions first), and your bot will then be connected.
It will show offline until you finalize and run the program.
Finished
And just like that you should be good. As long as you have the necessary dependencies to run the commands, you should see a smooth startup upon running the main.py file in VSCode (or preferred program)
Now go ahead and type "$luni" into the channel the bot is in (and online) and see it print out the top info for LUNI
I also added print function that will print the price in the console upon request from discord.
Tips
**This bot will have access to all your channels, so if you wish to limit this command to one channel, I recommend setting permissions for the Bot's role (should automatically be set as whatever you named the bot in the Discord Developer Portal) to not be able to view whatever channels you don't want it replying in.
**If you ever do have your token compromised (ie, you fork to github with your token readily available to anybody who checks your code) there is usually no cause for concern as Discord will automatically let you know and your token will be invalid. This does mean, however, that you must recopy and reenter your token into your local code in order for the bot to continue working (upon rerunning main.py, of course)
**Lastly, I do recommend applying "slow-mode" or limiting the frequency of using the commands, as the more info it pulls, the longer it will take. I am currently looking towards solutions in making the pull far more efficient so as to ease the amount of effort it takes for the program to access the data.
**This Bot is super simple, so feel free to mess with it and add to it/change it. This serves as a template, as not many solid ones are out there for this sort of thing. Hopefully this helps with that!
PS : Added the logo for the LuniBot avatar :)
Let me know any issues or suggestions! I'm not an expert by any means, so I don't expect this to work flawlessly :P