11import {
22 ContainerBuilder ,
3+ hyperlink ,
34 MessageFlags ,
45 SeparatorBuilder ,
56 SlashCommandBuilder ,
67} from "discord.js" ;
7- import { DEFAULT_EMBED_COLOR , SCHOOLS } from "../constants.js" ;
8+ import { DEFAULT_EMBED_COLOR , SCHOOLS , SCOTTYLABS_URL } from "../constants.js" ;
89import apCoursesData from "../data/ap-courses.json" with { type : "json" } ;
910import apCreditData from "../data/ap-credit.json" with { type : "json" } ;
1011import CoursesData from "../data/finalCourseJSON.json" with { type : "json" } ;
@@ -69,7 +70,7 @@ async function loadApCreditData(): Promise<Exam[]> {
6970 if ( ! course ) {
7071 return {
7172 id,
72- name : exam . name ,
73+ name : "Equivalent Course not Found" ,
7374 syllabi : [ ] ,
7475 desc : "" ,
7576 prereqs : [ ] ,
@@ -79,6 +80,19 @@ async function loadApCreditData(): Promise<Exam[]> {
7980 units : "" ,
8081 department : "" ,
8182 } ;
83+ } else if ( course . name . startsWith ( "AP" ) ) {
84+ return {
85+ id,
86+ name : exam . name + " (*Not Offered Course*)" ,
87+ syllabi : [ ] ,
88+ desc : "" ,
89+ prereqs : [ ] ,
90+ prereqString : "" ,
91+ coreqs : [ ] ,
92+ crosslisted : [ ] ,
93+ units : course . units ,
94+ department : "" ,
95+ } ;
8296 }
8397
8498 return course ;
@@ -111,7 +125,7 @@ function getGenedsForCourse(courseId: string, geneds: GenEd[]): string[] {
111125
112126const command : SlashCommand = {
113127 data : new SlashCommandBuilder ( )
114- . setName ( "credit-calculator " )
128+ . setName ( "credits " )
115129 . setDescription ( "Credit calculator for CMU courses" )
116130 . addSubcommand ( ( subcommand ) =>
117131 subcommand
@@ -263,7 +277,9 @@ const command: SlashCommand = {
263277 const container = new ContainerBuilder ( )
264278 . setAccentColor ( DEFAULT_EMBED_COLOR )
265279 . addTextDisplayComponents ( ( t ) =>
266- t . setContent ( "Awarded CMU Credit" ) ,
280+ t . setContent (
281+ "## Awarded CMU Credit\n*Gened data is incomplete and partly outdated*" ,
282+ ) ,
267283 ) ;
268284
269285 if ( awarded . length === 0 ) {
@@ -278,14 +294,6 @@ const command: SlashCommand = {
278294 let genedCreditTotal = 0 ;
279295
280296 for ( const { exam, courses : awardedCourses } of awarded ) {
281- container . addSeparatorComponents (
282- new SeparatorBuilder ( ) ,
283- ) ;
284-
285- container . addTextDisplayComponents ( ( t ) =>
286- t . setContent ( `### ${ exam . name } ` ) ,
287- ) ;
288-
289297 let geneds : GenEd [ ] = [ ] ;
290298
291299 if ( userSchool == "DC" ) {
@@ -305,6 +313,10 @@ const command: SlashCommand = {
305313 }
306314
307315 for ( const course of awardedCourses ) {
316+ container . addSeparatorComponents (
317+ new SeparatorBuilder ( ) ,
318+ ) ;
319+
308320 const units = Number ( course . units ) || 0 ;
309321 genedCreditTotal += units ;
310322
@@ -317,29 +329,32 @@ const command: SlashCommand = {
317329 : [ ] ;
318330
319331 const genedTags = genedList . length
320- ? genedList . map ( ( g ) => `[ ${ g } ] ` ) . join ( " " )
321- : "_None_ " ;
332+ ? genedList . map ( ( g ) => `${ g } ` ) . join ( " " )
333+ : "n/a " ;
322334
323335 container . addTextDisplayComponents ( ( t ) =>
324336 t . setContent (
325337 [
326- `> **${ course . id } ** — ${ courseName } ` ,
327- `> **${ units } units** · GenEds: ${ genedTags } ` ,
338+ courseName . endsWith (
339+ "(*Not Offered Course*)" ,
340+ )
341+ ? `**${ course . id } ** — AP ${ courseName } (${ units } units) `
342+ : hyperlink (
343+ `**${ course . id } ** — ${ courseName } (${ units } units)` ,
344+ `${ SCOTTYLABS_URL } /course/${ course . id } ` ,
345+ ) ,
346+ genedTags != "n/a"
347+ ? `AP ${ exam . name } • Fulfills ${ genedTags } Gened Requirement`
348+ : `AP ${ exam . name } ` ,
349+ `${ exam . info } ` ,
328350 ] . join ( "\n" ) ,
329351 ) ,
330352 ) ;
331353 }
332- if ( exam . info !== "" ) {
333- container . addTextDisplayComponents ( ( t ) =>
334- t . setContent ( `${ exam . info } ` ) ,
335- ) ;
336- }
337354 }
338355
339356 container . addTextDisplayComponents ( ( t ) =>
340- t . setContent (
341- `**GenEd Unit Total:** ${ genedCreditTotal } ` ,
342- ) ,
357+ t . setContent ( `**Unit Total:** ${ genedCreditTotal } ` ) ,
343358 ) ;
344359 return container ;
345360 } ,
0 commit comments