From 5eef91224ed922e1debd90d85c2e74d09a65b4b1 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:57:40 +0200 Subject: [PATCH 01/20] Create access_token.json --- bot/pl/access_token.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 bot/pl/access_token.json diff --git a/bot/pl/access_token.json b/bot/pl/access_token.json new file mode 100644 index 0000000..a7cebc7 --- /dev/null +++ b/bot/pl/access_token.json @@ -0,0 +1,4 @@ +{ + "1": "Administrator", + "2": "Podstawowy" +} From b8c813affb08c8f0c1394e1a67ebd86f7f34327a Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:58:59 +0200 Subject: [PATCH 02/20] Create channel_update_types.json --- bot/pl/channel_update_types.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bot/pl/channel_update_types.json diff --git a/bot/pl/channel_update_types.json b/bot/pl/channel_update_types.json new file mode 100644 index 0000000..fc86bc4 --- /dev/null +++ b/bot/pl/channel_update_types.json @@ -0,0 +1,3 @@ +{ + "none": "brak" +} From 29abfbe6a521e243ddda356ac2863e583dd63380 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:00:12 +0200 Subject: [PATCH 03/20] Create emoji_update_types.json --- bot/pl/emoji_update_types.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bot/pl/emoji_update_types.json diff --git a/bot/pl/emoji_update_types.json b/bot/pl/emoji_update_types.json new file mode 100644 index 0000000..fc86bc4 --- /dev/null +++ b/bot/pl/emoji_update_types.json @@ -0,0 +1,3 @@ +{ + "none": "brak" +} From b9c698c4d4eb0381d11df9a6c0df9058bd91737e Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:00:45 +0200 Subject: [PATCH 04/20] Create ignore_options.json --- bot/pl/ignore_options.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 bot/pl/ignore_options.json diff --git a/bot/pl/ignore_options.json b/bot/pl/ignore_options.json new file mode 100644 index 0000000..2dac85c --- /dev/null +++ b/bot/pl/ignore_options.json @@ -0,0 +1,12 @@ +{ + "ignoreTargets": "Ignoruj użytkowników docelowych", + "ignoreExecutors": "Ignoruj wykonawców", + "specificMessageContent": "Ignoruj konkretną treść wiadomości", + "ignoreChannels": "Ignoruj kanały", + "ignoreBotExecutors": "Ignoruj działania botów", + "ignoreBotTargets": "Ignoruj cele botów", + "ignoreExecutorRoles": "Ignoruj role wykonawców", + "ignoreTargetRoles": "Ignoruj role docelowe", + "ignoreCategories": "Ignoruj kategorie", + "activeIgnore": "Aktywne ignorowanie" +} From fa88766659ca6b8af3b306b97d2993826f8a9a88 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:01:24 +0200 Subject: [PATCH 05/20] Create log_categories.json --- bot/pl/log_categories.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bot/pl/log_categories.json diff --git a/bot/pl/log_categories.json b/bot/pl/log_categories.json new file mode 100644 index 0000000..0452668 --- /dev/null +++ b/bot/pl/log_categories.json @@ -0,0 +1,13 @@ +{ + "serverEvents": "Członkowie", + "serverActions": "Akcje", + "textEvents": "Wiadomości", + "voiceEvents": "Głosowe", + "fileEvents": "Pliki", + "generalEvents": "Serwer", + "roleEvents": "Role", + "channelEvents": "Kanały", + "quarkEvents": "Konfiguracja quark'a", + "modLog": "Dzienniki moderacji", + "main": "Głowne" +} From df4d273dcac8be3cf00c6cf6518f6e99f0e9b4c6 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:01:55 +0200 Subject: [PATCH 06/20] Create log_formats.json --- bot/pl/log_formats.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bot/pl/log_formats.json diff --git a/bot/pl/log_formats.json b/bot/pl/log_formats.json new file mode 100644 index 0000000..cb4c176 --- /dev/null +++ b/bot/pl/log_formats.json @@ -0,0 +1,7 @@ +{ + "0": "Standardowe", + "1": "Kompaktowe", + "2": "Standardowe (brak osadzenia)", + "3": "Kompaktowe (brak osadzenia)", + "4": "pliki json" +} From 7e825344bbde69fa6ba3d89f075da3438bb682c6 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:04:51 +0200 Subject: [PATCH 07/20] Create dashboard.json --- bot/pl/slash_commands/dashboard.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 bot/pl/slash_commands/dashboard.json diff --git a/bot/pl/slash_commands/dashboard.json b/bot/pl/slash_commands/dashboard.json new file mode 100644 index 0000000..f84d0e4 --- /dev/null +++ b/bot/pl/slash_commands/dashboard.json @@ -0,0 +1,4 @@ +{ + "name": "dashboard", + "description": "Odwiedź panel zarządzania quark'a" +} From 60ecfd635a875d17d513a9098ad8827c1a98a130 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:05:33 +0200 Subject: [PATCH 08/20] Create initialReactor.json --- bot/pl/slash_commands/initialReactor.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bot/pl/slash_commands/initialReactor.json diff --git a/bot/pl/slash_commands/initialReactor.json b/bot/pl/slash_commands/initialReactor.json new file mode 100644 index 0000000..6c85e0c --- /dev/null +++ b/bot/pl/slash_commands/initialReactor.json @@ -0,0 +1,3 @@ +{ + "name": "Zobacz pierwotnych reagujących" +} From 8e59f2d99da6ed92134d57a830f58f0cc33864c9 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:06:03 +0200 Subject: [PATCH 09/20] Create premium.json --- bot/pl/slash_commands/premium.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 bot/pl/slash_commands/premium.json diff --git a/bot/pl/slash_commands/premium.json b/bot/pl/slash_commands/premium.json new file mode 100644 index 0000000..c3e2c8e --- /dev/null +++ b/bot/pl/slash_commands/premium.json @@ -0,0 +1,4 @@ +{ + "name": "premium", + "description": "Zdobądź informacje na temat subskrybcji premium quark'a" +} From ff8ce900e1858eeafbdd53dffcbba790658e2395 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:06:42 +0200 Subject: [PATCH 10/20] Create quarkEvents.json --- bot/pl/standard/quarkEvents.json | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 bot/pl/standard/quarkEvents.json diff --git a/bot/pl/standard/quarkEvents.json b/bot/pl/standard/quarkEvents.json new file mode 100644 index 0000000..285710e --- /dev/null +++ b/bot/pl/standard/quarkEvents.json @@ -0,0 +1,64 @@ +{ + "serverlogChannelUpdate": { + "title": "Kanał logowania zmieniony", + "description_set": "{executor} ustawił kanał logowania dla typu {type} na {channel}", + "description_category_disable": "{executor} wyłączył kanał logowania dla typu {type}", + "description_unset": "{executor} usunął kanał logowania dla typu {type}" + }, + "serverlogOptionsUpdate": { + "title": "Opcje logowania zaktualizowane", + "description": "{executor} ustawił {option} na {state}", + "pluralkitSupport": "Wsparcie dla PluralKit", + "spoilers": "Spoilery", + "buttons": "Przyciski", + "formatType": "Typ formatu" + }, + "serverlogLogUpdate": { + "title": "Log zaktualizowany", + "description": "{executor} zaktualizował log typu {type}", + "enabled": "Włączone", + "logFormat": "Format", + "logChannel": "Kanał", + "colour": "Kolor", + "ignoreBotExecutors": "Ignoruj działania botów", + "ignoreBotTargets": "Ignoruj cele botów", + "activeIgnore": "Aktywne ignorowanie" + }, + "serverlogIgnoreUpdate": { + "title": "Opcje ignorowania zaktualizowane", + "description_set": "{executor} włączył {type}", + "description_unset": "{executor} wyłączył {type}", + "description_added": "{executor} dodał {target} do {type}", + "description_removed": "{executor} usunął {target} z {type}" + }, + "languageUpdate": { + "title": "Język zmieniony", + "description": "{executor} zmienił język na {language}" + }, + "reset": { + "title": "Konfiguracja zresetowana", + "description": "{executor} zresetował konfigurację tego serwera" + }, + "tagAdded": { + "title": "Tag dodany", + "description": "{executor} utworzył tag {tag}" + }, + "tagUpdated": { + "title": "Tag zaktualizowany", + "description": "{executor} zaktualizował tag {tag}" + }, + "tagDeleted": { + "title": "Tag usunięty", + "description": "{executor} usunął tag {tag}" + }, + "tokenAdded": { + "title": "Token wygenerowany", + "description": "{executor} wygenerował token dostępu quark'a z uprawnieniami {permissions} dla tego serwera", + "unique_id": "ID tokena", + "revoke": "Unieważnij ten token" + }, + "tokenRevoked": { + "title": "Token unieważniony", + "description": "{executor} unieważnił token dostępu quark'a o ID {token}" + } +} From e5c93169dd2833f8214b9ebbd92ab8a679210ec7 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:10:21 +0200 Subject: [PATCH 11/20] Create time.json --- bot/pl/time.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bot/pl/time.json diff --git a/bot/pl/time.json b/bot/pl/time.json new file mode 100644 index 0000000..f759066 --- /dev/null +++ b/bot/pl/time.json @@ -0,0 +1,16 @@ +{ + "second": "{time} sekunda", + "second-plural": "{time} sekundy", + "minute": "{time} minuta", + "minute-plural": "{time} minuty", + "hour": "{time} godzina", + "hour-plural": "{time} godziny", + "day": "{time} dzień", + "day-plural": "{time} dni", + "week": "{time} tydzień", + "week-plural": "{time} tygodnie", + "month": "{time} miesiąc", + "month-plural": "{time} miesiące", + "year": "{time} rok", + "year-plural": "{time} lata" +} From c65bee7cf704e3301fca92a126ddddbb6595dac1 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:14:14 +0200 Subject: [PATCH 12/20] Update command_responses.json --- bot/pl/command_responses.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot/pl/command_responses.json b/bot/pl/command_responses.json index fa2efae..83155a7 100644 --- a/bot/pl/command_responses.json +++ b/bot/pl/command_responses.json @@ -104,6 +104,8 @@ "setserverlog-type-channels-1": "wydarzenia kanału", "setserverlog-type-modlogs-0": "Modlogi", "setserverlog-type-modlogs-1": "modlogi", + "setserverlog-type-modlogs-0": "Modlogi", + "setserverlog-type-modlogs-1": "modlogi", "setserverlog-spoilers": "Spojlery", "setserverlog-spoilers-0": "Spojlery serverlog ustawione na {result}", "setserverlog-enable-status-updates": "Włącz aktualizacje statusu!", @@ -158,6 +160,9 @@ "need-to-vote": "Kliknij tutaj, aby zagłosować", "need-to-vote-footer": "Głosy są rejestrowane do minuty", + "initialreactors-expired": "wykasły", + "initialreactors-notfound": "Nie znaleziono żadnych reakcji", + "configCommand": { "title": "Konfiguracja Serverlog", "selection": "Wybierz kategorię w menu, aby wyświetlić konfigurację.", @@ -211,4 +216,4 @@ } } } -} \ No newline at end of file +} From 116eda0ec64a4b3b5919e26195186bbcc2fca0e1 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:20:05 +0200 Subject: [PATCH 13/20] Update gui_constants.json --- bot/pl/gui_constants.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot/pl/gui_constants.json b/bot/pl/gui_constants.json index 2a3b92e..220c329 100644 --- a/bot/pl/gui_constants.json +++ b/bot/pl/gui_constants.json @@ -33,5 +33,9 @@ "explicit_content_filter": "Filtr zawartości jawnej", "nsfw_level": "Poziom NSFW", "premium_progress_bar_enabled": "Pasek postępu" + }, + "webhookModificationTypes": { + "name": "Nazwa", + "channel_id": "Kanał" } -} \ No newline at end of file +} From dfe4d5570e9614809b4aab4c7b22aec2fccd7238 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:28:14 +0200 Subject: [PATCH 14/20] Update channelEvents.json --- bot/pl/standard/channelEvents.json | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bot/pl/standard/channelEvents.json b/bot/pl/standard/channelEvents.json index 9df6eb9..30299d8 100644 --- a/bot/pl/standard/channelEvents.json +++ b/bot/pl/standard/channelEvents.json @@ -26,5 +26,37 @@ "description": "{executor} zaktualizował uprawnienia dla {channel} dla {special}", "newPermissions": "Nowe Uprawnienia", "viewFullNewPermissions": "Zobacz Pełne Nowe Uprawnienia" + }, + "webhookCreate": { + "title": "Integracja Utworzona", + "description": "{executor} utworzył Integracja {webhook} na kanale {channel}" + }, + "webhookDelete": { + "title": "Integracja Usunieta", + "description": "{executor} usuną integrację {webhook}" + }, + "webhookUpdate": { + "title": "Integracja Zmodyfikowana", + "description": "{executor} zmodyfikował integrację {webhook}" + }, + "webhookAvatarUpdate": { + "title": "Zaktualizowany Awatar Integracji", + "description": "{executor} zaktualizował awatar dla integracji {webhook}", + "description_added": "{executor} dodał awatar dla integracji {webhook}", + "description_removed": "{executor} usuną awatar dla integracji {webhook}", + "linkToOldAvatar": "Link do starego awataru", + "linkToNewAvatar": "Link do nowego awataru" + }, + "statusChannelFollowed": { + "title": "Obserwowany Kanał", + "description": "{executor} zaczą obserwować kanał {name} w {channel}" + }, + "statusChannelUnfollowed": { + "title": "Nieobserwowany Kanał", + "description": "{executor} przestał obserwować kanał {name}" + }, + "statusChannelUpdated": { + "title": "Aktualizacja Obserwowanego Kanału", + "description": "{executor} zaktualizował obserwowany kanał {name}" } } From f4fc1d5ef22f5a75f98d7ab952dfd8d258375b4d Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:33:36 +0200 Subject: [PATCH 15/20] Update generalEvents.json --- bot/pl/standard/generalEvents.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bot/pl/standard/generalEvents.json b/bot/pl/standard/generalEvents.json index 5241fc4..8773bc1 100644 --- a/bot/pl/standard/generalEvents.json +++ b/bot/pl/standard/generalEvents.json @@ -10,5 +10,21 @@ "description_removed": "{executor} usunął ikonę serwera", "linkToOldIcon": "Link do starej ikony", "linkToNewIcon": "Link do nowej ikony" + }, + "serverBoostAdd": { + "title": "Serwer Został Zboostowany!", + "description": "{user} zboostował serwer 🎉", + "description_noUser": "Ktoś zboostował serwer 🎉", + "description_withTier": "{user} zboostował serwer do tieru {tier} 🎉", + "description_withTier_noUser": "Ktoś zboostował serwer do tieru {tier} 🎉", + "none": "brak" + }, + "serverBoostRemove": { + "title": "Serwer Przestał Być Boostowany", + "description": "{user} przestał boostować ten serwer", + "description_noUser": "Ktoś przestał boostować ten serwer", + "description_withTier": "{user} przestał boostować, powodując spadek serwera do tieru {tier}", + "description_withTier_noUser": "Ktoś przestał boostować, powodując spadek serwera do tieru {tier}", + "none": "brak" } } From 489999ca1fde7ac31ac1400211a762b23e7c1332 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:35:37 +0200 Subject: [PATCH 16/20] Update modlog.json --- bot/pl/standard/modlog.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bot/pl/standard/modlog.json b/bot/pl/standard/modlog.json index 0af8694..5cef75d 100644 --- a/bot/pl/standard/modlog.json +++ b/bot/pl/standard/modlog.json @@ -14,5 +14,11 @@ "timeoutEnds": "Przerwa kończy się {time}", - "editReason": "Edytuj powód" -} \ No newline at end of file + "editReason": "Edytuj powód", + + "reasonModal": { + "label": "Powód", + "placeholder": "Bardzo złe zachowanie >:(", + "title": "Zmodyfikuj powód w modlogu" + } +} From 331737272151de4538afdee1321d472df8d72e27 Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:40:02 +0200 Subject: [PATCH 17/20] Update serverActions.json --- bot/pl/standard/serverActions.json | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bot/pl/standard/serverActions.json b/bot/pl/standard/serverActions.json index 934090d..e473535 100644 --- a/bot/pl/standard/serverActions.json +++ b/bot/pl/standard/serverActions.json @@ -27,5 +27,26 @@ "emojiUpdated": { "title": "Edytowano emotkę", "description": "{emoji} została edytowana przez {executor}" + }, + "serverEventCreate": { + "title": "Wydarzenie Utworzone", + "description_withChannel": "{executor} utworzył wydarzenie {name} w kanale {channel}", + "description_withoutChannel": "{executor} utworzył wydarzenie {name}", + "eventDescription": "Opis", + "location": "Lokalizacja", + "starts": "Rozpoczęcie" + }, + "serverEventDelete": { + "title": "Wydarzenie Usunięte", + "description": "{executor} usuną wydarzenie {name}", + "linkToEventImage": "Link obrazu wydarzenia" + }, + "serverEventUpdate": { + "title": "Wydarzenie Zmodifikowane", + "description": "{executor} zmodyfikował wydarzenie {name}", + "newEventDescription": "Nowy Opis", + "newLocation": "Nowa Lokalizacja", + "newChannel": "Nowy Kanał", + "linkToEventImage": "Link do starego obrazu wydarzenia" } -} \ No newline at end of file +} From 294eb868aed2f905a6e0603ad6bba94d6d627edd Mon Sep 17 00:00:00 2001 From: lis0ownik <97831192+lis0ownik@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:42:46 +0200 Subject: [PATCH 18/20] Update voiceEvents.json --- bot/pl/standard/voiceEvents.json | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/bot/pl/standard/voiceEvents.json b/bot/pl/standard/voiceEvents.json index 526a606..885c976 100644 --- a/bot/pl/standard/voiceEvents.json +++ b/bot/pl/standard/voiceEvents.json @@ -67,5 +67,36 @@ "description": "{executor} ustawił status dla kanału {channel}", "status": "Status", "linksToEmojis": "Linki do emoji" + }, + "stageStarted": { + "title": "Rozpoczęto Scenę", + "description": "{executor} rozpoczął scenę w kanale {channel}", + "topic": "Temat" + }, + "stageEnded": { + "title": "Zakończono Scenę", + "description": "Scena w kanale {channel} została zakończona przez {executor}", + "description_noExecutor": "Scena w kanale {channel} została zakończona", + "topic": "Temat", + "none": "brak" + }, + "stageUpdated": { + "title": "Zaktualizowano Scenę", + "description": "Scena w kanale {channel} została zaktualizowana przez {executor}", + "oldTopic": "Stary Temat", + "newTopic": "Nowy Temat" + }, + "stageSpeakerAdd": { + "title": "Nowy Mówca na Scenie", + "description": "{user} został mówcą na kanale sceny {channel}", + "description_inviteAccepted": "{user} zaakceptował zaproszenie do zostania mówcą na kanale sceny {channel}" + }, + "stageSpeakerRemove": { + "title": "Zakończono Mówienie", + "description": "{user} nie jest już mówcą na kanale sceny {channel}" + }, + "stageSpeakerInvited": { + "title": "Zaproszono Mówcę", + "description": "{user} został zaproszony do mówienia na kanale sceny {channel}" } -} \ No newline at end of file +} From 59779bfdeaffeb30a94e954785d4a7d07d07bbbd Mon Sep 17 00:00:00 2001 From: Starman <30315137+Starman3787@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:36:09 +0100 Subject: [PATCH 19/20] convert to ESM --- activate.js | 174 +++++++++++++++++++++++++++++---------------------- index.js | 6 +- package.json | 20 ++++++ 3 files changed, 121 insertions(+), 79 deletions(-) create mode 100644 package.json diff --git a/activate.js b/activate.js index 381cd1b..f799472 100644 --- a/activate.js +++ b/activate.js @@ -1,95 +1,121 @@ -const fs = require('fs'); -const path = require('path'); +import fs from "fs"; +import path from "path"; const fallbackLanguage = "en_us"; const baseDirectory = "bot"; -const languages = require('./bot/languages.json'); +import languages from "./bot/languages.json" with { type: "json" }; const languagesLocation = path.join(process.cwd(), "languages", baseDirectory); -const activeLanguagesLocation = path.join(process.cwd(), "languages", "active", baseDirectory); +const activeLanguagesLocation = path.join( + process.cwd(), + "languages", + "active", + baseDirectory +); // relative file path is the path after the locale directory function loadFile(locale, relativeFilePath) { - - const filePath = path.join(languagesLocation, locale, relativeFilePath); - - try { - let data; - if (!fs.existsSync(filePath)) - data = "{}"; - else - data = fs.readFileSync(filePath, 'utf8'); - const jsonData = JSON.parse(data); - const fallbackLanguageData = JSON.parse(fs.readFileSync(path.join(languagesLocation, fallbackLanguage, relativeFilePath), 'utf8')); - function checkFields(obj, path = '') { - Object.keys(obj).forEach(key => { - const value = obj[key]; - const currentPath = path ? `${path}.${key}` : key; - - if (typeof value === 'string') { - let pointer = fallbackLanguageData; - const structPath = currentPath.split("."); - for (let i = 0; i < structPath.length - 1; i++) { - pointer = pointer[structPath[i]]; - } - pointer[structPath[structPath.length - 1]] = value; - } else if (typeof value === 'object' && value !== null) { - checkFields(value, currentPath); - } - }); + const filePath = path.join(languagesLocation, locale, relativeFilePath); + + try { + let data; + if (!fs.existsSync(filePath)) data = "{}"; + else data = fs.readFileSync(filePath, "utf8"); + const jsonData = JSON.parse(data); + const fallbackLanguageData = JSON.parse( + fs.readFileSync( + path.join(languagesLocation, fallbackLanguage, relativeFilePath), + "utf8" + ) + ); + function checkFields(obj, path = "") { + Object.keys(obj).forEach((key) => { + const value = obj[key]; + const currentPath = path ? `${path}.${key}` : key; + + if (typeof value === "string") { + let pointer = fallbackLanguageData; + const structPath = currentPath.split("."); + for (let i = 0; i < structPath.length - 1; i++) { + pointer = pointer[structPath[i]]; + } + pointer[structPath[structPath.length - 1]] = value; + } else if (typeof value === "object" && value !== null) { + checkFields(value, currentPath); } - - checkFields(jsonData); - - const absolutePathToActiveSubdirectory = path.join(activeLanguagesLocation, locale, relativeFilePath); - - if (!fs.existsSync(path.dirname(absolutePathToActiveSubdirectory))) - fs.mkdirSync(path.dirname(absolutePathToActiveSubdirectory), { recursive: true }); - - fs.writeFileSync(absolutePathToActiveSubdirectory, JSON.stringify(fallbackLanguageData), { recursive: true }); - - } catch (err) { - console.error(`Error processing ${filePath}:`, err); - foundErrors = true; + }); } + checkFields(jsonData); + + const absolutePathToActiveSubdirectory = path.join( + activeLanguagesLocation, + locale, + relativeFilePath + ); + + if (!fs.existsSync(path.dirname(absolutePathToActiveSubdirectory))) + fs.mkdirSync(path.dirname(absolutePathToActiveSubdirectory), { + recursive: true, + }); + + fs.writeFileSync( + absolutePathToActiveSubdirectory, + JSON.stringify(fallbackLanguageData), + { recursive: true } + ); + } catch (err) { + console.error(`Error processing ${filePath}:`, err); + foundErrors = true; + } } function loadSubdirectory(locale, relativePath) { - const absolutePath = path.join(languagesLocation, fallbackLanguage, relativePath); - const subdirectories = fs.readdirSync(absolutePath, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name); - const subfiles = fs.readdirSync(absolutePath, { withFileTypes: true }) - .filter(dirent => !dirent.isDirectory()) - .map(dirent => dirent.name); - for (let i = 0; i < subdirectories.length; i++) { - const subdirectoryPath = path.join(relativePath, subdirectories[i]); - loadSubdirectory(locale, subdirectoryPath); - } - for (let i = 0; i < subfiles.length; i++) { - const filePath = path.join(relativePath, subfiles[i]); - loadFile(locale, filePath); - } + const absolutePath = path.join( + languagesLocation, + fallbackLanguage, + relativePath + ); + const subdirectories = fs + .readdirSync(absolutePath, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name); + const subfiles = fs + .readdirSync(absolutePath, { withFileTypes: true }) + .filter((dirent) => !dirent.isDirectory()) + .map((dirent) => dirent.name); + for (let i = 0; i < subdirectories.length; i++) { + const subdirectoryPath = path.join(relativePath, subdirectories[i]); + loadSubdirectory(locale, subdirectoryPath); + } + for (let i = 0; i < subfiles.length; i++) { + const filePath = path.join(relativePath, subfiles[i]); + loadFile(locale, filePath); + } } function activate() { - Object.entries(languages).forEach(([key, value]) => { - const directory = path.join(process.cwd(), "languages", baseDirectory, value); - console.log(`Processing language code ${key}...`); - if (!fs.existsSync(directory)) { - console.log(`Skipping non-existent directory: ${directory} for language code ${key}`); - return; - } - - if (!fs.existsSync(activeLanguagesLocation)) - fs.mkdirSync(activeLanguagesLocation, { recursive: true }); - - console.log(`Copying ${directory}...`); - loadSubdirectory(value, "/"); + Object.entries(languages).forEach(([key, value]) => { + const directory = path.join( + process.cwd(), + "languages", + baseDirectory, + value + ); + console.log(`Processing language code ${key}...`); + if (!fs.existsSync(directory)) { + console.log( + `Skipping non-existent directory: ${directory} for language code ${key}` + ); + return; + } - }); + if (!fs.existsSync(activeLanguagesLocation)) + fs.mkdirSync(activeLanguagesLocation, { recursive: true }); + console.log(`Copying ${directory}...`); + loadSubdirectory(value, "/"); + }); } -module.exports = activate; \ No newline at end of file +export default activate; diff --git a/index.js b/index.js index 808a358..8c40dd9 100644 --- a/index.js +++ b/index.js @@ -1,5 +1 @@ -const activate = require("./activate"); - -module.exports = { - activate -}; \ No newline at end of file +export { default as activate } from "./activate.js"; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..05f6a46 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "languages", + "version": "1.0.0", + "description": "Languages for Quark", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/quark-bot-discord/languages.git" + }, + "author": "Quark", + "license": "MIT", + "bugs": { + "url": "https://github.com/quark-bot-discord/languages/issues" + }, + "homepage": "https://github.com/quark-bot-discord/languages#readme" +} From af86b403f156c27f4068b586c4ea4541d9568459 Mon Sep 17 00:00:00 2001 From: Starman <30315137+Starman3787@users.noreply.github.com> Date: Sat, 14 Sep 2024 13:37:53 +0100 Subject: [PATCH 20/20] convert scripts to esm --- .github/scripts/compare-languages.js | 132 +++++++++------- .github/scripts/validate-json.js | 60 +++---- .github/scripts/validate-slash_commands.js | 176 ++++++++++++--------- 3 files changed, 207 insertions(+), 161 deletions(-) diff --git a/.github/scripts/compare-languages.js b/.github/scripts/compare-languages.js index fcb1f4c..8e3f742 100644 --- a/.github/scripts/compare-languages.js +++ b/.github/scripts/compare-languages.js @@ -1,74 +1,92 @@ -const fs = require('fs'); -const path = require('path'); +import { readFileSync, readdirSync, statSync } from "fs"; +import { join, relative } from "path"; function readJson(filePath) { - const rawData = fs.readFileSync(filePath, 'utf8'); - return JSON.parse(rawData); + const rawData = readFileSync(filePath, "utf8"); + return JSON.parse(rawData); } function getAllJsonFiles(directory) { - let jsonFiles = []; - const files = fs.readdirSync(directory); - - files.forEach(file => { - const fullPath = path.join(directory, file); - if (fs.statSync(fullPath).isDirectory()) { - jsonFiles = jsonFiles.concat(getAllJsonFiles(fullPath)); - } else if (file.endsWith('.json')) { - jsonFiles.push(fullPath); - } - }); - - return jsonFiles; + let jsonFiles = []; + const files = readdirSync(directory); + + files.forEach((file) => { + const fullPath = join(directory, file); + if (statSync(fullPath).isDirectory()) { + jsonFiles = jsonFiles.concat(getAllJsonFiles(fullPath)); + } else if (file.endsWith(".json")) { + jsonFiles.push(fullPath); + } + }); + + return jsonFiles; } function compareJsonFiles(enUsDir, otherLangDir) { - const enUsFiles = getAllJsonFiles(enUsDir); - const otherLangFiles = getAllJsonFiles(otherLangDir); - - const enUsFilesRelative = enUsFiles.map(file => path.relative(enUsDir, file)); - const otherLangFilesRelative = otherLangFiles.map(file => path.relative(otherLangDir, file)); - - const missingFiles = enUsFilesRelative.filter(file => !otherLangFilesRelative.includes(file)); - - const missingKeys = {}; - - enUsFilesRelative.forEach(file => { - if (otherLangFilesRelative.includes(file)) { - const enUsJson = readJson(path.join(enUsDir, file)); - const otherLangJson = readJson(path.join(otherLangDir, file)); - - const missingKeysInFile = Object.keys(enUsJson).filter(key => !otherLangJson.hasOwnProperty(key)); - if (missingKeysInFile.length > 0) { - missingKeys[file] = missingKeysInFile; - } - } - }); - - return { missingFiles, missingKeys }; + const enUsFiles = getAllJsonFiles(enUsDir); + const otherLangFiles = getAllJsonFiles(otherLangDir); + + const enUsFilesRelative = enUsFiles.map((file) => relative(enUsDir, file)); + const otherLangFilesRelative = otherLangFiles.map((file) => + relative(otherLangDir, file) + ); + + const missingFiles = enUsFilesRelative.filter( + (file) => !otherLangFilesRelative.includes(file) + ); + + const missingKeys = {}; + + enUsFilesRelative.forEach((file) => { + if (otherLangFilesRelative.includes(file)) { + const enUsJson = readJson(join(enUsDir, file)); + const otherLangJson = readJson(join(otherLangDir, file)); + + const missingKeysInFile = Object.keys(enUsJson).filter( + (key) => !otherLangJson.hasOwnProperty(key) + ); + if (missingKeysInFile.length > 0) { + missingKeys[file] = missingKeysInFile; + } + } + }); + + return { missingFiles, missingKeys }; } function compareAllLanguages(baseDir) { - const enUsDir = path.join(baseDir, 'en_us'); - const languages = fs.readdirSync(baseDir).filter(dir => fs.statSync(path.join(baseDir, dir)).isDirectory() && dir !== 'en_us'); - - const report = {}; - - languages.forEach(lang => { - const langDir = path.join(baseDir, lang); - const { missingFiles, missingKeys } = compareJsonFiles(enUsDir, langDir); - report[lang] = { missingFiles, missingKeys }; - }); - - return report; + const enUsDir = join(baseDir, "en_us"); + const languages = readdirSync(baseDir).filter( + (dir) => statSync(join(baseDir, dir)).isDirectory() && dir !== "en_us" + ); + + const report = {}; + + languages.forEach((lang) => { + const langDir = join(baseDir, lang); + const { missingFiles, missingKeys } = compareJsonFiles(enUsDir, langDir); + report[lang] = { missingFiles, missingKeys }; + }); + + return report; } -const baseDirectory = './bot/'; +const baseDirectory = "./bot/"; const comparisonReport = compareAllLanguages(baseDirectory); for (const [lang, report] of Object.entries(comparisonReport)) { - console.log(`Language: ${lang}`); - console.log(` Missing files: ${report.missingFiles.length > 0 ? report.missingFiles.join(', ') : 'None'}`); - console.log(` Missing keys: ${Object.keys(report.missingKeys).length > 0 ? JSON.stringify(report.missingKeys, null, 2) : 'None'}`); - console.log(); + console.log(`Language: ${lang}`); + console.log( + ` Missing files: ${ + report.missingFiles.length > 0 ? report.missingFiles.join(", ") : "None" + }` + ); + console.log( + ` Missing keys: ${ + Object.keys(report.missingKeys).length > 0 + ? JSON.stringify(report.missingKeys, null, 2) + : "None" + }` + ); + console.log(); } diff --git a/.github/scripts/validate-json.js b/.github/scripts/validate-json.js index ea039b3..f2eb32d 100644 --- a/.github/scripts/validate-json.js +++ b/.github/scripts/validate-json.js @@ -1,43 +1,45 @@ -const fs = require('fs'); -const path = require('path'); +import { readdirSync, statSync, readFileSync } from "fs"; +import { join } from "path"; -const baseDirectory = './bot'; +const baseDirectory = "./bot"; let foundErrors = false; function validateJSONFiles(directory) { - try { - const files = fs.readdirSync(directory); + try { + const files = readdirSync(directory); - files.forEach(file => { - const filePath = path.join(directory, file); - const stat = fs.statSync(filePath); + files.forEach((file) => { + const filePath = join(directory, file); + const stat = statSync(filePath); - if (stat.isDirectory()) { - validateJSONFiles(filePath); - } else if (file.endsWith('.json')) { - console.log(`Validating ${filePath}...`); - try { - const data = fs.readFileSync(filePath, 'utf8'); - JSON.parse(data); - } catch (err) { - console.error(`Error processing ${filePath}: ${err.message}`); - foundErrors = true; - } - } - }); - } catch (err) { - console.error(`Error reading directory ${directory}: ${err.message}`); - process.exit(1); - } + if (stat.isDirectory()) { + validateJSONFiles(filePath); + } else if (file.endsWith(".json")) { + console.log(`Validating ${filePath}...`); + try { + const data = readFileSync(filePath, "utf8"); + JSON.parse(data); + } catch (err) { + console.error(`Error processing ${filePath}: ${err.message}`); + foundErrors = true; + } + } + }); + } catch (err) { + console.error(`Error reading directory ${directory}: ${err.message}`); + process.exit(1); + } } validateJSONFiles(baseDirectory); if (foundErrors) { - console.error("Validation errors found in some JSON files. Please check the logs above."); - process.exit(1); + console.error( + "Validation errors found in some JSON files. Please check the logs above." + ); + process.exit(1); } else { - console.log("All JSON files validated successfully."); - process.exit(0); + console.log("All JSON files validated successfully."); + process.exit(0); } diff --git a/.github/scripts/validate-slash_commands.js b/.github/scripts/validate-slash_commands.js index 34c8cc1..6d24e90 100644 --- a/.github/scripts/validate-slash_commands.js +++ b/.github/scripts/validate-slash_commands.js @@ -1,94 +1,120 @@ -const fs = require('fs'); -const path = require('path'); +import { readFileSync, existsSync, readdirSync } from "fs"; +import { join } from "path"; -const baseDirectory = './bot'; -const conversionFile = './bot/languages.json'; +const baseDirectory = "./bot"; +const conversionFile = "./bot/languages.json"; let foundErrors = false; const nonChatInputCommands = ["initialReactor.json"]; try { - const conversionData = fs.readFileSync(conversionFile, 'utf8'); - const languageMap = JSON.parse(conversionData); + const conversionData = readFileSync(conversionFile, "utf8"); + const languageMap = JSON.parse(conversionData); - Object.entries(languageMap).forEach(([key, value]) => { - const directory = path.join(baseDirectory, value, 'slash_commands'); - if (!fs.existsSync(directory)) { - console.log(`Skipping non-existent directory: ${directory} for language code ${key}`); - return; - } - - const files = fs.readdirSync(directory); - if (files.length === 0) { - console.log(`No JSON files found in ${directory}.`); - return; - } - - files.forEach(file => { - if (!file.endsWith('.json')) { - console.log(`Skipping non-JSON file: ${file}`); - return; - } - - console.log(`Validating ${value}/${file}...`) - const filePath = path.join(directory, file); - try { - const data = fs.readFileSync(filePath, 'utf8'); - const jsonData = JSON.parse(data); + Object.entries(languageMap).forEach(([key, value]) => { + const directory = join(baseDirectory, value, "slash_commands"); + if (!existsSync(directory)) { + console.log( + `Skipping non-existent directory: ${directory} for language code ${key}` + ); + return; + } - function checkFields(obj, path = '') { - Object.keys(obj).forEach(key => { - const value = obj[key]; - const currentPath = path ? `${path}.${key}` : key; + const files = readdirSync(directory); + if (files.length === 0) { + console.log(`No JSON files found in ${directory}.`); + return; + } - if (typeof value === 'string') { + files.forEach((file) => { + if (!file.endsWith(".json")) { + console.log(`Skipping non-JSON file: ${file}`); + return; + } - if (currentPath.endsWith('.description') && value.length > 100) { - console.error(`Validation error: ${directory}/${file}: Description exceeds 100 characters at '${currentPath}'`); - foundErrors = true; - } - if (currentPath.endsWith('.name') && value.match(/^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/gu) == null) { - console.error(`Validation error: ${directory}/${file}: Name does not match regex at '${currentPath}', VALUE: ${value}`); - foundErrors = true; - } - if (value !== value.toLowerCase() && currentPath.endsWith('name')) { - console.error(`Validation error: ${directory}/${file}: Key '${currentPath}' must be lowercase`); - foundErrors = true; - } + console.log(`Validating ${value}/${file}...`); + const filePath = join(directory, file); + try { + const data = readFileSync(filePath, "utf8"); + const jsonData = JSON.parse(data); - } else if (typeof value === 'object' && value !== null) { - checkFields(value, currentPath); - } - }); - } - if (!nonChatInputCommands.includes(file)) { - checkFields(jsonData); + function checkFields(obj, path = "") { + Object.keys(obj).forEach((key) => { + const value = obj[key]; + const currentPath = path ? `${path}.${key}` : key; - if (jsonData.name && jsonData.name.match(/^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/gu) == null) { - console.error(`Validation error: ${directory}/${file}: Name does not match regex, VALUE: ${jsonData.name}`); - foundErrors = true; - } else if (jsonData.description && jsonData.description.length > 100) { - console.error(`Validation error: ${directory}/${file}: Description exceeds 100 characters at 'description'`); - foundErrors = true; - } - } - } catch (err) { - console.error(`Error processing ${file}:`, err); + if (typeof value === "string") { + if (currentPath.endsWith(".description") && value.length > 100) { + console.error( + `Validation error: ${directory}/${file}: Description exceeds 100 characters at '${currentPath}'` + ); + foundErrors = true; + } + if ( + currentPath.endsWith(".name") && + value.match(/^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/gu) == + null + ) { + console.error( + `Validation error: ${directory}/${file}: Name does not match regex at '${currentPath}', VALUE: ${value}` + ); foundErrors = true; + } + if ( + value !== value.toLowerCase() && + currentPath.endsWith("name") + ) { + console.error( + `Validation error: ${directory}/${file}: Key '${currentPath}' must be lowercase` + ); + foundErrors = true; + } + } else if (typeof value === "object" && value !== null) { + checkFields(value, currentPath); } - }); - }); + }); + } + if (!nonChatInputCommands.includes(file)) { + checkFields(jsonData); - if (foundErrors) { - console.error("Validation errors found in some JSON files. Please check the logs above."); - process.exit(1); - } else { - console.log("All files validated successfully."); - process.exit(0); - } + if ( + jsonData.name && + jsonData.name.match( + /^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/gu + ) == null + ) { + console.error( + `Validation error: ${directory}/${file}: Name does not match regex, VALUE: ${jsonData.name}` + ); + foundErrors = true; + } else if ( + jsonData.description && + jsonData.description.length > 100 + ) { + console.error( + `Validation error: ${directory}/${file}: Description exceeds 100 characters at 'description'` + ); + foundErrors = true; + } + } + } catch (err) { + console.error(`Error processing ${file}:`, err); + foundErrors = true; + } + }); + }); -} catch (err) { - console.error("Error reading the conversion file or directory:", err); + if (foundErrors) { + console.error( + "Validation errors found in some JSON files. Please check the logs above." + ); process.exit(1); + } else { + console.log("All files validated successfully."); + process.exit(0); + } +} catch (err) { + console.error("Error reading the conversion file or directory:", err); + process.exit(1); }