LuniBot for Discord

Displays market info for LUNI/LUNA on the Terra Blockchain (Webscrape method currently scraping CoinMarketCap). Will evolve over time :)

Install Dependencies

pip3 install bs4 discord dotenv flask requests

Set up your Discord Bot and obtain Bot Token

Discord Developer Portal: https://discord.com/developers/applications/

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.

Keep this in mind, as you will need this later.

This is a private key to your Bot, so make sure to keep it safe/hidden, as anyone with it has control over your bot and potentially your server.

Add Discord Bot to your server

In the Discord Dev Portal, click "OAuth2" on the left

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 the bot is offline until you finalize and run the program.

Add Bot Token to Environment Variables

This can depend on how/where youre hosting your bot (for example Replit has a special way to store env variables). I use VSCode and run the program locally. To do this simply add a '.env' file to the repository. Within that paste the line below, replacing 'REPLACEWITHTOKEN' with your Discord Bot Token you copied from the Discord Dev Portal.

    token = REPLACEWITHTOKEN                   

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 witness the magic :)

Commands

$luna, $luni (volume, supply, mc)
  mc - shows the available Market Cap estimations (Market Cap and/or Fully Diluted Market Cap)
  supply - shows the available supply information (Total Supply, Max Supply, and/or Circulating Supply)
  volume - shows the traded volume in the last 24hrs

Running the '$luna'/'$luni' command alone will show you the price, percentage price change in the last 24hrs, and links to view/buy/trade the coin.

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

GitHub - v8ive/LuniBot at pythonawesome.com
Displays market info for LUNI/LUNA on the Terra Blockchain (Webscrape method currently scraping CoinMarketCap). Will evolve over time :) - GitHub - v8ive/LuniBot at pythonawesome.com