How to build a Discord Bot to track Crypto Prices 24/7 and set Price Alerts (part 1) --- with Python
Автор: Andrew Fung
Загружено: 2021-07-06
Просмотров: 42429
Описание:
Hello Everyone! My name is Andrew Fung, in this video, I will be showing you how you create a Crypto Bot in your discord server to track Crypto Prices and send user notifications in the form of messages to your devices. The crypto bot will be running 24/7 all the time as hosted by UpTimeRobot and will be constantly pinged every 5 minutes to keep the bot alive.
#discordbot #pricealert #cryptocurrency #python #replit
#cryptobot
Elevator Music:
Local Forecast - Elevator by Kevin MacLeod https://incompetech.com/
Promoted by MrSnooze • Elevator Music I Muzak & Lift Music I No C...
Creative Commons — CC BY 3.0 I https://goo.gl/Yibru5
Installation and Setup!
Coingecko API endpoint: https://api.coingecko.com/api/v3/coin...
Discord Python Documentation: https://discordpy.readthedocs.io/en/s...
UpTimeRobot service: https://uptimerobot.com
Discord Developer Portal: / discord
Source code for this project:
https://github.com/Andrew-FungKinHo/Y...
Check out my Github!
https://github.com/Andrew-FungKinHo
How I make my YouTube videos:
⌨️ Keyboard - Nuphy Air75 Mechanical Keyboard - https://amzn.to/3Xu4PD3
🎙 Microphone - MAONO A04 Professional Podcaster USB Microphone - https://amzn.to/3k8ocD5
🖱 Mouse - Microsoft Bluetooth Ergonomic Mouse - https://amzn.to/3CHhdHJ
🔌 Accessories - Laptop Docking Station for MacBook Pro - https://amzn.to/3CHi5Mv
Timestamps
0:00 | Intro
0:47 | Discord Crypto Bot Demo
05:51 | Create a Discord Server and Bot
09:45 | Instantiate a Discord Client to run bot
14:40 | GetCryptoPrice and IsCryptoSupport functions
22:09 | Out tro
Full Code:
———————————————————————————————
import discord
import requests
from replit import db
getting crypto data
def getCryptoPrices(crypto):
URL = "https://api.coingecko.com/api/v3/coin..."
r = requests.get(url=URL)
data = r.json()
putting the cryptocurrencies and their prices in db
for i in range(len(data)):
db[data[i]['id']] = data[i]['current_price']
if crypto in db.keys():
return db[crypto]
else:
return None
check if a cryptocurrency is supported in this bot
def isCryptoSupported(crypto):
if crypto in db.keys():
return True
else:
return False
instantiate a discord client
client = discord.Client()
@client.event
async def on_ready():
print(f'You have logged in as {client}')
channel = discord.utils.get(client.get_all_channels(),name='general')
await client.get_channel(channel.id).send('bot is now online!')
called whether there is a message in the chat
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('ya'):
await message.channel.send('yeet')
BOT_TOKEN = 'YOUR_TOKEN_HERE'
client.run(BOT_TOKEN)
———————————————————————————————
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: