diff --git a/interactions/klausuren.ts b/interactions/klausuren.ts index 586e389..2a0bb4b 100644 --- a/interactions/klausuren.ts +++ b/interactions/klausuren.ts @@ -179,10 +179,10 @@ function pushToWeeksEvents(interaction, event, relevantEvents) { } exports.Command = async (client: DiscordClient, interaction: DiscordCommandInteraction): Promise => { + await interaction.deferReply({ ephemeral: true }) const now = new Date() const embed = await klausuren(client, interaction, now, 'all') - interaction.deferReply() await interaction.editReply({ embeds: [embed], }) diff --git a/interactions/mensa.ts b/interactions/mensa.ts index 7a0ce62..5a042d5 100644 --- a/interactions/mensa.ts +++ b/interactions/mensa.ts @@ -145,7 +145,7 @@ const weekdayOptions = { so: new Weekday('Sonntag', 6), } -function _updateJson(client: DiscordClient): Promise { +export function _updateJson(client: DiscordClient): Promise { return new Promise((resolve, reject) => { /** * Fancy API stuff and user credential hashing diff --git a/interactions/wochenplan.ts b/interactions/wochenplan.ts index 612ba56..90324a5 100644 --- a/interactions/wochenplan.ts +++ b/interactions/wochenplan.ts @@ -292,12 +292,12 @@ function doubleEntry(array: any[], new_element: any, start_date: Date, end_date: } exports.Command = async (client: DiscordClient, interaction: DiscordCommandInteraction): Promise => { + await interaction.deferReply({ ephemeral: true }) const option = interaction.options.getString('datum')?.split('.') const option_date = option ? new Date(`${option[2]}-${option[1]}-${option[0]}T00:00:00`) : new Date() const valid_date = option_date.toString() !== 'Invalid Date' const date = JSON.stringify(option_date) === 'null' ? new Date() : option_date - interaction.deferReply({ ephemeral: true }) const embed = await wochenplan(client, interaction, date, 'all') if (!valid_date) { diff --git a/package.json b/package.json index 23b1e49..f022f74 100644 --- a/package.json +++ b/package.json @@ -11,17 +11,17 @@ "homepage": "https://github.com/Chr1s70ph/ETIT-Master-JS#readme", "author": "Christoph Bluem", "dependencies": { - "@discordjs/builders": "^0.13.0", - "@discordjs/rest": "^0.4.1", - "discord-api-types": "^0.33.0", - "discord.js": "^13.7.0", + "@discordjs/builders": "^0.15.0", + "@discordjs/rest": "^0.5.0", + "discord-api-types": "^0.36.0", + "discord.js": "^13.8.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-prettier": "^4.2.1", "fs": "^0.0.1-security", "github-create-issue": "^1.0.1", "https": "^1.0.0", - "i18next": "^21.8.2", + "i18next": "^21.8.11", "i18next-fs-backend": "^1.1.4", "luxon": "^2.4.0", "moment": "^2.29.3", @@ -35,8 +35,8 @@ "valid-url": "^1.0.9" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.24.0", - "@typescript-eslint/parser": "^5.24.0", - "eslint": "^8.15.0" + "@typescript-eslint/eslint-plugin": "^5.30.0", + "@typescript-eslint/parser": "^5.30.0", + "eslint": "^8.18.0" } } diff --git a/scripts/addCommands.ts b/scripts/addCommands.ts index 162282a..4b652c1 100644 --- a/scripts/addCommands.ts +++ b/scripts/addCommands.ts @@ -3,7 +3,7 @@ import { readdir as promiseReaddir } from 'fs/promises' import { REST } from '@discordjs/rest' import { TextChannel } from 'discord.js' import { scheduleJob } from 'node-schedule' -import { mensa, getWeekday } from '../interactions/mensa' +import { mensa, getWeekday, _updateJson } from '../interactions/mensa' import { DiscordClient } from '../types/customTypes' const { Routes } = require('discord-api-types/v9') @@ -145,6 +145,11 @@ async function postSlashCommands(client, slashCommandData) { */ async function mensa_automation(client: DiscordClient) { await scheduleJob('0 5 * * 1-5', async () => { + /** + * Fetch latest updates of mensaplan + */ + _updateJson(client) + const today = new Date() const weekday = today.getHours() >= 16 ? getWeekday(today.getDay()) : getWeekday(today.getDay() - 1) diff --git a/scripts/iCalReader.ts b/scripts/iCalReader.ts index 699d083..54e73ba 100644 --- a/scripts/iCalReader.ts +++ b/scripts/iCalReader.ts @@ -397,7 +397,7 @@ function rruleFilter( showRecurrence = false } - if (showRecurrence === true && datesAreOnSameDay(date, today)) { + if (showRecurrence === true) { /** * Add event to todays {@link events}. */