@@ -27,76 +27,78 @@ module.exports = {
27
27
28
28
let data ;
29
29
try {
30
- const response = await axios . get ( `${ apiURL } ${ courseCode } ` ) ;
30
+ // Documented at:
31
+ // https://circlesapi.csesoc.app/docs#/courses/get_course_courses_getCourse__courseCode__get
32
+ const response = await axios . get ( `${ apiURL } /courses/getCourse/${ courseCode } ` ) ;
31
33
data = response . data ;
34
+ // console.log(data);
32
35
} catch ( e ) {
33
36
return await interaction . reply ( {
34
37
content : "Invalid course code." ,
35
38
ephemeral : true ,
36
39
} ) ;
37
40
}
38
41
42
+ const {
43
+ title, code, UOC , level, description, study_level, school, campus,
44
+ equivalents, raw_requirements, exclusions, handbook_note, terms
45
+ } = data ;
46
+
39
47
const courseInfo = new MessageEmbed ( )
40
- . setTitle ( data [ " title" ] )
41
- . setURL ( `${ handbookURL } ${ courseCode } ` )
48
+ . setTitle ( title )
49
+ . setURL ( `${ handbookURL } / ${ code } ` )
42
50
. setColor ( 0x3a76f8 )
43
51
. setAuthor (
44
- `Course Info: ${ courseCode } (${ data [ "credit_points" ] } UOC)` ,
52
+ `Course Info: ${ code } (${ UOC } UOC)` ,
45
53
"https://i.imgur.com/EE3Q40V.png" ,
46
54
)
47
55
. addFields (
48
56
{
49
57
name : "Overview" ,
50
- value : textVersion ( data [ " description" ] ) . substring (
58
+ value : textVersion ( description ) . substring (
51
59
0 ,
52
- Math . min ( textVersion ( data [ " description" ] ) . indexOf ( "\n" ) , 1024 ) ,
60
+ Math . min ( textVersion ( description ) . indexOf ( "\n" ) , 1024 ) ,
53
61
) ,
54
62
inline : false ,
55
63
} ,
56
64
{
57
65
name : "Enrolment Requirements" ,
58
66
value :
59
- data [ "enrolment_requirements" ] . replace (
67
+ raw_requirements . replace (
60
68
/ [ A - Z ] { 4 } [ 0 - 9 ] { 4 } / g,
61
69
`[$&](${ handbookURL } $&)` ,
62
70
) || "None" ,
63
71
inline : true ,
64
72
} ,
65
73
{
66
74
name : "Offering Terms" ,
67
- value : data [ "offering_terms" ] ,
68
- inline : true ,
69
- } ,
70
- {
71
- name : "Delivery Mode" ,
72
- value : data [ "delivery_mode" ] ,
75
+ value : terms . join ( ", " ) ,
73
76
inline : true ,
74
77
} ,
75
78
{
76
79
name : "Equivalent Courses" ,
77
- value :
78
- data [ "equivalent_courses" ]
79
- . map ( ( course ) => `[${ course } ](${ handbookURL } ${ course } )` )
80
- . join ( ", " ) || "None" ,
80
+ value :
81
+ Object . keys ( equivalents )
82
+ . map ( ( course ) => `[${ course } ](${ course } )` )
83
+ . join ( ", " ) || "None" ,
81
84
inline : true ,
82
85
} ,
83
86
{
84
87
name : "Exclusion Courses" ,
85
88
value :
86
- data [ "exclusion_courses" ]
89
+ Object . keys ( exclusions )
87
90
. map ( ( course ) => `[${ course } ](${ handbookURL } ${ course } )` )
88
91
. join ( ", " ) || "None" ,
89
92
inline : true ,
90
93
} ,
91
- {
92
- name : "Course Outline" ,
93
- value : `[${ courseCode } Course Outline](${ data [ "course_outline_url" ] } )` ,
94
- inline : true ,
95
- } ,
94
+ /* { */
95
+ /* name: "Course Outline", */
96
+ /* value: `[${courseCode} Course Outline](${data["course_outline_url"]})`, */
97
+ /* inline: true, */
98
+ /* }, */
96
99
)
97
100
. setTimestamp ( )
98
- . setFooter ( "Data fetched from Zac's Handbook API" ) ;
99
-
101
+ . setFooter ( "Data fetched from Circles' Api" ) ;
100
102
await interaction . reply ( { embeds : [ courseInfo ] } ) ;
101
103
}
102
104
} ,
0 commit comments