mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Upgrading the stability of the warframe api
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import discord
|
import discord
|
||||||
from dotenv import dotenv_values
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
@@ -21,30 +20,32 @@ class Warframe(commands.Cog):
|
|||||||
self.__bot = newBot
|
self.__bot = newBot
|
||||||
|
|
||||||
@commands.command(name='cetus', help='Informa o tempo atual de Cetus - Warframe')
|
@commands.command(name='cetus', help='Informa o tempo atual de Cetus - Warframe')
|
||||||
async def get_cetus(self, ctx):
|
async def cetus(self, ctx):
|
||||||
try:
|
description = await self.__get_api()
|
||||||
response = requests.get(config.CETUS_API)
|
embed = discord.Embed(
|
||||||
data = json.loads(response.content)
|
title='Warframe Cetus Timing',
|
||||||
short = data['shortString']
|
description=description,
|
||||||
|
colour=config.COLOURS['blue']
|
||||||
|
)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
responseText = f'{short}'
|
async def __get_api(self):
|
||||||
|
"""Return the information of the Warframe API"""
|
||||||
|
tries = 0
|
||||||
|
while True:
|
||||||
|
tries += 1
|
||||||
|
if tries > config.MAX_API_CETUS_TRIES:
|
||||||
|
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||||
|
|
||||||
embed = discord.Embed(
|
try:
|
||||||
title='Warframe Cetus Timing',
|
response = requests.get(config.CETUS_API)
|
||||||
description=responseText,
|
data = json.loads(response.content)
|
||||||
colour=0xFF0000
|
short = data['shortString']
|
||||||
)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
except Exception as e:
|
return short
|
||||||
print(e)
|
|
||||||
responseText = f'Houve um erro inesperado :/'
|
except Exception as e:
|
||||||
embed = discord.Embed(
|
continue
|
||||||
title='Warframe Cetus Timing',
|
|
||||||
description=responseText,
|
|
||||||
colour=0xFF0000
|
|
||||||
)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|||||||
Reference in New Issue
Block a user