Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of simple discord chatbot based on library
# Example of simple discord chatbot based on library
# For article (Russian language):
import discord
import asyncio
import requests
BTC_PRICE_URL_coinmarketcap = ''
client = discord.Client()
async def on_ready():
print('Logged in as')
async def on_message(message):
if message.content.startswith('!btcprice'):
print('[command]: btcprice ')
btc_price_usd, btc_price_rub = get_btc_price()
await client.send_message(, 'USD: ' + str(btc_price_usd) + ' | RUB: ' + str(btc_price_rub))
def get_btc_price():
r = requests.get(BTC_PRICE_URL_coinmarketcap)
response_json = r.json()
usd_price = response_json[0]['price_usd']
rub_rpice = response_json[0]['price_rub']
return usd_price, rub_rpice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.