-
Notifications
You must be signed in to change notification settings - Fork 0
/
launches.py
41 lines (36 loc) · 1.56 KB
/
launches.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
async def next_five(ctx) -> str:
"""
Returns the next few spacecraft launches
"""
launches = requests.get(
"https://fdo.rocketlaunch.live/json/launches/next/5",
timeout=3
)
launches_json = launches.json()
print(launches_json)
await ctx.send(f"Upcoming Launches As Requested By {ctx.author.mention}")
response_string = ""
for launch in launches_json['result']:
next_launch_string = ""
next_launch_string = next_launch_string + f"""
```
Company/Agency: {launch['provider']['name']}
Mission Name: {launch['name']}
Vehicle: {launch['vehicle']['name']}
Launch Site: {launch['pad']['location']['name']}, {launch['pad']['location']['state']}, {launch['pad']['location']['country']}
Suborbital: {launch['suborbital']}
"""
if launch['missions'][0]['name'] is not None:
next_launch_string = next_launch_string + \
f"{launch['missions'][0]['name']}\n"
if launch['missions'][0]['description'] is not None:
next_launch_string = next_launch_string + \
f" {launch['missions'][0]['description']}"
next_launch_string = next_launch_string + \
f" {launch['launch_description']}\n ```"
if len(next_launch_string) + len(response_string) > 2000:
break
else:
response_string = response_string + next_launch_string
await ctx.send(response_string)