From 93f78fd78fb71c899fd1001d9fa3184d647f6d32 Mon Sep 17 00:00:00 2001 From: wooden_case Date: Fri, 3 May 2024 19:15:43 +0200 Subject: [PATCH 1/3] load subjects from a file --- modules.conf | 8 ++++++++ src/bot.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 modules.conf diff --git a/modules.conf b/modules.conf new file mode 100644 index 0000000..8c6b8e7 --- /dev/null +++ b/modules.conf @@ -0,0 +1,8 @@ +Conception +Hardware +Infrastructure Cloud +Intelligence Artificielle +Robotique +Sécurité +SEPT +Sûreté \ No newline at end of file diff --git a/src/bot.ts b/src/bot.ts index 9e91075..817a576 100755 --- a/src/bot.ts +++ b/src/bot.ts @@ -8,8 +8,12 @@ import { update_loop } from "./lib/board.ts"; import { notification_loop } from "./lib/notification.ts"; import { declare_commands, handle_autocomplete, handle_command } from "./lib/commands/commands.ts"; -const log = log_from(import.meta); +const log = log_from(import.meta); +import * as fs from "node:fs"; +const subjects = fs.readFileSync('/path-to-file', 'utf-8').split('\n'); + +/* const subjects = new Set([ "Conception", "Hardware", @@ -19,7 +23,7 @@ const subjects = new Set([ "Sécurité", "SEPT", "Sûreté", -]); +]);*/ async function main() { const debug_server = Deno.env.get("DEBUG"); From ac2f47f431f3c799c15aa334c5e14696b434987f Mon Sep 17 00:00:00 2001 From: wooden_case Date: Fri, 3 May 2024 20:51:14 +0200 Subject: [PATCH 2/3] Fix path --- src/bot.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 817a576..f42f971 100755 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,7 @@ #!/bin/env -S deno run -A --unstable-kv +import * as fs from "node:fs"; + import { Client } from "npm:discord.js"; import { Storage } from "./lib/storage.ts"; @@ -10,20 +12,7 @@ import { declare_commands, handle_autocomplete, handle_command } from "./lib/com const log = log_from(import.meta); -import * as fs from "node:fs"; -const subjects = fs.readFileSync('/path-to-file', 'utf-8').split('\n'); - -/* -const subjects = new Set([ - "Conception", - "Hardware", - "Infrastructure Cloud", - "Intelligence Artificielle", - "Robotique", - "Sécurité", - "SEPT", - "Sûreté", -]);*/ +const subjects = fs.readFileSync('/modules.conf', 'utf-8').split('\n'); async function main() { const debug_server = Deno.env.get("DEBUG"); From 31d3303df0c9cc95f41052f98b238896bd3f4a00 Mon Sep 17 00:00:00 2001 From: wooden_case Date: Sat, 4 May 2024 09:56:37 +0200 Subject: [PATCH 3/3] Fix types --- src/bot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index f42f971..ce9eb0b 100755 --- a/src/bot.ts +++ b/src/bot.ts @@ -12,7 +12,7 @@ import { declare_commands, handle_autocomplete, handle_command } from "./lib/com const log = log_from(import.meta); -const subjects = fs.readFileSync('/modules.conf', 'utf-8').split('\n'); +const subjects = new Set(fs.readFileSync('/modules.conf', 'utf-8').split('\n')); async function main() { const debug_server = Deno.env.get("DEBUG");