-
Notifications
You must be signed in to change notification settings - Fork 0
/
spacex.py
28 lines (22 loc) · 994 Bytes
/
spacex.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
import json
from dateutil import parser
async def spacex_launches(ctx):
"""
Returns the next few upcoming SpaceX launches to the discord channel.
It is ependent on the amount of information in the response fields
how many responses can be returned due to Discord's 2000 character message limit.
"""
file = open("nextlaunch.json", encoding="utf-8")
json_file = json.load(file)
await ctx.send(f"Upcoming SpaceX Launches As requested By {ctx.author.mention}")
for launch in json_file['results']:
launch_string = f"""
```
Name: {launch['name']}
Description: {launch['status']['description']}
Mission Type: {launch['mission']['type']}
Location: {launch['pad']['name']}, {launch['pad']['location']['name']}, {launch['pad']['location']['country_code']}
Launch Window (YYYY-MM-DD: 24 Hour Time Format): {parser.parse(launch['window_start'])} to {parser.parse(launch['window_end'])}
```
"""
await ctx.respond(launch_string)