Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import requests
import json
from discord.ext import commands
# I have to convert the file to discord one!
"""I took the idea from https://youtu.be/uBfZal3Ve84 but I had to add and change some parts from the code ."""
class CoinMarket:
def __init__(self, client):
client.self = client
# base URLs
@commands.command(alisases = ['coin', 'coinmarket', 'coinM'])
async def coin(self,ctx):
globalURL = "https://api.coinmarketcap.com/v1/global/"
tickerURL = "https://api.coinmarketcap.com/v1/ticker/"
# get data from globalURL
request = requests.get(globalURL)
data = request.json()
globalMarketCap = data['total_market_cap_usd']
# menu
print()
print("Welcome to the conin market cap ")
print("globall ....." + str(globalMarketCap))
print("Enter 'all' or 'name of crypto'")
print()
choice = input("Your choice: ")
if choice == "all":
request = requests.get(tickerURL)
data = request.json()
for x in data:
ticker = x['symbol']
price = x['price_usd']
print(ticker + ":\t\t$" + price)
print()
else:
tickerURL += '/' + choice + '/'
request = requests.get(tickerURL)
data = request.json()
ticker = data[0]['symbol']
price = data[0]['price_usd']
print(ticker + ":\t\t$" + price)
print()
choice2 = input("Again (y/n): ")
if choice2 == "y":
pass
if choice2 == "n":
pass
def setup(client):
client.add_cog(CoinMarket(client))
print("API is loaded")