Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebase #190

Merged
merged 9 commits into from
Jul 1, 2022
2 changes: 1 addition & 1 deletion interactions/klausuren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ function pushToWeeksEvents(interaction, event, relevantEvents) {
}

exports.Command = async (client: DiscordClient, interaction: DiscordCommandInteraction): Promise<void> => {
await interaction.deferReply({ ephemeral: true })
const now = new Date()
const embed = await klausuren(client, interaction, now, 'all')

interaction.deferReply()
await interaction.editReply({
embeds: [embed],
})
Expand Down
2 changes: 1 addition & 1 deletion interactions/mensa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const weekdayOptions = {
so: new Weekday('Sonntag', 6),
}

function _updateJson(client: DiscordClient): Promise<string> {
export function _updateJson(client: DiscordClient): Promise<string> {
return new Promise((resolve, reject) => {
/**
* Fancy API stuff and user credential hashing
Expand Down
2 changes: 1 addition & 1 deletion interactions/wochenplan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ function doubleEntry(array: any[], new_element: any, start_date: Date, end_date:
}

exports.Command = async (client: DiscordClient, interaction: DiscordCommandInteraction): Promise<void> => {
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) {
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
7 changes: 6 additions & 1 deletion scripts/addCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion scripts/iCalReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function rruleFilter(
showRecurrence = false
}

if (showRecurrence === true && datesAreOnSameDay(date, today)) {
if (showRecurrence === true) {
/**
* Add event to todays {@link events}.
*/
Expand Down