From d9fc188025d50953a55981e817d7ae88fb2acf0b Mon Sep 17 00:00:00 2001 From: 0xbasar <109233435+0xbasar@users.noreply.github.com> Date: Thu, 21 Jul 2022 16:11:28 +0300 Subject: [PATCH] Create Bot --- Bot | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Bot diff --git a/Bot b/Bot new file mode 100644 index 0000000..704c274 --- /dev/null +++ b/Bot @@ -0,0 +1,44 @@ +import discord +from discord.ext import commands +import requests +import json +import asyncio +from numerize import numerize +import config + +client = commands.Bot(command_prefix = '$') + +async def status_task(): + + while True: + + getir = requests.get("https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true&include_last_updated_at=true").text + getir = json.loads(getir) + getir_dex = requests.get("https://api.dexscreener.com/latest/dex/pairs/ethereum/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640,0x16b9a82891338f9ba80e2d6970fdda79d1eb0dae").text + getir_dex = json.loads(getir_dex) + + getir_usd = getir_dex["pairs"][0]["priceUsd"] + getir_mcap = getir["ethereum"]["usd_market_cap"] + getir_24 = getir["ethereum"]["usd_24h_change"] + getir_24_vol = getir["ethereum"]["usd_24h_vol"] + + await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"MCAP:{numerize.numerize(getir_mcap)}$")) + for guild in client.guilds: + await guild.me.edit(nick=f"ETH:{getir_usd}$ ") + + await asyncio.sleep(6) + await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"24hChange:%{numerize.numerize(getir_24)}")) + await asyncio.sleep(6) + await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"24hVol:{numerize.numerize(getir_24_vol)}")) + await asyncio.sleep(6) + +try : + @client.event + async def on_ready(): + client.loop.create_task(status_task()) + print('blockland Etherbot hazir') + +except : + False + +client.run(config.ETHEREUM_TOKEN)