def covid_api_request(endpoint): try: covid_request_url = urllib.request.Request( 'https://api.covid19api.com/' + endpoint) covid_request_data = json.loads( urllib.request.urlopen(covid_request_url).read().decode('utf-8')) return covid_request_data except Exception as e: printt( f"====| Ocurrio un error al pedir los datos de la api covid19.\nDetalles:{e}\nRazon:{e.args}" )
async def lyrics(self, ctx: SlashContext, artista: str, *, cancion): """ #lyrics, #letras, #buscar_letras, todos sirven igual. Se sube un archivo .txt para que sea mas facil su lectura. Argumento 1 <artist_name>: nombre del artista. Argumento 2 <song_name>: nombre de la cancion. """ genius = lyricsgenius.Genius(os.getenv('GENIUS_ACCESS_TOKEN')) song = genius.search_song(artist=artista, title=cancion) with open(f'databases/{cancion[:7]}_lyrics.txt', 'w', encoding='utf-8') as file: file.write(song.lyrics) printt("Lyrics saved successfully") await ctx.send( content=f"Mostrando Letras para **{cancion}**", file=discord.File(f'databases/{cancion[:7]}_lyrics.txt') )
async def dolar(self, ctx): ''' Cotizacion del dolar argentino en diversas variantes ''' try: dolar_request = requests.get(DOLAR_URL) except Exception as e: await ctx.send(f"Ocurrio un error al obtener las cotizaciones. ```**Info detallada***:{e}\n**Razon**:{e.args}```") printt(f"====| Ocurrio un error al extraer el json del dolar. Exc:{e}\nArgs:{e.args}") if dolar_request.status_code == 200: dolar_json = dolar_request.json() compraOfi = dolar_json[0]['casa']['compra'][:-1] ventaOfi = dolar_json[0]['casa']['venta'][:-1] varOfi = dolar_json[0]['casa']['variacion'][:-1] dolarSolid = str(float(dolar_json[0]['casa']['venta'][:-1].replace(",", ".")[:4]) * 1.65) compraBlue = dolar_json[1]['casa']['compra'][:-1] ventaBlue = dolar_json[1]['casa']['venta'][:-1] varBlue = dolar_json[1]['casa']['variacion'][:-1] compraCcl = dolar_json[3]['casa']['compra'][:-1] ventaCcl = dolar_json[3]['casa']['venta'][:-1] varCcl = dolar_json[3]['casa']['variacion'][:-1] compraBolsa = dolar_json[4]['casa']['compra'][:-1] ventaBolsa = dolar_json[4]['casa']['venta'][:-1] varBolsa = dolar_json[4]['casa']['variacion'][:-1] precioBitcoin = str(dolar_json[5]['casa']['venta'])[:-2] embedDolar = discord.Embed( Title = "Cotización del dolar", color = discord.Colour.green()) embedDolar.set_thumbnail(url=DOLAR_THUMBNAIL) embedDolar.add_field(name=':blue_circle: Blue:', value=f"Compra: {compraBlue} | Venta: {ventaBlue} | Var. 24h: {varBlue}", inline=False) embedDolar.add_field(name=':green_circle: Oficial:', value=f"Compra: {compraOfi} | Venta: {ventaOfi} | Var. 24h: {varOfi}", inline=False) embedDolar.add_field(name=':green_circle: Oficial con impuestos (El que importa):', value=f"Valor aproximado de: {dolarSolid}", inline=False) embedDolar.add_field(name=':yellow_circle: Bolsa:', value=f"Compra: {compraBolsa} | Venta: {ventaBolsa} | Var. 24h: {varBolsa}", inline=False) embedDolar.add_field(name=':orange_circle: Contado con liqui:', value=f"Compra: {compraCcl} | Venta: {ventaCcl} | Var. 24h: {varCcl}", inline=False) embedDolar.add_field(name=':orange_circle: Precio del Bitcoin:', value=f"Valor aproximado medio: {precioBitcoin}", inline=False) await typing_sleep(ctx) await ctx.send(embed=embedDolar) print(f"cmdDolar|| {ctx.author.name} solicitó la cot. del dolar")
async def on_ready(self): printt("cog de server_statuses listo")
async def on_ready(self): printt("cog de fortnite_stats listo")
async def reddit_meme(self, ctx: SlashContext, subreddit_to_search=None): """ ES: Busca un meme random en un subreddit dado. por defecto envia memes del subreddit r/memes... ejemplo: #reddit_meme MemesArgentina No spamear el comando caso contrario se causara un error 429 y quedara inutilizable por un tiempo. • EN: Searchs for a random meme in a given subreddit. subreddit r/memes by default if no subreddit is given... syntax example: #reddit_meme dankmemes Please do not spam the command, thanks. """ if subreddit_to_search != None: subreddit_url = f"https://www.reddit.com/r/{subreddit_to_search}.json" elif subreddit_to_search == None: subreddit_url = "https://www.reddit.com/r/memes.json" subreddit_to_search = "memes" try: memes = requests.get(subreddit_url).json() pick_random = random.randint( 0, 25 ) # to choose between the 25 available posts that json returns. embedReddit = discord.Embed( title=(f"Meme|Post de r/{subreddit_to_search}."), color=discord.Color.purple()) titulo_var = memes["data"]["children"][pick_random]["data"][ "title"] autor_var = memes["data"]["children"][pick_random]["data"][ "author"] likes_var = memes["data"]["children"][pick_random]["data"]["score"] url_var = memes["data"]["children"][pick_random]["data"]["url"] embedReddit.add_field(name="**TÃtulo**", value=titulo_var, inline=True) embedReddit.add_field(name="**Autor**", value=autor_var, inline=True) embedReddit.add_field(name="**Likes**", value=likes_var, inline=True) embedReddit.set_image(url=url_var) embedReddit.set_footer(icon_url=ctx.author.avatar_url, text=f"Meme para {ctx.author.name}") await ctx.send(content="Aqui esta el meme", embed=embedReddit) print(f'cmdRedditMeme|| Meme enviado a {ctx.author.name}') except: printt( "====| El 1er metodo para extraer memes fallo, usando el 2do metodo" ) await ctx.defer() # pesonal credentials! reddit = asyncpraw.Reddit(client_id=getenv('CLIENT_ID'), client_secret=getenv('CLIENT_SECRET'), username='******', password=getenv('REDDIT_PASSWORD'), user_agent='app:bigobot/user:JuliTJZ') subreddit = await reddit.subreddit(subreddit_to_search) all_subs = [] top = subreddit.top(limit=350) async for submission in top: all_subs.append(submission) random_sub = random.choice(all_subs) name = random_sub.title url = random_sub.url embedTwo = discord.Embed(title=f'__{name}__', colour=discord.Color.purple(), timestamp=ctx.message.created_at, url=url) embedTwo.set_image(url=url) embedTwo.set_footer(text="Este es el meme 🥂:", icon_url=REDDIT_ICON) await ctx.message.delete() await ctx.send( content= "Usando el segundo metodo del comando ya que el primer metodo retorna error 429", embed=embedTwo, )
async def on_ready(self): printt("cog de reddit_meme listo")
async def on_ready(): printt("Cog de matecomandos listo")
async def on_ready(self): printt("cog de bot_info listo")
async def on_ready(self): printt("cog de fb_posts listo")
async def on_ready(self): printt("cog de instagram listo")
async def on_ready(self): printt("cog de cotizacion del dolar funcionando")
async def on_ready(self): printt("cog de covid_19 listo")
async def on_ready(self): printt("cog de lyrics listo")
async def on_ready(self): printt("cog de country_guesses listo")
async def on_ready(self): printt("cog de ofertas de juegos listo")
async def on_ready(self): printt('cog de comandos_generales listo')
async def on_ready(self): printt("cog de minehut_server info listo")