mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Upgrading Warframe module to return more information
This commit is contained in:
@@ -3,33 +3,43 @@ import json
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import config
|
from config import config
|
||||||
|
from discord import Embed
|
||||||
|
|
||||||
|
|
||||||
class Warframe(commands.Cog):
|
class Warframe(commands.Cog):
|
||||||
"""Deal with the generation of warframe data"""
|
"""Deal with the generation of warframe data"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot: discord.Client):
|
||||||
self.__bot = bot
|
self.__bot = bot
|
||||||
|
self.__open_functions = ['cetus', 'cambion', 'fissures']
|
||||||
|
|
||||||
@property
|
@commands.command(name='warframe', help='<x> - Retorna informações de x')
|
||||||
def bot(self):
|
async def warframe(self, ctx, arg):
|
||||||
return self.__bot
|
if arg in self.__open_functions:
|
||||||
|
function = getattr(Warframe, f'_Warframe__{arg}') # Get the required function
|
||||||
|
embed = await function(self) # Execute the function passing self
|
||||||
|
|
||||||
@bot.setter
|
await ctx.send(embed=embed) # Return the result
|
||||||
def bot(self, newBot):
|
else:
|
||||||
self.__bot = newBot
|
info = f'Warframe commands: {self.__open_functions}'
|
||||||
|
|
||||||
@commands.command(name='cetus', help='Informa o tempo atual de Cetus - Warframe')
|
embed = Embed(
|
||||||
async def cetus(self, ctx):
|
title='Invalid Command',
|
||||||
description = await self.__get_api()
|
description=info,
|
||||||
|
colour=config.COLOURS['blue']
|
||||||
|
)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
async def __cetus(self) -> Embed:
|
||||||
|
description = await self.__get_cetus()
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title='Warframe Cetus Timing',
|
title='Warframe Cetus Timing',
|
||||||
description=description,
|
description=description,
|
||||||
colour=config.COLOURS['blue']
|
colour=config.COLOURS['blue']
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
return embed
|
||||||
|
|
||||||
async def __get_api(self):
|
async def __get_cetus(self):
|
||||||
"""Return the information of the Warframe API"""
|
"""Return the information of the Warframe API"""
|
||||||
tries = 0
|
tries = 0
|
||||||
while True:
|
while True:
|
||||||
@@ -46,6 +56,64 @@ class Warframe(commands.Cog):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
async def __cambion(self) -> Embed:
|
||||||
|
description = await self.__get_cambion()
|
||||||
|
embed = discord.Embed(
|
||||||
|
title='Warframe Cambion Timing',
|
||||||
|
description=description,
|
||||||
|
colour=config.COLOURS['blue']
|
||||||
|
)
|
||||||
|
return embed
|
||||||
|
|
||||||
|
async def __get_cambion(self):
|
||||||
|
"""Return the information of the Warframe API"""
|
||||||
|
tries = 0
|
||||||
|
while True:
|
||||||
|
tries += 1
|
||||||
|
if tries > config.MAX_API_CAMBION_TRIES:
|
||||||
|
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(config.CAMBION_API)
|
||||||
|
data = json.loads(response.content)
|
||||||
|
|
||||||
|
info = f'**Active:** {data["active"]}\n**Time Left:** {data["timeLeft"]}'
|
||||||
|
|
||||||
|
return info
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
async def __fissures(self) -> Embed:
|
||||||
|
description = await self.__get_fissures()
|
||||||
|
embed = discord.Embed(
|
||||||
|
title='Warframe Fissures Status',
|
||||||
|
description=description,
|
||||||
|
colour=config.COLOURS['blue']
|
||||||
|
)
|
||||||
|
return embed
|
||||||
|
|
||||||
|
async def __get_fissures(self):
|
||||||
|
"""Return the information of the Warframe API"""
|
||||||
|
tries = 0
|
||||||
|
while True:
|
||||||
|
tries += 1
|
||||||
|
if tries > config.MAX_API_FISSURES_TRIES:
|
||||||
|
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.get(config.FISSURES_API)
|
||||||
|
data = json.loads(response.content)
|
||||||
|
|
||||||
|
info = ''
|
||||||
|
for pos, fissure in enumerate(data, start=1):
|
||||||
|
info += f'`{pos}` - **Mission:** {fissure["missionType"]} | **Type:** {fissure["tier"]} | **Timing:** {fissure["eta"]} | **Storm:** {fissure["isStorm"]}\n'
|
||||||
|
|
||||||
|
return info
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|||||||
Reference in New Issue
Block a user