Adding quantumfuel to the /ship command
This commit is contained in:
parent
f2d7ef917e
commit
003f77b93f
@ -310,6 +310,21 @@ class StarCitizen(commands.Cog):
|
|||||||
|
|
||||||
await star_citizen.send_alert(self, channel=channel_id, embed=embed)
|
await star_citizen.send_alert(self, channel=channel_id, embed=embed)
|
||||||
|
|
||||||
|
@commands.slash_command(
|
||||||
|
guild_ids=None,
|
||||||
|
name="rsifind",
|
||||||
|
description="Pull up info about a player from their RSI profile",
|
||||||
|
)
|
||||||
|
@option(
|
||||||
|
name="player",
|
||||||
|
description="The player name to search for",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
async def rsi_find(self, ctx: commands.Context, player: str):
|
||||||
|
await ctx.defer()
|
||||||
|
embed = await star_citizen.rsi_find(player=player)
|
||||||
|
await ctx.send_followup(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(StarCitizen(bot))
|
bot.add_cog(StarCitizen(bot))
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import requests
|
|
||||||
import discord
|
import discord
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
import datetime
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# prints for debug
|
# prints for debug
|
||||||
import pprint
|
import pprint
|
||||||
@ -49,6 +51,53 @@ def write_incident_file(file_path, url, details):
|
|||||||
out_file.write(json.dumps(info_dict))
|
out_file.write(json.dumps(info_dict))
|
||||||
|
|
||||||
|
|
||||||
|
async def rsi_find(player):
|
||||||
|
url = "https://api.starcitizen-api.com/%s/v1/live/user/%s" % (
|
||||||
|
os.getenv("star_citizen_token").replace('"', ""),
|
||||||
|
player,
|
||||||
|
)
|
||||||
|
response = requests.get(url).json()
|
||||||
|
embed = discord.Embed(
|
||||||
|
description="-------",
|
||||||
|
color=discord.Color.blue(),
|
||||||
|
type="rich",
|
||||||
|
title="[%s's Star Citizen Information](%s)"
|
||||||
|
% (
|
||||||
|
response["data"]["profile"]["page"]["url"],
|
||||||
|
response["data"]["profile"]["handle"],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Link to profile",
|
||||||
|
value=response["data"]["profile"]["page"]["url"],
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.add_field(
|
||||||
|
name="Enlisted",
|
||||||
|
value=response["data"]["profile"]["enlisted"],
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
embed.set_author(
|
||||||
|
name=response["data"]["profile"]["badge"],
|
||||||
|
icon_url=response["data"]["profile"]["badge_image"],
|
||||||
|
)
|
||||||
|
embed.set_thumbnail(url=response["data"]["profile"]["image"])
|
||||||
|
|
||||||
|
embed.add_field(name="-------", value="", inline=False)
|
||||||
|
if response["data"]["organization"]["name"]:
|
||||||
|
embed.add_field(
|
||||||
|
name="Org Info",
|
||||||
|
value=response["data"]["organization"]["name"],
|
||||||
|
inline=False,
|
||||||
|
)
|
||||||
|
embed.set_image(url=response["data"]["organization"]["image"])
|
||||||
|
else:
|
||||||
|
embed.add_field(name="Org Info", value="Player is not in an org", inline=False)
|
||||||
|
|
||||||
|
return embed
|
||||||
|
|
||||||
|
|
||||||
async def get_ship(ship_name):
|
async def get_ship(ship_name):
|
||||||
try:
|
try:
|
||||||
wiki_ship_name = "_".join(elem for elem in ship_name.split())
|
wiki_ship_name = "_".join(elem for elem in ship_name.split())
|
||||||
@ -203,6 +252,19 @@ async def get_ship(ship_name):
|
|||||||
|
|
||||||
embed.add_field(name="**Ship Health**", value=health, inline=True)
|
embed.add_field(name="**Ship Health**", value=health, inline=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
quantum_fuel = (
|
||||||
|
soup.find("div", {"class": "infobox__label"}, string="Quantum capacity")
|
||||||
|
.findNext("span", {"class": "smwtext"})
|
||||||
|
.text
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
quantum_fuel = "N/A"
|
||||||
|
|
||||||
|
embed.add_field(
|
||||||
|
name="**Quantum Fuel Capacity**", value=quantum_fuel, inline=True
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
top_speed = (
|
top_speed = (
|
||||||
soup.find("div", {"class": "infobox__label"}, string="Max speed")
|
soup.find("div", {"class": "infobox__label"}, string="Max speed")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user