Skip to content

Commit f1f052a

Browse files
authored
Merge pull request #1 from DankDumpster/api-2
Api 2
2 parents f1e8588 + eeb228c commit f1f052a

28 files changed

+876
-588
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ Cargo.lock
1212

1313
# Custom Directories
1414
.idea/
15-
config.yml
15+
config.yml
16+
.env

Diff for: Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "apollo"
3-
version = "0.1.0"
3+
version = "0.2.2"
44
authors = ["Matthew <[email protected]>"]
55
edition = "2018"
66
readme = "README.md"
@@ -21,7 +21,7 @@ typemap = "0.3.3"
2121
num-format = "0.4.0"
2222

2323
[dependencies.serenity]
24-
version = "0.9.0-rc.1"
24+
version = "0.9.0-rc.2"
2525
features = ["framework", "standard_framework", "rustls_backend", "cache", "collector"]
2626

2727
[dependencies.tokio]

Diff for: README.md

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Rust discord template
2-
This template is configured with postgres and serenity.
1+
# Apollo
2+
Apollo is a discord bot written in rust to keep you reminded on rocket launches and more! An always online bot is available **[here](https://discord.com/oauth2/authorize?client_id=755775587716563015&permissions=355328&scope=bot)**
33

44
## How to start
55
Clone the repo with
66
```shell script
7-
git clone https://github.com/DankDumpster/rust-discord-bot-template
7+
git clone https://github.com/DankDumpster/apollo.git
88
```
99

1010
Now we need to setup sqlx and we do that by doing
1111
```shell script
1212
cargo install --version=0.1.0-beta.1 sqlx-cli --no-default-features --features postgres
1313
```
1414

15-
Before we run sqlx we need to set the database environment variable temporarily, this is different for most shells
15+
Before we run we need to set the database environment variable temporarily, this is different for most shells. This is needed for the library sqlx.
1616

1717
#### cmd
1818
```shell script
19-
setx DATABASE_URL = "postgres://postgres:postgres@localhost/postgres"
19+
set DATABASE_URL=postgres://postgres:postgres@localhost/postgres
2020
```
2121
#### fish
2222
```shell script
@@ -26,7 +26,7 @@ etc...
2626

2727
Now once that's done we're going to run, this will take some time as its compiling everything
2828
```shell script
29-
cargo sqlx prepare
29+
cargo run
3030
```
3131

3232
NOTE: this will panic
@@ -35,18 +35,14 @@ This will ask you to enter each of the configuration values. If you wish edit th
3535
If anything goes wrong for any reason you can manually make a config.yml in the root with this:
3636
```yaml
3737
---
38-
token: ""
39-
prefix: ;
40-
db_uri: "postgres://postgres:postgres@localhost/postgres"
38+
token:
39+
prefix: ";"
40+
db_uri: "postgres://postgres:password@localhost/postgres"
41+
nasa_key:
42+
log_channel_id:
4143
```
4244
4345
Now run it again and it should work
4446
```shell script
4547
cargo run
4648
```
47-
48-
## Notes
49-
### Custom Config Location
50-
To set a custom config location, set the enviroment variable "CONFIG_PATH" and point it to a file.
51-
52-
###### Massive thanks to [dylan](https://github.com/dylhack) for the config function

Diff for: sqlx-data.json

+49-188
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,47 @@
1212
],
1313
"parameters": {
1414
"Left": [
15-
"Int4"
15+
"Text"
1616
]
1717
},
1818
"nullable": [
1919
false
2020
]
2121
}
2222
},
23-
"1c913927d614bebf4ace3340d5189911e415f11afc51c0eca356b8cf6f4b36f9": {
24-
"query": "SELECT * FROM apollo.guilds",
23+
"1c49ce24cda135321490774e9a818dd42cf1031d670eebc8e9874a74e0905383": {
24+
"query": "INSERT INTO apollo.launches (launch_id, name, net, tbd, vid_url, image_url, dispatched) VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (launch_id) DO UPDATE SET net = $3, tbd = $4, vid_url = $5, dispatched = $7;",
25+
"describe": {
26+
"columns": [],
27+
"parameters": {
28+
"Left": [
29+
"Text",
30+
"Text",
31+
"Timestamptz",
32+
"Bool",
33+
"Text",
34+
"Text",
35+
"Bool"
36+
]
37+
},
38+
"nullable": []
39+
}
40+
},
41+
"585008cd20c05f469cd1279c6bbbe053f66f78e25e2da83b7b1d974842316649": {
42+
"query": "INSERT INTO apollo.reminders (user_id, launch_id) VALUES ($1, $2)",
43+
"describe": {
44+
"columns": [],
45+
"parameters": {
46+
"Left": [
47+
"Int8",
48+
"Text"
49+
]
50+
},
51+
"nullable": []
52+
}
53+
},
54+
"982a74f0ce6a0497344c95770b7e8531aa8121b6dec0717003bf10856172625d": {
55+
"query": "SELECT * FROM apollo.guilds WHERE active = true",
2556
"describe": {
2657
"columns": [
2758
{
@@ -50,34 +81,8 @@
5081
]
5182
}
5283
},
53-
"2e2166a0aafbd70d5bde9d9fd1b37c5e15fdf9214a3fb48d7443837bb2779d32": {
54-
"query": "SELECT dispatched, timestamp FROM apollo.launches WHERE launch_id = $1 AND dispatched = true",
55-
"describe": {
56-
"columns": [
57-
{
58-
"ordinal": 0,
59-
"name": "dispatched",
60-
"type_info": "Bool"
61-
},
62-
{
63-
"ordinal": 1,
64-
"name": "timestamp",
65-
"type_info": "Int8"
66-
}
67-
],
68-
"parameters": {
69-
"Left": [
70-
"Int4"
71-
]
72-
},
73-
"nullable": [
74-
false,
75-
false
76-
]
77-
}
78-
},
79-
"37acbf4071d747f53e62516b901d2d678509fba9cce382d533ee5e2c9179c484": {
80-
"query": "SELECT dispatched, timestamp FROM apollo.launches WHERE launch_id = $1",
84+
"b00b699aee10a73a9e8ad42bc721909ab4dc0b637469915053d0080e51cc1ab2": {
85+
"query": "SELECT dispatched, net FROM apollo.launches WHERE launch_id = $1 AND dispatched = true",
8186
"describe": {
8287
"columns": [
8388
{
@@ -87,13 +92,13 @@
8792
},
8893
{
8994
"ordinal": 1,
90-
"name": "timestamp",
91-
"type_info": "Int8"
95+
"name": "net",
96+
"type_info": "Timestamptz"
9297
}
9398
],
9499
"parameters": {
95100
"Left": [
96-
"Int4"
101+
"Text"
97102
]
98103
},
99104
"nullable": [
@@ -102,124 +107,19 @@
102107
]
103108
}
104109
},
105-
"5206d2c60158f21f6ad1a0f975962d6f1006f34c9907845f98e264e110df66dd": {
106-
"query": "INSERT INTO apollo.launches (launch_id, dispatched, timestamp) VALUES ($1, true, $2) ON CONFLICT (launch_id) DO UPDATE SET timestamp = $2;",
107-
"describe": {
108-
"columns": [],
109-
"parameters": {
110-
"Left": [
111-
"Int4",
112-
"Int8"
113-
]
114-
},
115-
"nullable": []
116-
}
117-
},
118-
"539f3075886b085d6e8a33a74b21440b4fb6d97ad19b259e5704d0fa89ca2b27": {
119-
"query": "INSERT INTO apollo.launches (launch_id, dispatched) VALUES ($1, true)",
120-
"describe": {
121-
"columns": [],
122-
"parameters": {
123-
"Left": [
124-
"Int4"
125-
]
126-
},
127-
"nullable": []
128-
}
129-
},
130-
"58130ff9ca88874cf3f92c708d36aecf08f065c1988e216a0c3a788a3867aef8": {
131-
"query": "UPDATE apollo.guilds SET active = false WHERE guild_id = $1",
132-
"describe": {
133-
"columns": [],
134-
"parameters": {
135-
"Left": [
136-
"Int8"
137-
]
138-
},
139-
"nullable": []
140-
}
141-
},
142-
"585008cd20c05f469cd1279c6bbbe053f66f78e25e2da83b7b1d974842316649": {
143-
"query": "INSERT INTO apollo.reminders (user_id, launch_id) VALUES ($1, $2)",
144-
"describe": {
145-
"columns": [],
146-
"parameters": {
147-
"Left": [
148-
"Int8",
149-
"Int4"
150-
]
151-
},
152-
"nullable": []
153-
}
154-
},
155-
"738433d7d8a302ae480cdf34f31ce4f34a68a32d97d2112add1a1659ce7ee184": {
156-
"query": "INSERT INTO apollo.guilds (guild_id, channel_id) VALUES ($1, $2) ON CONFLICT (guild_id) DO UPDATE SET channel_id = $2, active = true",
157-
"describe": {
158-
"columns": [],
159-
"parameters": {
160-
"Left": [
161-
"Int8",
162-
"Int8"
163-
]
164-
},
165-
"nullable": []
166-
}
167-
},
168-
"78f70a999969b1267853cc20810452d8d7053d14c92439ec798110973728fd9f": {
169-
"query": "INSERT INTO apollo.reminders (user_id, launch_id, active) VALUES ($1, $2, true)",
170-
"describe": {
171-
"columns": [],
172-
"parameters": {
173-
"Left": [
174-
"Int8",
175-
"Int4"
176-
]
177-
},
178-
"nullable": []
179-
}
180-
},
181-
"86e8b2dfdb6a286f6f92862f263f89cd8e0e3cc478567a626d9e86794e0a6ca2": {
182-
"query": "UPDATE apollo.reminders SET active = false WHERE launch_id = $1",
110+
"b8863d9563ae655118a63524ed4299941fee28a4ef7423b428087a4450087f54": {
111+
"query": "UPDATE apollo.launches SET net = $1, dispatched = false WHERE launch_id = $2",
183112
"describe": {
184113
"columns": [],
185114
"parameters": {
186115
"Left": [
187-
"Int4"
116+
"Timestamptz",
117+
"Text"
188118
]
189119
},
190120
"nullable": []
191121
}
192122
},
193-
"982a74f0ce6a0497344c95770b7e8531aa8121b6dec0717003bf10856172625d": {
194-
"query": "SELECT * FROM apollo.guilds WHERE active = true",
195-
"describe": {
196-
"columns": [
197-
{
198-
"ordinal": 0,
199-
"name": "guild_id",
200-
"type_info": "Int8"
201-
},
202-
{
203-
"ordinal": 1,
204-
"name": "channel_id",
205-
"type_info": "Int8"
206-
},
207-
{
208-
"ordinal": 2,
209-
"name": "active",
210-
"type_info": "Bool"
211-
}
212-
],
213-
"parameters": {
214-
"Left": []
215-
},
216-
"nullable": [
217-
false,
218-
false,
219-
false
220-
]
221-
}
222-
},
223123
"d65e391092aa6e2be032528ec0a894b685cc8ceaf966976e191ee9c3bf17f914": {
224124
"query": "SELECT * FROM apollo.reminders WHERE user_id = $1 AND launch_id = $2",
225125
"describe": {
@@ -231,50 +131,24 @@
231131
},
232132
{
233133
"ordinal": 1,
234-
"name": "user_id",
235-
"type_info": "Int8"
236-
},
237-
{
238-
"ordinal": 2,
239134
"name": "launch_id",
240-
"type_info": "Int4"
135+
"type_info": "Text"
241136
},
242137
{
243-
"ordinal": 3,
244-
"name": "active",
245-
"type_info": "Bool"
138+
"ordinal": 2,
139+
"name": "user_id",
140+
"type_info": "Int8"
246141
}
247142
],
248143
"parameters": {
249144
"Left": [
250145
"Int8",
251-
"Int4"
146+
"Text"
252147
]
253148
},
254149
"nullable": [
255150
false,
256151
false,
257-
true,
258-
false
259-
]
260-
}
261-
},
262-
"e47b03706be3a1a5b801aa5bbfd7ae17c7c80fdf5308bd0d6817563c992e1141": {
263-
"query": "SELECT dispatched FROM apollo.launches WHERE launch_id = $1",
264-
"describe": {
265-
"columns": [
266-
{
267-
"ordinal": 0,
268-
"name": "dispatched",
269-
"type_info": "Bool"
270-
}
271-
],
272-
"parameters": {
273-
"Left": [
274-
"Int4"
275-
]
276-
},
277-
"nullable": [
278152
false
279153
]
280154
}
@@ -286,20 +160,7 @@
286160
"parameters": {
287161
"Left": [
288162
"Int8",
289-
"Int4"
290-
]
291-
},
292-
"nullable": []
293-
}
294-
},
295-
"ef27e703a0f53004aa0ab0df821f6d72164257921fd09e0ef7e07e3b8e983f79": {
296-
"query": "INSERT INTO apollo.guilds (guild_id, channel_id) VALUES ($1, $2) ON CONFLICT (guild_id) DO UPDATE SET channel_id = $2",
297-
"describe": {
298-
"columns": [],
299-
"parameters": {
300-
"Left": [
301-
"Int8",
302-
"Int8"
163+
"Text"
303164
]
304165
},
305166
"nullable": []

0 commit comments

Comments
 (0)