@futdevpro/nts-dynamo 1.10.76 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_collections/atlas-default-db-options.const.d.ts +28 -0
- package/build/_collections/atlas-default-db-options.const.d.ts.map +1 -0
- package/build/_collections/atlas-default-db-options.const.js +10 -0
- package/build/_collections/atlas-default-db-options.const.js.map +1 -0
- package/build/_collections/get-environment-settings.util.d.ts +3 -0
- package/build/_collections/get-environment-settings.util.d.ts.map +1 -0
- package/build/_collections/get-environment-settings.util.js +45 -0
- package/build/_collections/get-environment-settings.util.js.map +1 -0
- package/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +9 -4
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/control-models/app-params.control-model.d.ts +6 -0
- package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/app-params.control-model.js +29 -2
- package/build/_models/control-models/app-params.control-model.js.map +1 -1
- package/build/_models/control-models/app-params.control-model.spec.js +5 -4
- package/build/_models/control-models/app-params.control-model.spec.js.map +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/build/_models/interfaces/environment-settings.interface.d.ts +35 -0
- package/build/_models/interfaces/environment-settings.interface.d.ts.map +1 -0
- package/build/_models/interfaces/environment-settings.interface.js +3 -0
- package/build/_models/interfaces/environment-settings.interface.js.map +1 -0
- package/build/_models/interfaces/global-settings.interface.d.ts +34 -2
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_modules/custom-data/index.d.ts.map +1 -1
- package/build/_modules/custom-data/index.js +1 -0
- package/build/_modules/custom-data/index.js.map +1 -1
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts +3 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js +17 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts +18 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js +3 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts +10 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js +41 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +14 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +88 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts +10 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.js +39 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts +8 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.js +23 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +13 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.js +61 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -0
- package/build/_modules/discord-assistant/index.d.ts +10 -0
- package/build/_modules/discord-assistant/index.d.ts.map +1 -0
- package/build/_modules/discord-assistant/index.js +23 -0
- package/build/_modules/discord-assistant/index.js.map +1 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts +4 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js +8 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js.map +1 -0
- package/build/_modules/discord-assistant-voiced/index.d.ts +3 -0
- package/build/_modules/discord-assistant-voiced/index.d.ts.map +1 -0
- package/build/_modules/discord-assistant-voiced/index.js +26 -0
- package/build/_modules/discord-assistant-voiced/index.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts +3 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js +13 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts +3 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js +44 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts +22 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.js +261 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts +8 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts +7 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts +6 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js.map +1 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts +88 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js +3 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts +12 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.js +72 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts +19 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.js +176 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts +85 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.js +228 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +13 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +38 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.js.map +1 -0
- package/build/_modules/discord-bot/index.d.ts +12 -0
- package/build/_modules/discord-bot/index.d.ts.map +1 -0
- package/build/_modules/discord-bot/index.js +30 -0
- package/build/_modules/discord-bot/index.js.map +1 -0
- package/build/_modules/oauth2/index.d.ts.map +1 -1
- package/build/_modules/oauth2/index.js +7 -0
- package/build/_modules/oauth2/index.js.map +1 -1
- package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts +74 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.js +385 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-document.util.d.ts +4 -0
- package/build/_modules/open-ai/_collections/oai-document.util.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-document.util.js +12 -0
- package/build/_modules/open-ai/_collections/oai-document.util.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.js +9 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js +75 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js +68 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js.map +1 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts +6 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts.map +1 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js +10 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js.map +1 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts +18 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +1 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js +40 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts +7 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts +14 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +6 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts +6 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts +52 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts +13 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts +18 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js +80 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts +13 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.js +170 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/{embedding.control-service.d.ts → oai-embedding.control-service.d.ts} +3 -3
- package/build/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/{embedding.control-service.js → oai-embedding.control-service.js} +5 -5
- package/build/_modules/open-ai/_services/oai-embedding.control-service.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +161 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js +332 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts +231 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.js +438 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/{vector-data.service.d.ts → oai-vector-data.service.d.ts} +4 -4
- package/build/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/{vector-data.service.js → oai-vector-data.service.js} +27 -7
- package/build/_modules/open-ai/_services/oai-vector-data.service.js.map +1 -0
- package/build/_modules/open-ai/index.d.ts +18 -4
- package/build/_modules/open-ai/index.d.ts.map +1 -1
- package/build/_modules/open-ai/index.js +35 -4
- package/build/_modules/open-ai/index.js.map +1 -1
- package/build/_modules/server/index.d.ts +1 -1
- package/build/_modules/server/index.d.ts.map +1 -1
- package/build/_modules/server/index.js +16 -2
- package/build/_modules/server/index.js.map +1 -1
- package/build/_modules/server/server-status/server-status.controller.d.ts.map +1 -1
- package/build/_modules/server/server-status/server-status.controller.js +10 -0
- package/build/_modules/server/server-status/server-status.controller.js.map +1 -1
- package/build/_modules/socket/index.d.ts.map +1 -1
- package/build/_modules/socket/index.js +18 -0
- package/build/_modules/socket/index.js.map +1 -1
- package/build/_modules/test/index.d.ts.map +1 -1
- package/build/_modules/test/index.js +5 -0
- package/build/_modules/test/index.js.map +1 -1
- package/build/_modules/usage/index.d.ts.map +1 -1
- package/build/_modules/usage/index.js +5 -0
- package/build/_modules/usage/index.js.map +1 -1
- package/build/_services/server/app.server.js +1 -2
- package/build/_services/server/app.server.js.map +1 -1
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +26 -1
- package/build/index.js.map +1 -1
- package/package.json +40 -10
- package/src/_collections/atlas-default-db-options.const.ts +10 -0
- package/src/_collections/get-environment-settings.util.ts +49 -0
- package/src/_collections/global-settings.const.ts +15 -4
- package/src/_collections/sample.env +21 -0
- package/src/_models/control-models/app-params.control-model.spec.ts +5 -4
- package/src/_models/control-models/app-params.control-model.ts +31 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +1 -1
- package/src/_models/interfaces/environment-settings.interface.ts +59 -0
- package/src/_models/interfaces/global-settings.interface.ts +41 -1
- package/src/_modules/custom-data/index.ts +3 -0
- package/src/_modules/discord-assistant/_collections/dias-global-settings.const.ts +19 -0
- package/src/_modules/discord-assistant/_models/dias-global-settings.interface.ts +20 -0
- package/src/_modules/discord-assistant/_models/dias-knowledge.data-model.ts +46 -0
- package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +152 -0
- package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +59 -0
- package/src/_modules/discord-assistant/_services/dias-main.control-service.ts +28 -0
- package/src/_modules/discord-assistant/_services/dias.service-base.ts +81 -0
- package/src/_modules/discord-assistant/index.ts +36 -0
- package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.ts +11 -0
- package/src/_modules/discord-assistant-voiced/index.ts +36 -0
- package/src/_modules/discord-bot/_collections/dibo-default-commands.const.ts +17 -0
- package/src/_modules/discord-bot/_collections/dibo-global-settings.conts.ts +56 -0
- package/src/_modules/discord-bot/_collections/dibo-operations.util.ts +372 -0
- package/src/_modules/discord-bot/_models/dibo-command.interface.ts +12 -0
- package/src/_modules/discord-bot/_models/dibo-last-mention-date.inteface.ts +8 -0
- package/src/_modules/discord-bot/_models/dibo-last-message-date.interface.ts +6 -0
- package/src/_modules/discord-bot/_models/global-bot-log-settings.interface.ts +98 -0
- package/src/_modules/discord-bot/_services/dibo-commands.control-service.ts +120 -0
- package/src/_modules/discord-bot/_services/dibo-io.control-service.ts +245 -0
- package/src/_modules/discord-bot/_services/dibo-main.control-service.ts +304 -0
- package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +60 -0
- package/src/_modules/discord-bot/index.ts +36 -0
- package/src/_modules/oauth2/index.ts +8 -0
- package/src/_modules/open-ai/_collections/oai-chunking.util.ts +496 -0
- package/src/_modules/open-ai/_collections/oai-document.util.ts +10 -0
- package/src/_modules/open-ai/_collections/oai-global-settings.const.ts +9 -0
- package/src/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.ts +83 -0
- package/src/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.ts +76 -0
- package/src/_modules/open-ai/_enums/oai-compare-result-type.enum.ts +7 -0
- package/src/_modules/open-ai/_enums/oai-gpt-message-role.enum.ts +45 -0
- package/src/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.ts +10 -0
- package/src/_modules/open-ai/_models/interfaces/oai-document-page.interface.ts +20 -0
- package/src/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +8 -0
- package/src/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.ts +7 -0
- package/src/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.ts +57 -0
- package/src/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.ts +18 -0
- package/src/_modules/open-ai/_models/oai-doc-chunk.data-model.ts +92 -0
- package/src/_modules/open-ai/_services/oai-chunk.service-base.ts +214 -0
- package/src/_modules/open-ai/_services/{embedding.control-service.ts → oai-embedding.control-service.ts} +2 -2
- package/src/_modules/open-ai/_services/oai-llm-chat.service-base.ts +609 -0
- package/src/_modules/open-ai/_services/oai-llm.service-base.ts +648 -0
- package/src/_modules/open-ai/_services/{vector-data.service.ts → oai-vector-data.service.ts} +32 -5
- package/src/_modules/open-ai/index.ts +42 -4
- package/src/_modules/server/index.ts +18 -2
- package/src/_modules/server/server-status/server-status.controller.ts +13 -0
- package/src/_modules/socket/index.ts +23 -0
- package/src/_modules/test/index.ts +8 -0
- package/src/_modules/usage/index.ts +8 -0
- package/src/_services/server/app.server.ts +1 -1
- package/src/index.ts +28 -1
- package/build/_modules/open-ai/_services/embedding.control-service.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/embedding.control-service.js.map +0 -1
- package/build/_modules/open-ai/_services/gpt.service-base.d.ts +0 -98
- package/build/_modules/open-ai/_services/gpt.service-base.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/gpt.service-base.js +0 -284
- package/build/_modules/open-ai/_services/gpt.service-base.js.map +0 -1
- package/build/_modules/open-ai/_services/open-ai.service-base.d.ts +0 -21
- package/build/_modules/open-ai/_services/open-ai.service-base.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/open-ai.service-base.js +0 -50
- package/build/_modules/open-ai/_services/open-ai.service-base.js.map +0 -1
- package/build/_modules/open-ai/_services/vector-data.service.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/vector-data.service.js.map +0 -1
- package/build/_services/server/env-set.d.ts +0 -2
- package/build/_services/server/env-set.d.ts.map +0 -1
- package/build/_services/server/env-set.js +0 -20
- package/build/_services/server/env-set.js.map +0 -1
- package/src/_modules/open-ai/_services/gpt.service-base.ts +0 -438
- package/src/_modules/open-ai/_services/open-ai.service-base.ts +0 -69
- package/src/_services/server/env-set.ts +0 -21
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
import { Client, Guild, Message, TextChannel } from 'discord.js';
|
|
3
|
+
|
|
4
|
+
import { DyNTS_DiBo_Main_ControlService } from '../../discord-bot/_services/dibo-main.control-service';
|
|
5
|
+
import { DyNTS_OAI_LLMChat_ServiceBase } from '../../open-ai/_services/oai-llm-chat.service-base';
|
|
6
|
+
import { DyNTS_DiAs_global_settings } from '../_collections/dias-global-settings.const';
|
|
7
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
8
|
+
import { DyNTS_OAI_GPT_Message } from '../../open-ai/_models/interfaces/oai-gpt-message.interface';
|
|
9
|
+
import { DyNTS_OAI_GPT_Message_Role } from '../../open-ai/_enums/oai-gpt-message-role.enum';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export abstract class DyNTS_DiAs_ServiceBase extends DyNTS_DiBo_Main_ControlService {
|
|
13
|
+
|
|
14
|
+
getLLMChatControlService(): DyNTS_OAI_LLMChat_ServiceBase {
|
|
15
|
+
return new DyNTS_OAI_LLMChat_ServiceBase();
|
|
16
|
+
}
|
|
17
|
+
readonly llmChat_CS: DyNTS_OAI_LLMChat_ServiceBase = this.getLLMChatControlService();
|
|
18
|
+
|
|
19
|
+
defaultSystemPrompt: string = DyNTS_DiAs_global_settings.defaultSystemPrompt;
|
|
20
|
+
|
|
21
|
+
protected constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
DyNTS_global_settings.dias_settings ??= DyNTS_DiAs_global_settings;
|
|
25
|
+
|
|
26
|
+
this.llmChat_CS.defaultSettings.systemPrompt = this.defaultSystemPrompt;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async gatherMessages(message: Message, limit: number = 100): Promise<Message[]> {
|
|
30
|
+
const channel = message.channel;
|
|
31
|
+
const userId = message.author.id;
|
|
32
|
+
|
|
33
|
+
const messages: Message[] = await channel.messages.fetch({ limit: limit }).then(
|
|
34
|
+
messages => messages.filter(
|
|
35
|
+
msg => !DyNTS_DiAs_global_settings.skipConversationMessagesFlags.some(
|
|
36
|
+
flag => msg.content.includes(flag)
|
|
37
|
+
)
|
|
38
|
+
).map(msg => msg) // this last part creates simple array from Discord Collection
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (messages.some(msg => ![ this.botClientId, userId ].includes(msg.author.id))) {
|
|
42
|
+
messages.forEach(msg => {
|
|
43
|
+
msg.content = `**${msg.author.displayName}**: ${msg.content}`;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return messages;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async convertDiscordMessagesToOAIConversation(
|
|
51
|
+
messages: Message[]
|
|
52
|
+
): Promise<DyNTS_OAI_GPT_Message[]> {
|
|
53
|
+
return messages.map(message => {
|
|
54
|
+
if (
|
|
55
|
+
(message?.author &&
|
|
56
|
+
(message.author.bot ||
|
|
57
|
+
message.author.id === this.botClientId ||
|
|
58
|
+
message.author.displayName === this.botDisplayName))
|
|
59
|
+
) {
|
|
60
|
+
if (DyNTS_DiAs_global_settings.userTranslationFlags.some(
|
|
61
|
+
flag => message.content.includes(flag)
|
|
62
|
+
)) {
|
|
63
|
+
return {
|
|
64
|
+
role: DyNTS_OAI_GPT_Message_Role.user,
|
|
65
|
+
content: message.content,
|
|
66
|
+
};
|
|
67
|
+
} else {
|
|
68
|
+
return {
|
|
69
|
+
role: DyNTS_OAI_GPT_Message_Role.assistant,
|
|
70
|
+
content: message.content,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
return {
|
|
75
|
+
role: DyNTS_OAI_GPT_Message_Role.user,
|
|
76
|
+
content: message.content,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Discord Assistant module (AI-based)
|
|
7
|
+
//
|
|
8
|
+
// This module is created to simplify the usage of Discord Assistant
|
|
9
|
+
// It creates universal solutions for the most common use cases
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
// DEPENDENCIES
|
|
14
|
+
export * from '../discord-bot';
|
|
15
|
+
export * from '../open-ai';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// COLLECTIONS
|
|
19
|
+
export * from './_collections/dias-global-settings.const';
|
|
20
|
+
|
|
21
|
+
// MODELS
|
|
22
|
+
export * from './_models/dias-global-settings.interface';
|
|
23
|
+
export * from './_models/dias-knowledge.data-model';
|
|
24
|
+
|
|
25
|
+
// SERVICES
|
|
26
|
+
export * from './_services/dias-chunk.data-service';
|
|
27
|
+
export * from './_services/dias-io.control-service';
|
|
28
|
+
export * from './_services/dias-main.control-service';
|
|
29
|
+
export * from './_services/dias.service-base';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client, GatewayIntentBits, Guild, Collection, GuildMember, Message, Partials } from 'discord.js'
|
|
2
|
+
import * as dotenv from 'dotenv'
|
|
3
|
+
import { DyNTS_SingletonService } from '../../../_services/base/singleton.service';
|
|
4
|
+
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
6
|
+
import { DyNTS_DiAs_Main_ControlService } from '../../discord-assistant/_services/dias-main.control-service';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export abstract class DyNTS_DiAV_Main_ControlService extends DyNTS_DiAs_Main_ControlService {
|
|
10
|
+
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
try {
|
|
2
|
+
require('@discordjs/opus');
|
|
3
|
+
} catch (error) {
|
|
4
|
+
console.log(
|
|
5
|
+
'❌ @discordjs/opus package not found, please install it with: pnpm add @discordjs/opus'
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
require('@discordjs/voice');
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.log(
|
|
13
|
+
'❌ @discordjs/voice package not found, please install it with: pnpm add @discordjs/voice'
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
//
|
|
19
|
+
// Discord Assistant Voiced module
|
|
20
|
+
//
|
|
21
|
+
// This module is created to simplify the usage of Discord Assistant Voiced
|
|
22
|
+
// It creates universal solutions for the most common use cases
|
|
23
|
+
//
|
|
24
|
+
|
|
25
|
+
// DEPENDENCIES
|
|
26
|
+
export * from '../discord-assistant';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// SERVICES
|
|
30
|
+
export * from './_services/dias-discord-bot.control-service';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Message } from 'discord.js';
|
|
2
|
+
import { DyNTS_DiBo_Command } from '../_models/dibo-command.interface';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const DyNTS_DiBo_defaultCommands: DyNTS_DiBo_Command[] = [
|
|
10
|
+
{
|
|
11
|
+
command: '!ping',
|
|
12
|
+
description: 'Ping the bot',
|
|
13
|
+
commandHandler: async (message: Message) => {
|
|
14
|
+
await message.reply('Pong!');
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { GatewayIntentBits, Partials } from 'discord.js';
|
|
2
|
+
import { DyNTS_DiBo_Global_Settings } from '../_models/global-bot-log-settings.interface';
|
|
3
|
+
import { minute, week } from '@futdevpro/fsm-dynamo';
|
|
4
|
+
import { DyNTS_DiBo_defaultCommands } from './dibo-default-commands.const';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const DyNTS_DiBo_global_settings: DyNTS_DiBo_Global_Settings = {
|
|
10
|
+
debugLevel: 3,
|
|
11
|
+
|
|
12
|
+
intents: [
|
|
13
|
+
GatewayIntentBits.Guilds,
|
|
14
|
+
GatewayIntentBits.GuildMembers,
|
|
15
|
+
GatewayIntentBits.GuildMessages,
|
|
16
|
+
GatewayIntentBits.MessageContent,
|
|
17
|
+
GatewayIntentBits.DirectMessages,
|
|
18
|
+
GatewayIntentBits.GuildVoiceStates,
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
partials: [
|
|
22
|
+
Partials.Channel,
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
allowedUsers: 'all',
|
|
26
|
+
|
|
27
|
+
messageSettings: {
|
|
28
|
+
messageFetchTimeLimit: 3 * week,
|
|
29
|
+
messageFetchCountLimit: 1000,
|
|
30
|
+
messageSendDelay: minute / 3,
|
|
31
|
+
|
|
32
|
+
skipFlags: [
|
|
33
|
+
'[BOT-SKIP]',
|
|
34
|
+
'[SYSTEM|REFUSE|BOT]',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
channelSettings: {
|
|
39
|
+
reportChannelName: 'bot-report',
|
|
40
|
+
|
|
41
|
+
defaultChannels: [
|
|
42
|
+
'bot-help',
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
allowedChannels: [],
|
|
46
|
+
dmIsAllowed: false,
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
commandSettings: {
|
|
50
|
+
commandOperator: '',
|
|
51
|
+
|
|
52
|
+
commands: DyNTS_DiBo_defaultCommands,
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
allowBotsInteractEachOther: false,
|
|
56
|
+
}
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Client, Guild, GuildChannelManager, GuildBasedChannel, Message, TextBasedChannel, GuildMember,
|
|
5
|
+
TextChannel,
|
|
6
|
+
VoiceChannel
|
|
7
|
+
} from 'discord.js';
|
|
8
|
+
import { Collection } from 'discord.js';
|
|
9
|
+
import { DyNTS_DiBo_global_settings } from './dibo-global-settings.conts';
|
|
10
|
+
import { DyNTS_DiBo_LastMessageDate } from '../_models/dibo-last-message-date.interface';
|
|
11
|
+
import { DyNTS_DiBo_LastMentionDate } from '../_models/dibo-last-mention-date.inteface';
|
|
12
|
+
|
|
13
|
+
export class DyNTS_DiBo_Operations_Util {
|
|
14
|
+
|
|
15
|
+
static findChannelByName(channels: GuildChannelManager, name: string): GuildBasedChannel {
|
|
16
|
+
const channel = channels.cache.find(
|
|
17
|
+
(ch) => ch.name === name && ch.isTextBased()
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
if (!channel) {
|
|
21
|
+
DyFM_Log.error('No text channel found')
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return channel
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static findTextChannelByName(channels: GuildChannelManager, name: string): TextChannel {
|
|
29
|
+
const channel = this.findChannelByName(channels, name)
|
|
30
|
+
|
|
31
|
+
if (!channel.isTextBased()) {
|
|
32
|
+
throw new Error('Channel is not text based')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return channel as TextChannel
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static findVoiceChannelByName(channels: GuildChannelManager, name: string): VoiceChannel {
|
|
39
|
+
const channel = this.findChannelByName(channels, name)
|
|
40
|
+
|
|
41
|
+
if (!channel.isVoiceBased()) {
|
|
42
|
+
throw new Error('Channel is not voice based')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return channel as VoiceChannel
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static async reportIn(guild: Guild, client: Client): Promise<void> {
|
|
49
|
+
try {
|
|
50
|
+
const lastReportMessage = await this.getLastMessageInChannel(
|
|
51
|
+
guild,
|
|
52
|
+
DyNTS_DiBo_global_settings.channelSettings.reportChannelName
|
|
53
|
+
)
|
|
54
|
+
const reportMessage = `${client.user?.username} report for duty!`
|
|
55
|
+
|
|
56
|
+
if (lastReportMessage.content === reportMessage) {
|
|
57
|
+
await this.deleteMessage(lastReportMessage).catch((error) => {
|
|
58
|
+
DyFM_Log.error('Failed to delete message', error);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.sendMessageToChannelByName(
|
|
63
|
+
guild,
|
|
64
|
+
DyNTS_DiBo_global_settings.channelSettings.reportChannelName,
|
|
65
|
+
reportMessage
|
|
66
|
+
)
|
|
67
|
+
} catch (error) {
|
|
68
|
+
DyFM_Log.error('Failed to report in', error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static sendMessageToChannelByName(guild: Guild, channelName: string, message: string) {
|
|
73
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
74
|
+
|
|
75
|
+
if (channel?.isTextBased()) {
|
|
76
|
+
channel.send(message)
|
|
77
|
+
DyFM_Log.success('Message sent to channel', channel.name)
|
|
78
|
+
} else {
|
|
79
|
+
DyFM_Log.error('Channel is not text based')
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static async readMembersInChannel(
|
|
84
|
+
guild: Guild,
|
|
85
|
+
channelName: string
|
|
86
|
+
): Promise<Collection<string, GuildMember>> {
|
|
87
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
88
|
+
|
|
89
|
+
const members = await guild?.members.fetch()
|
|
90
|
+
|
|
91
|
+
const allowedMembers = members?.filter((member) =>
|
|
92
|
+
channel.permissionsFor(member)?.has('ViewChannel')
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return allowedMembers
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static async readMemberNamesInChannel(guild: Guild, channelName: string): Promise<string[]> {
|
|
99
|
+
const members = await this.readMembersInChannel(guild, channelName)
|
|
100
|
+
|
|
101
|
+
const memberNames = members?.map((member) => member.user.username)
|
|
102
|
+
|
|
103
|
+
return memberNames
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static async fetchAllMessagesWithPaging(
|
|
107
|
+
channel: TextBasedChannel,
|
|
108
|
+
maxFetch = 1000
|
|
109
|
+
): Promise<Collection<string, Message<true>>> {
|
|
110
|
+
let lastId: string | undefined = undefined;
|
|
111
|
+
let fetched = 0;
|
|
112
|
+
const allMessages = new Collection<string, Message<true>>();
|
|
113
|
+
|
|
114
|
+
while (fetched < maxFetch) {
|
|
115
|
+
const options: any = { limit: 100 };
|
|
116
|
+
if (lastId) options.before = lastId;
|
|
117
|
+
|
|
118
|
+
const messages = await channel.messages.fetch(options) as unknown as Collection<string, Message<true>>;
|
|
119
|
+
if (messages.size === 0) break;
|
|
120
|
+
|
|
121
|
+
messages.forEach((msg: Message<true>) => {
|
|
122
|
+
allMessages.set(msg.id, msg);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
lastId = messages.last()?.id;
|
|
126
|
+
fetched += messages.size;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
DyFM_Log.success('Fetched messages with paging', allMessages.size);
|
|
130
|
+
return allMessages;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static async readLastMessageDatesByMembers(
|
|
134
|
+
guild: Guild,
|
|
135
|
+
channelName: string,
|
|
136
|
+
memberNames: string[]
|
|
137
|
+
): Promise<DyNTS_DiBo_LastMessageDate[]> {
|
|
138
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
139
|
+
|
|
140
|
+
if (!channel?.isTextBased()) {
|
|
141
|
+
DyFM_Log.error('Channel is not text based')
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Prepare tracking for each member
|
|
146
|
+
const memberStatus: Record<string, { lastMessageDate: Date | null, allMessages: number }> = {};
|
|
147
|
+
memberNames.forEach(name => {
|
|
148
|
+
memberStatus[name] = { lastMessageDate: null, allMessages: 0 };
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
let lastId: string | undefined = undefined;
|
|
152
|
+
let done = false;
|
|
153
|
+
const cutoffTime = Date.now() - DyNTS_DiBo_global_settings.messageSettings.messageFetchTimeLimit;
|
|
154
|
+
let totalFetched = 0;
|
|
155
|
+
|
|
156
|
+
while (
|
|
157
|
+
!done &&
|
|
158
|
+
totalFetched < DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit
|
|
159
|
+
) {
|
|
160
|
+
const options: any = { limit: 100 };
|
|
161
|
+
if (lastId) options.before = lastId;
|
|
162
|
+
const messages = await channel.messages.fetch(options) as unknown as Collection<string, Message<true>>;
|
|
163
|
+
if (messages.size === 0) break;
|
|
164
|
+
|
|
165
|
+
let shouldStop = false;
|
|
166
|
+
messages.forEach((message) => {
|
|
167
|
+
// Check if message is too old
|
|
168
|
+
if (message.createdTimestamp < cutoffTime) {
|
|
169
|
+
shouldStop = true;
|
|
170
|
+
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const author = message.author.username;
|
|
175
|
+
if (memberStatus[author] !== undefined) {
|
|
176
|
+
memberStatus[author].allMessages++;
|
|
177
|
+
|
|
178
|
+
// Only set lastMessageDate if not already set (since we fetch newest first)
|
|
179
|
+
if (!memberStatus[author].lastMessageDate) {
|
|
180
|
+
memberStatus[author].lastMessageDate = message.createdAt;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (shouldStop) {
|
|
186
|
+
DyFM_Log.warn('Reached time limit cutoff');
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Check if all members have a lastMessageDate
|
|
191
|
+
done = memberNames.every(name => memberStatus[name].lastMessageDate !== null);
|
|
192
|
+
lastId = messages.last()?.id;
|
|
193
|
+
totalFetched += messages.size;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (totalFetched >= DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit) {
|
|
197
|
+
DyFM_Log.warn(
|
|
198
|
+
'Reached maximum fetch count limit',
|
|
199
|
+
DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const lastMessageDatesByMembers: DyNTS_DiBo_LastMessageDate[] = memberNames.map((memberName) => {
|
|
204
|
+
const status = memberStatus[memberName];
|
|
205
|
+
if (!status.lastMessageDate) {
|
|
206
|
+
DyFM_Log.warn('No last message date found for member', memberName);
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
memberName: memberName,
|
|
210
|
+
allMessages: status.allMessages,
|
|
211
|
+
lastMessageDate: null/* new Date(0) */
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return ({
|
|
216
|
+
memberName: memberName,
|
|
217
|
+
allMessages: status.allMessages,
|
|
218
|
+
lastMessageDate: new Date(status.lastMessageDate)
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return lastMessageDatesByMembers;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static async readLastMessageWithMemberNamePingInIt(
|
|
226
|
+
guild: Guild,
|
|
227
|
+
channelName: string,
|
|
228
|
+
members: Collection<string, GuildMember>
|
|
229
|
+
): Promise<DyNTS_DiBo_LastMentionDate[]> {
|
|
230
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
231
|
+
|
|
232
|
+
if (!channel?.isTextBased()) {
|
|
233
|
+
DyFM_Log.error('Channel is not text based')
|
|
234
|
+
return []
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Prepare tracking for each member
|
|
238
|
+
const memberStatus: Record<string, { lastMentionDate: Date | null, allMentions: number }> = {};
|
|
239
|
+
members.forEach(member => {
|
|
240
|
+
memberStatus[member.user.username] = { lastMentionDate: null, allMentions: 0 };
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
let lastId: string | undefined = undefined;
|
|
244
|
+
let done = false;
|
|
245
|
+
const cutoffTime = Date.now() - DyNTS_DiBo_global_settings.messageSettings.messageFetchTimeLimit;
|
|
246
|
+
let totalFetched = 0;
|
|
247
|
+
|
|
248
|
+
while (
|
|
249
|
+
!done &&
|
|
250
|
+
totalFetched < DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit
|
|
251
|
+
) {
|
|
252
|
+
const options: any = { limit: 100 };
|
|
253
|
+
if (lastId) options.before = lastId;
|
|
254
|
+
const messages = await channel.messages.fetch(options) as unknown as Collection<string, Message<true>>;
|
|
255
|
+
if (messages.size === 0) break;
|
|
256
|
+
|
|
257
|
+
let shouldStop = false;
|
|
258
|
+
messages.forEach((message) => {
|
|
259
|
+
// Check if message is too old
|
|
260
|
+
if (message.createdTimestamp < cutoffTime) {
|
|
261
|
+
shouldStop = true;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Check if message content contains "@Username" for any member
|
|
266
|
+
members.forEach(member => {
|
|
267
|
+
if (
|
|
268
|
+
message.content.includes(`@${member.user.id}`) &&
|
|
269
|
+
!memberStatus[member.user.username].lastMentionDate
|
|
270
|
+
) {
|
|
271
|
+
memberStatus[member.user.username].lastMentionDate = message.createdAt;
|
|
272
|
+
memberStatus[member.user.username].allMentions++;
|
|
273
|
+
DyFM_Log.success(
|
|
274
|
+
'Found message with member ping',
|
|
275
|
+
{
|
|
276
|
+
memberName: member.user.username,
|
|
277
|
+
messageId: message.id
|
|
278
|
+
}
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (shouldStop) {
|
|
285
|
+
DyFM_Log.warn('Reached time limit cutoff while searching for member pings');
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Check if all members have a lastMessageDate
|
|
290
|
+
done = members.every(member => memberStatus[member.user.username].lastMentionDate !== null);
|
|
291
|
+
lastId = messages.last()?.id;
|
|
292
|
+
totalFetched += messages.size;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (totalFetched >= DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit) {
|
|
296
|
+
DyFM_Log.warn(
|
|
297
|
+
'Reached maximum fetch count limit while searching for member pings',
|
|
298
|
+
DyNTS_DiBo_global_settings.messageSettings.messageFetchCountLimit
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const lastMentionDatesByMembers: DyNTS_DiBo_LastMentionDate[] = members.map((member) => {
|
|
303
|
+
const status = memberStatus[member.user.username];
|
|
304
|
+
if (!status.lastMentionDate) {
|
|
305
|
+
DyFM_Log.warn('No message found with member ping', member.user.username);
|
|
306
|
+
return {
|
|
307
|
+
memberId: member.user.id,
|
|
308
|
+
memberName: member.user.username,
|
|
309
|
+
allMentions: status.allMentions,
|
|
310
|
+
lastMentionDate: null/* new Date(0) */
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return ({
|
|
314
|
+
memberId: member.user.id,
|
|
315
|
+
memberName: member.user.username,
|
|
316
|
+
allMentions: status.allMentions,
|
|
317
|
+
lastMentionDate: new Date(status.lastMentionDate)
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
return lastMentionDatesByMembers;
|
|
322
|
+
}
|
|
323
|
+
static readMentionsInChannel = this.readLastMessageWithMemberNamePingInIt
|
|
324
|
+
|
|
325
|
+
static async readLastMessagesInChannel(
|
|
326
|
+
guild: Guild,
|
|
327
|
+
channelName: string,
|
|
328
|
+
): Promise<Collection<string, Message<true>>> {
|
|
329
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
330
|
+
|
|
331
|
+
if (!channel?.isTextBased()) {
|
|
332
|
+
DyFM_Log.error('Channel is not text based')
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const messages = await channel.messages.fetch({ limit: 100 })
|
|
337
|
+
|
|
338
|
+
return messages
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static async getLastMessageInChannel(
|
|
342
|
+
guild: Guild,
|
|
343
|
+
channelName: string
|
|
344
|
+
): Promise<Message<true>> {
|
|
345
|
+
const channel = this.findChannelByName(guild.channels, channelName)
|
|
346
|
+
|
|
347
|
+
if (!channel?.isTextBased()) {
|
|
348
|
+
DyFM_Log.error('Channel is not text based')
|
|
349
|
+
return
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const messages = await channel.messages.fetch({ limit: 1 })
|
|
353
|
+
|
|
354
|
+
return messages.first()
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
static getMemberIdByName(
|
|
358
|
+
members: Collection<string, GuildMember>,
|
|
359
|
+
username: string
|
|
360
|
+
): string | undefined {
|
|
361
|
+
const member = members.find(m => m.user.username === username);
|
|
362
|
+
return member ? member.user.id : undefined;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
static async deleteMessage(message: Message): Promise<void> {
|
|
366
|
+
await message.delete().catch((error) => {
|
|
367
|
+
DyFM_Log.error('Failed to delete message', error);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
DyFM_Log.success('Message deleted', message.id);
|
|
371
|
+
}
|
|
372
|
+
}
|