@@ -18,16 +18,16 @@ export const data = new SlashCommandBuilder()
18
18
option . setName ( 'datum' ) . setDescription ( 'Das Datum, das angezeigt werden soll. Format: DD.MM.YYYY' ) ,
19
19
)
20
20
21
- async function wochenplan ( client : DiscordClient , interaction : DiscordCommandInteraction , pNow , pCourseAndSemester ) {
21
+ async function wochenplan ( client : DiscordClient , interaction : DiscordCommandInteraction , date , pCourseAndSemester ) {
22
22
let returnData = { }
23
23
for ( const entry in client . config . calendars ) {
24
24
// eslint-disable-next-line no-await-in-loop
25
25
returnData = { ...returnData , ...( await async . fromURL ( client . config . calendars [ entry ] ) ) }
26
26
}
27
27
28
28
const relevantEvents = [ ]
29
- const curWeekday = pNow . getDay ( ) === 0 ? 6 : pNow . getDay ( ) - 1
30
- const startOfWeek = new Date ( pNow . setDate ( pNow . getDate ( ) - curWeekday ) )
29
+ const curWeekday = date . getDay ( ) === 0 ? 6 : date . getDay ( ) - 1
30
+ const startOfWeek = new Date ( date . setDate ( date . getDate ( ) - curWeekday ) )
31
31
startOfWeek . setHours ( 0 , 0 , 0 )
32
32
33
33
const rangeStart = moment ( startOfWeek )
@@ -239,11 +239,17 @@ function pushToWeeksEvents(interaction, event, event_start, event_end, relevantE
239
239
searchQuery = event . summary . toString ( )
240
240
}
241
241
if ( roles [ role ] . name . toLowerCase ( ) . trim ( ) === searchQuery . toLowerCase ( ) . trim ( ) ) {
242
- console . log ( event . summary , event_start )
243
- relevantEvents . push ( event )
244
242
/**
245
- * TODO: now OFE of 28th of april is added, but not GHF from 29th of April, and also not yet displayed correctly in the weekplanner
243
+ * Add entry with new key.
244
+ * Key increments by one (determined by length).
246
245
*/
246
+ relevantEvents [ Object . keys ( relevantEvents ) . length ] = {
247
+ start : event_start ,
248
+ end : event_end ,
249
+ summary : event . summary ,
250
+ description : event . description ,
251
+ location : event . location ,
252
+ }
247
253
}
248
254
}
249
255
}
@@ -252,9 +258,11 @@ function pushToWeeksEvents(interaction, event, event_start, event_end, relevantE
252
258
* Check if the new element added to @link{array} creates a duplicate
253
259
* @param {any[] } array array to check
254
260
* @param {any } new_element new element on which to check if duplicate
261
+ * @param {Date } start_date end date of event
262
+ * @param {Date } end_date start date of event
255
263
* @returns {boolean }
256
264
*/
257
- function doubleEntry ( array : any [ ] , new_element : any , start_date , end_date ) : boolean {
265
+ function doubleEntry ( array : any [ ] , new_element : any , start_date : Date , end_date : Date ) : boolean {
258
266
/**
259
267
* Always return false, if array has no entry
260
268
* There are no possible duplicates if there is nothing in the array
0 commit comments