From 72ec76ff4a4f1ea43158cbf8501f876aff6ef0a0 Mon Sep 17 00:00:00 2001 From: MidSpike Date: Tue, 9 Aug 2022 13:26:54 -0400 Subject: [PATCH] start ts conversion --- .eslintrc.js | 340 ---- .eslintrc.json | 407 +++++ dist/bot/bot.js | 41 + dist/bot/bot.js.map | 1 + dist/bot/commands/ban.js | 109 ++ dist/bot/commands/ban.js.map | 1 + dist/bot/commands/blacklist.js | 287 ++++ dist/bot/commands/blacklist.js.map | 1 + dist/bot/commands/demo.js | 38 + dist/bot/commands/demo.js.map | 1 + dist/bot/commands/downloads.js | 38 + dist/bot/commands/downloads.js.map | 1 + dist/bot/commands/echo.js | 35 + dist/bot/commands/echo.js.map | 1 + dist/bot/commands/help.js | 71 + dist/bot/commands/help.js.map | 1 + dist/bot/commands/identity_token.js | 26 + dist/bot/commands/identity_token.js.map | 1 + dist/bot/commands/kick.js | 107 ++ dist/bot/commands/kick.js.map | 1 + dist/bot/commands/lookup.js | 85 + dist/bot/commands/lookup.js.map | 1 + dist/bot/commands/moderation_actions.js | 451 ++++++ dist/bot/commands/moderation_actions.js.map | 1 + dist/bot/commands/notes.js | 536 +++++++ dist/bot/commands/notes.js.map | 1 + dist/bot/commands/product_hub.js | 38 + dist/bot/commands/product_hub.js.map | 1 + dist/bot/commands/products.js | 140 ++ dist/bot/commands/products.js.map | 1 + dist/bot/commands/profile.js | 44 + dist/bot/commands/profile.js.map | 1 + dist/bot/commands/purge.js | 40 + dist/bot/commands/purge.js.map | 1 + dist/bot/commands/support.js | 950 +++++++++++ dist/bot/commands/support.js.map | 1 + dist/bot/commands/verify.js | 244 +++ dist/bot/commands/verify.js.map | 1 + dist/bot/commands/warn.js | 98 ++ dist/bot/commands/warn.js.map | 1 + dist/bot/commands/website.js | 38 + dist/bot/commands/website.js.map | 1 + dist/bot/common/bot.js | 79 + dist/bot/common/bot.js.map | 1 + dist/bot/common/message.js | 28 + dist/bot/common/message.js.map | 1 + dist/bot/discord_client.js | 69 + dist/bot/discord_client.js.map | 1 + dist/bot/events/guild_member_add.js | 49 + dist/bot/events/guild_member_add.js.map | 1 + dist/bot/events/guild_member_remove.js | 24 + dist/bot/events/guild_member_remove.js.map | 1 + dist/bot/events/guild_member_update.js | 37 + dist/bot/events/guild_member_update.js.map | 1 + dist/bot/events/interaction_create.js | 17 + dist/bot/events/interaction_create.js.map | 1 + dist/bot/events/message_create.js | 56 + dist/bot/events/message_create.js.map | 1 + dist/bot/events/message_delete.js | 24 + dist/bot/events/message_delete.js.map | 1 + dist/bot/events/message_update.js | 24 + dist/bot/events/message_update.js.map | 1 + dist/bot/events/ready.js | 107 ++ dist/bot/events/ready.js.map | 1 + .../automated_quick_support_handler.js | 113 ++ .../automated_quick_support_handler.js.map | 1 + dist/bot/handlers/command_handler.js | 111 ++ dist/bot/handlers/command_handler.js.map | 1 + dist/bot/handlers/illegal_nickname_handler.js | 41 + .../handlers/illegal_nickname_handler.js.map | 1 + dist/bot/handlers/interaction_handler.js | 57 + dist/bot/handlers/interaction_handler.js.map | 1 + .../handlers/log_moderation_action_handler.js | 60 + .../log_moderation_action_handler.js.map | 1 + .../handlers/logs/guild_member_messages.js | 103 ++ .../logs/guild_member_messages.js.map | 1 + .../handlers/logs/guild_member_retention.js | 90 ++ .../logs/guild_member_retention.js.map | 1 + dist/bot/handlers/logs/guild_member_roles.js | 82 + .../handlers/logs/guild_member_roles.js.map | 1 + .../one_word_story_channel_handler.js | 27 + .../one_word_story_channel_handler.js.map | 1 + .../handlers/suggestions_category_handler.js | 46 + .../suggestions_category_handler.js.map | 1 + dist/bot/handlers/user_notes_handler.js | 178 ++ dist/bot/handlers/user_notes_handler.js.map | 1 + dist/bot/handlers/user_profile_handler.js | 131 ++ dist/bot/handlers/user_profile_handler.js.map | 1 + dist/bot/handlers/welcome_message_handler.js | 71 + .../handlers/welcome_message_handler.js.map | 1 + ...splay_support_ticket_database_documents.js | 90 ++ ...y_support_ticket_database_documents.js.map | 1 + .../buttons/welcome_message_captcha_button.js | 43 +- .../welcome_message_captcha_button.js.map | 1 + .../context_menus/user_profile.js | 30 + .../context_menus/user_profile.js.map | 1 + .../message_commands/manage_karma.js | 162 ++ .../message_commands/manage_karma.js.map | 1 + .../message_commands/manage_products.js | 172 ++ .../message_commands/manage_products.js.map | 1 + .../message_commands/quick_support.js | 84 + .../message_commands/quick_support.js.map | 1 + .../interactions/message_commands/timeout.js | 66 +- .../message_commands/timeout.js.map | 1 + .../select_menus/automatic_roles_menu.js | 39 +- .../select_menus/automatic_roles_menu.js.map | 1 + index.js => dist/index.js | 24 +- dist/index.js.map | 1 + dist/mongo/mongo.js | 10 + dist/mongo/mongo.js.map | 1 + dist/utilities.js | 103 ++ dist/utilities.js.map | 1 + package-lock.json | 1427 +++++++++++------ package.json | 45 +- src/bot/bot.js | 25 - src/bot/bot.ts | 24 + src/bot/common/{bot.js => bot.ts} | 24 +- src/bot/common/{message.js => message.ts} | 12 +- .../{discord_client.js => discord_client.ts} | 14 +- ...play_support_ticket_database_documents.ts} | 20 +- .../buttons/welcome_message_captcha_button.ts | 119 ++ .../{user_profile.js => user_profile.ts} | 13 +- .../{manage_karma.js => manage_karma.ts} | 23 +- ...{manage_products.js => manage_products.ts} | 37 +- .../{quick_support.js => quick_support.ts} | 45 +- .../interactions/message_commands/timeout.ts | 138 ++ .../select_menus/automatic_roles_menu.ts | 60 + src/index.ts | 30 + src/mongo/{mongo.js => mongo.ts} | 10 +- src/types/types.d.ts | 84 + src/{utilities.js => utilities.ts} | 75 +- tsconfig.json | 35 + 132 files changed, 7748 insertions(+), 1177 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 .eslintrc.json create mode 100644 dist/bot/bot.js create mode 100644 dist/bot/bot.js.map create mode 100644 dist/bot/commands/ban.js create mode 100644 dist/bot/commands/ban.js.map create mode 100644 dist/bot/commands/blacklist.js create mode 100644 dist/bot/commands/blacklist.js.map create mode 100644 dist/bot/commands/demo.js create mode 100644 dist/bot/commands/demo.js.map create mode 100644 dist/bot/commands/downloads.js create mode 100644 dist/bot/commands/downloads.js.map create mode 100644 dist/bot/commands/echo.js create mode 100644 dist/bot/commands/echo.js.map create mode 100644 dist/bot/commands/help.js create mode 100644 dist/bot/commands/help.js.map create mode 100644 dist/bot/commands/identity_token.js create mode 100644 dist/bot/commands/identity_token.js.map create mode 100644 dist/bot/commands/kick.js create mode 100644 dist/bot/commands/kick.js.map create mode 100644 dist/bot/commands/lookup.js create mode 100644 dist/bot/commands/lookup.js.map create mode 100644 dist/bot/commands/moderation_actions.js create mode 100644 dist/bot/commands/moderation_actions.js.map create mode 100644 dist/bot/commands/notes.js create mode 100644 dist/bot/commands/notes.js.map create mode 100644 dist/bot/commands/product_hub.js create mode 100644 dist/bot/commands/product_hub.js.map create mode 100644 dist/bot/commands/products.js create mode 100644 dist/bot/commands/products.js.map create mode 100644 dist/bot/commands/profile.js create mode 100644 dist/bot/commands/profile.js.map create mode 100644 dist/bot/commands/purge.js create mode 100644 dist/bot/commands/purge.js.map create mode 100644 dist/bot/commands/support.js create mode 100644 dist/bot/commands/support.js.map create mode 100644 dist/bot/commands/verify.js create mode 100644 dist/bot/commands/verify.js.map create mode 100644 dist/bot/commands/warn.js create mode 100644 dist/bot/commands/warn.js.map create mode 100644 dist/bot/commands/website.js create mode 100644 dist/bot/commands/website.js.map create mode 100644 dist/bot/common/bot.js create mode 100644 dist/bot/common/bot.js.map create mode 100644 dist/bot/common/message.js create mode 100644 dist/bot/common/message.js.map create mode 100644 dist/bot/discord_client.js create mode 100644 dist/bot/discord_client.js.map create mode 100644 dist/bot/events/guild_member_add.js create mode 100644 dist/bot/events/guild_member_add.js.map create mode 100644 dist/bot/events/guild_member_remove.js create mode 100644 dist/bot/events/guild_member_remove.js.map create mode 100644 dist/bot/events/guild_member_update.js create mode 100644 dist/bot/events/guild_member_update.js.map create mode 100644 dist/bot/events/interaction_create.js create mode 100644 dist/bot/events/interaction_create.js.map create mode 100644 dist/bot/events/message_create.js create mode 100644 dist/bot/events/message_create.js.map create mode 100644 dist/bot/events/message_delete.js create mode 100644 dist/bot/events/message_delete.js.map create mode 100644 dist/bot/events/message_update.js create mode 100644 dist/bot/events/message_update.js.map create mode 100644 dist/bot/events/ready.js create mode 100644 dist/bot/events/ready.js.map create mode 100644 dist/bot/handlers/automated_quick_support_handler.js create mode 100644 dist/bot/handlers/automated_quick_support_handler.js.map create mode 100644 dist/bot/handlers/command_handler.js create mode 100644 dist/bot/handlers/command_handler.js.map create mode 100644 dist/bot/handlers/illegal_nickname_handler.js create mode 100644 dist/bot/handlers/illegal_nickname_handler.js.map create mode 100644 dist/bot/handlers/interaction_handler.js create mode 100644 dist/bot/handlers/interaction_handler.js.map create mode 100644 dist/bot/handlers/log_moderation_action_handler.js create mode 100644 dist/bot/handlers/log_moderation_action_handler.js.map create mode 100644 dist/bot/handlers/logs/guild_member_messages.js create mode 100644 dist/bot/handlers/logs/guild_member_messages.js.map create mode 100644 dist/bot/handlers/logs/guild_member_retention.js create mode 100644 dist/bot/handlers/logs/guild_member_retention.js.map create mode 100644 dist/bot/handlers/logs/guild_member_roles.js create mode 100644 dist/bot/handlers/logs/guild_member_roles.js.map create mode 100644 dist/bot/handlers/one_word_story_channel_handler.js create mode 100644 dist/bot/handlers/one_word_story_channel_handler.js.map create mode 100644 dist/bot/handlers/suggestions_category_handler.js create mode 100644 dist/bot/handlers/suggestions_category_handler.js.map create mode 100644 dist/bot/handlers/user_notes_handler.js create mode 100644 dist/bot/handlers/user_notes_handler.js.map create mode 100644 dist/bot/handlers/user_profile_handler.js create mode 100644 dist/bot/handlers/user_profile_handler.js.map create mode 100644 dist/bot/handlers/welcome_message_handler.js create mode 100644 dist/bot/handlers/welcome_message_handler.js.map create mode 100644 dist/bot/interactions/buttons/display_support_ticket_database_documents.js create mode 100644 dist/bot/interactions/buttons/display_support_ticket_database_documents.js.map rename {src => dist}/bot/interactions/buttons/welcome_message_captcha_button.js (86%) create mode 100644 dist/bot/interactions/buttons/welcome_message_captcha_button.js.map create mode 100644 dist/bot/interactions/context_menus/user_profile.js create mode 100644 dist/bot/interactions/context_menus/user_profile.js.map create mode 100644 dist/bot/interactions/message_commands/manage_karma.js create mode 100644 dist/bot/interactions/message_commands/manage_karma.js.map create mode 100644 dist/bot/interactions/message_commands/manage_products.js create mode 100644 dist/bot/interactions/message_commands/manage_products.js.map create mode 100644 dist/bot/interactions/message_commands/quick_support.js create mode 100644 dist/bot/interactions/message_commands/quick_support.js.map rename {src => dist}/bot/interactions/message_commands/timeout.js (75%) create mode 100644 dist/bot/interactions/message_commands/timeout.js.map rename {src => dist}/bot/interactions/select_menus/automatic_roles_menu.js (75%) create mode 100644 dist/bot/interactions/select_menus/automatic_roles_menu.js.map rename index.js => dist/index.js (79%) create mode 100644 dist/index.js.map create mode 100644 dist/mongo/mongo.js create mode 100644 dist/mongo/mongo.js.map create mode 100644 dist/utilities.js create mode 100644 dist/utilities.js.map delete mode 100644 src/bot/bot.js create mode 100644 src/bot/bot.ts rename src/bot/common/{bot.js => bot.ts} (84%) rename src/bot/common/{message.js => message.ts} (75%) rename src/bot/{discord_client.js => discord_client.ts} (89%) rename src/bot/interactions/buttons/{display_support_ticket_database_documents.js => display_support_ticket_database_documents.ts} (81%) create mode 100644 src/bot/interactions/buttons/welcome_message_captcha_button.ts rename src/bot/interactions/context_menus/{user_profile.js => user_profile.ts} (77%) rename src/bot/interactions/message_commands/{manage_karma.js => manage_karma.ts} (90%) rename src/bot/interactions/message_commands/{manage_products.js => manage_products.ts} (86%) rename src/bot/interactions/message_commands/{quick_support.js => quick_support.ts} (70%) create mode 100644 src/bot/interactions/message_commands/timeout.ts create mode 100644 src/bot/interactions/select_menus/automatic_roles_menu.ts create mode 100644 src/index.ts rename src/mongo/{mongo.js => mongo.ts} (71%) create mode 100644 src/types/types.d.ts rename src/{utilities.js => utilities.ts} (68%) create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5d991023..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,340 +0,0 @@ -/* Copyright © Inertia Lighting | All Rights Reserved */ - -//---------------------------------------------------------------------------------------------------------------// - -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - -module.exports = { - 'env': { - 'browser': false, - 'node': true, - 'commonjs': true, - 'es2021': true, - }, - 'extends': 'eslint:recommended', - 'parserOptions': { - 'ecmaVersion': 12, - 'requireConfigFile': false, - 'sourceType': 'script', - }, - 'rules': { - 'accessor-pairs': 'error', - 'array-bracket-newline': 'off', - 'array-bracket-spacing': 'off', - 'array-callback-return': 'error', - 'array-element-newline': 'off', - 'arrow-body-style': 'error', - 'arrow-parens': 'off', - 'arrow-spacing': [ - 'error', - { - 'after': true, - 'before': true, - }, - ], - 'block-scoped-var': 'error', - 'block-spacing': 'error', - 'brace-style': [ - 'error', - '1tbs', - ], - 'camelcase': 'off', - 'capitalized-comments': 'off', - 'class-methods-use-this': 'error', - 'comma-dangle': 'off', - 'comma-spacing': [ - 'error', - { - 'after': true, - 'before': false, - }, - ], - 'comma-style': [ - 'error', - 'last', - ], - 'complexity': 'off', - 'computed-property-spacing': [ - 'error', - 'never', - ], - 'consistent-return': 'off', - 'consistent-this': 'error', - 'curly': 'off', - 'default-case': 'error', - 'default-case-last': 'error', - 'default-param-last': 'error', - 'dot-location': [ - 'error', - 'property', - ], - 'dot-notation': 'error', - 'eol-last': 'error', - 'eqeqeq': 'error', - 'func-call-spacing': 'error', - 'func-name-matching': 'error', - 'func-names': 'error', - 'func-style': [ - 'error', - 'declaration', - { - 'allowArrowFunctions': true, - }, - ], - 'function-call-argument-newline': [ - 'error', - 'consistent' - ], - 'function-paren-newline': 'off', - 'generator-star-spacing': 'error', - 'grouped-accessor-pairs': 'error', - 'guard-for-in': 'error', - 'id-denylist': 'error', - 'id-length': 'off', - 'id-match': 'error', - 'implicit-arrow-linebreak': 'off', - 'indent': 'off', - 'init-declarations': 'off', - 'jsx-quotes': 'error', - 'key-spacing': 'error', - 'keyword-spacing': [ - 'error', - { - 'after': true, - 'before': true, - }, - ], - 'line-comment-position': 'off', - 'linebreak-style': [ - 'error', - 'windows', - ], - 'lines-around-comment': 'off', - 'lines-between-class-members': 'error', - 'max-classes-per-file': 'error', - 'max-depth': 'error', - 'max-len': 'off', - 'max-lines': 'off', - 'max-lines-per-function': 'off', - 'max-nested-callbacks': 'error', - 'max-params': 'off', - 'max-statements': 'off', - 'max-statements-per-line': 'error', - 'multiline-comment-style': [ - 'error', - 'separate-lines', - ], - 'multiline-ternary': [ - 'error', - 'never', - ], - 'new-parens': 'error', - 'newline-per-chained-call': 'off', - 'no-alert': 'error', - 'no-array-constructor': 'error', - 'no-await-in-loop': 'off', - 'no-bitwise': 'error', - 'no-caller': 'error', - 'no-confusing-arrow': 'off', - 'no-console': 'off', - 'no-constructor-return': 'error', - 'no-continue': 'off', - 'no-div-regex': 'error', - 'no-duplicate-imports': 'error', - 'no-else-return': 'off', - 'no-empty': [ - 'error', - { - 'allowEmptyCatch': true, - }, - ], - 'no-empty-function': 'error', - 'no-eq-null': 'error', - 'no-eval': 'error', - 'no-extend-native': 'error', - 'no-extra-bind': 'error', - 'no-extra-label': 'error', - 'no-extra-parens': 'off', - 'no-floating-decimal': 'error', - 'no-implicit-coercion': 'error', - 'no-implicit-globals': 'error', - 'no-implied-eval': 'error', - 'no-inline-comments': 'off', - 'no-invalid-this': 'error', - 'no-iterator': 'error', - 'no-label-var': 'error', - 'no-labels': 'error', - 'no-lone-blocks': 'error', - 'no-lonely-if': 'error', - 'no-loop-func': 'error', - 'no-loss-of-precision': 'error', - 'no-magic-numbers': 'off', - 'no-mixed-operators': [ - 'error', - { - 'allowSamePrecedence': true, - }, - ], - 'no-multi-assign': 'error', - 'no-multi-spaces': 'error', - 'no-multi-str': 'error', - 'no-multiple-empty-lines': 'error', - 'no-negated-condition': 'error', - 'no-nested-ternary': 'off', - 'no-new': 'error', - 'no-new-func': 'error', - 'no-new-object': 'error', - 'no-new-wrappers': 'error', - 'no-nonoctal-decimal-escape': 'error', - 'no-octal-escape': 'error', - 'no-param-reassign': 'error', - 'no-plusplus': [ - 'error', - { - 'allowForLoopAfterthoughts': true, - }, - ], - 'no-promise-executor-return': 'off', - 'no-proto': 'error', - 'no-restricted-exports': 'error', - 'no-restricted-globals': 'error', - 'no-restricted-imports': 'error', - 'no-restricted-properties': 'error', - 'no-restricted-syntax': 'error', - 'no-return-assign': 'error', - 'no-return-await': 'off', - 'no-script-url': 'error', - 'no-self-compare': 'error', - 'no-sequences': 'error', - 'no-shadow': 'off', - 'no-tabs': 'error', - 'no-template-curly-in-string': 'error', - 'no-ternary': 'off', - 'no-throw-literal': 'error', - 'no-trailing-spaces': 'error', - 'no-undef-init': 'error', - 'no-undefined': 'off', - 'no-underscore-dangle': 'error', - 'no-unmodified-loop-condition': 'error', - 'no-unneeded-ternary': 'off', - 'no-unreachable-loop': 'error', - 'no-unsafe-optional-chaining': 'error', - 'no-unused-expressions': 'error', - 'no-unused-vars': [ - 'error', - { - 'vars': 'all', - 'args': 'none', - 'ignoreRestSiblings': true, - }, - ], - 'no-use-before-define': 'error', - 'no-useless-backreference': 'error', - 'no-useless-call': 'error', - 'no-useless-computed-key': 'off', - 'no-useless-concat': 'error', - 'no-useless-constructor': 'error', - 'no-useless-escape': 'off', - 'no-useless-return': 'off', - 'no-var': 'error', - 'no-void': 'error', - 'no-warning-comments': 'error', - 'no-whitespace-before-property': 'error', - 'nonblock-statement-body-position': 'error', - 'object-curly-newline': 'error', - 'object-curly-spacing': [ - 'error', - 'always', - ], - 'object-shorthand': 'off', - 'one-var': 'off', - 'one-var-declaration-per-line': 'error', - 'operator-assignment': [ - 'error', - 'always', - ], - 'operator-linebreak': 'error', - 'padded-blocks': 'off', - 'padding-line-between-statements': 'error', - 'prefer-arrow-callback': 'error', - 'prefer-const': 'error', - 'prefer-destructuring': 'off', - 'prefer-exponentiation-operator': 'error', - 'prefer-named-capture-group': 'off', - 'prefer-numeric-literals': 'error', - 'prefer-object-spread': 'error', - 'prefer-promise-reject-errors': 'error', - 'prefer-regex-literals': 'error', - 'prefer-rest-params': 'error', - 'prefer-spread': 'error', - 'prefer-template': 'error', - 'quote-props': 'off', - 'quotes': [ - 'error', - 'single', - ], - 'radix': [ - 'error', - 'as-needed', - ], - 'require-atomic-updates': 'error', - 'require-await': 'off', - 'require-unicode-regexp': 'off', - 'rest-spread-spacing': [ - 'error', - 'never', - ], - 'semi': 'error', - 'semi-spacing': [ - 'error', - { - 'after': true, - 'before': false, - }, - ], - 'semi-style': [ - 'error', - 'last', - ], - 'sort-imports': 'error', - 'sort-keys': 'off', - 'sort-vars': 'error', - 'space-before-blocks': 'error', - 'space-before-function-paren': 'off', - 'space-in-parens': [ - 'error', - 'never', - ], - 'space-infix-ops': 'off', - 'space-unary-ops': [ - 'error', - { - 'nonwords': false, - 'words': true, - }, - ], - 'spaced-comment': 'off', - 'strict': 'error', - 'switch-colon-spacing': 'error', - 'symbol-description': 'error', - 'template-curly-spacing': [ - 'error', - 'never', - ], - 'template-tag-spacing': 'error', - 'unicode-bom': [ - 'error', - 'never', - ], - 'vars-on-top': 'error', - 'wrap-iife': 'error', - 'wrap-regex': 'error', - 'yield-star-spacing': 'error', - 'yoda': [ - 'error', - 'never', - ], - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..643dadd5 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,407 @@ +{ + "env": { + "browser": false, + "node": true, + "commonjs": true, + "es2022": true + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest" + }, + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "ignorePatterns": [ + "node_modules/", + "dist/" + ], + "rules": { + "accessor-pairs": "error", + "array-bracket-newline": "off", + "array-bracket-spacing": "off", + "array-callback-return": "error", + "array-element-newline": "off", + "arrow-body-style": "error", + "arrow-parens": "off", + "arrow-spacing": [ + "error", + { + "after": true, + "before": true + } + ], + "block-scoped-var": "error", + "block-spacing": "error", + "brace-style": [ + "error", + "1tbs" + ], + "camelcase": "off", + "capitalized-comments": "off", + "class-methods-use-this": "error", + "comma-dangle": [ + "error", + { + "arrays": "always-multiline", + "objects": "always-multiline", + "imports": "always-multiline", + "exports": "always-multiline", + "functions": "ignore" + } + ], + "comma-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "comma-style": [ + "error", + "last" + ], + "complexity": "off", + "computed-property-spacing": [ + "error", + "never" + ], + "consistent-return": "off", + "consistent-this": "error", + "curly": "off", + "default-case": "error", + "default-case-last": "error", + "default-param-last": "error", + "dot-location": [ + "error", + "property" + ], + "dot-notation": "error", + "eol-last": [ + "error", + "always" + ], + "eqeqeq": "error", + "func-call-spacing": "error", + "func-name-matching": "error", + "func-names": "error", + "func-style": [ + "error", + "declaration", + { + "allowArrowFunctions": true + } + ], + "function-call-argument-newline": [ + "error", + "consistent" + ], + "function-paren-newline": "off", + "generator-star-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "grouped-accessor-pairs": "error", + "guard-for-in": "error", + "id-denylist": "error", + "id-length": "off", + "id-match": "error", + "implicit-arrow-linebreak": "off", + "indent": "off", + "init-declarations": "off", + "jsx-quotes": "error", + "key-spacing": "error", + "keyword-spacing": [ + "error", + { + "after": true, + "before": true + } + ], + "line-comment-position": "off", + "linebreak-style": [ + "error", + "windows" + ], + "lines-around-comment": "off", + "lines-between-class-members": [ + "error", + "always", + { + "exceptAfterSingleLine": true + } + ], + "max-classes-per-file": "off", + "max-depth": "error", + "max-len": "off", + "max-lines": "off", + "max-lines-per-function": "off", + "max-nested-callbacks": "error", + "max-params": "off", + "max-statements": "off", + "max-statements-per-line": "error", + "multiline-comment-style": [ + "error", + "separate-lines" + ], + "multiline-ternary": [ + "error", + "never" + ], + "new-parens": "error", + "newline-per-chained-call": "off", + "no-alert": "error", + "no-array-constructor": "error", + "no-await-in-loop": "off", + "no-async-promise-executor": "off", + "no-bitwise": "warn", + "no-caller": "error", + "no-confusing-arrow": "off", + "no-console": "off", + "no-constructor-return": "error", + "no-continue": "off", + "no-div-regex": "error", + "no-duplicate-imports": "error", + "no-else-return": "off", + "no-empty": [ + "error", + { + "allowEmptyCatch": true + } + ], + "no-empty-function": "off", + "no-eq-null": "error", + "no-eval": "error", + "no-extend-native": "error", + "no-extra-bind": "error", + "no-extra-label": "error", + "no-extra-parens": "off", + "no-floating-decimal": "error", + "no-implicit-coercion": "error", + "no-implicit-globals": "error", + "no-implied-eval": "error", + "no-inline-comments": "off", + "no-invalid-this": "error", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "error", + "no-loop-func": "error", + "no-loss-of-precision": "error", + "no-magic-numbers": [ + "off", + { + "ignoreArrayIndexes": true, + "ignoreDefaultValues": true, + "ignore": [ + 0, + 1 + ] + } + ], + "no-mixed-operators": [ + "error", + { + "allowSamePrecedence": true + } + ], + "no-multi-assign": "error", + "no-multi-spaces": "error", + "no-multi-str": "error", + "no-multiple-empty-lines": "error", + "no-negated-condition": "error", + "no-nested-ternary": "off", + "no-new": "error", + "no-new-func": "error", + "no-new-object": "error", + "no-new-wrappers": "error", + "no-nonoctal-decimal-escape": "error", + "no-octal-escape": "error", + "no-param-reassign": "error", + "no-plusplus": [ + "error", + { + "allowForLoopAfterthoughts": true + } + ], + "no-promise-executor-return": "off", + "no-proto": "error", + "no-restricted-exports": "error", + "no-restricted-globals": "error", + "no-restricted-imports": "error", + "no-restricted-properties": "error", + "no-restricted-syntax": "error", + "no-return-assign": "error", + "no-return-await": "off", + "no-script-url": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow": "off", + "no-tabs": "error", + "no-template-curly-in-string": "error", + "no-ternary": "off", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef-init": "error", + "no-undefined": "off", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": "off", + "no-unreachable-loop": "error", + "no-unsafe-optional-chaining": "error", + "no-unused-expressions": "error", + "no-unused-vars": "off", + "no-use-before-define": "off", + "no-useless-backreference": "error", + "no-useless-call": "error", + "no-useless-computed-key": "off", + "no-useless-concat": "error", + "no-useless-constructor": "off", + "no-useless-escape": "off", + "no-useless-return": "off", + "no-var": "error", + "no-void": "error", + "no-warning-comments": "error", + "no-whitespace-before-property": "error", + "nonblock-statement-body-position": "error", + "object-curly-newline": "error", + "object-curly-spacing": [ + "error", + "always" + ], + "object-shorthand": "off", + "one-var": "off", + "one-var-declaration-per-line": "error", + "operator-assignment": [ + "error", + "always" + ], + "operator-linebreak": "error", + "padded-blocks": "off", + "padding-line-between-statements": "error", + "prefer-arrow-callback": "error", + "prefer-const": "error", + "prefer-destructuring": "off", + "prefer-exponentiation-operator": "error", + "prefer-named-capture-group": "off", + "prefer-numeric-literals": "error", + "prefer-object-spread": "error", + "prefer-promise-reject-errors": "error", + "prefer-regex-literals": "error", + "prefer-rest-params": "error", + "prefer-spread": "error", + "prefer-template": "error", + "quote-props": "off", + "quotes": [ + "error", + "single" + ], + "radix": [ + "warn", + "always" + ], + "require-atomic-updates": "error", + "require-await": "off", + "require-unicode-regexp": "off", + "rest-spread-spacing": [ + "error", + "never" + ], + "semi": [ + "error", + "always" + ], + "semi-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "semi-style": [ + "error", + "last" + ], + "sort-imports": [ + "error", + { + "ignoreCase": false, + "ignoreDeclarationSort": false, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": [ + "none", + "all", + "multiple", + "single" + ], + "allowSeparatedGroups": true + } + ], + "sort-keys": "off", + "sort-vars": "error", + "space-before-blocks": "error", + "space-before-function-paren": "off", + "space-in-parens": [ + "error", + "never" + ], + "space-infix-ops": "off", + "space-unary-ops": [ + "error", + { + "nonwords": false, + "words": true + } + ], + "spaced-comment": "off", + "switch-colon-spacing": "error", + "symbol-description": "error", + "template-curly-spacing": [ + "error", + "never" + ], + "template-tag-spacing": "error", + "unicode-bom": [ + "error", + "never" + ], + "vars-on-top": "error", + "wrap-iife": "error", + "wrap-regex": "error", + "yield-star-spacing": "error", + "yoda": [ + "error", + "never" + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "vars": "all", + "args": "none", + "ignoreRestSiblings": true, + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_", + "destructuredArrayIgnorePattern": "^_" + } + ], + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-use-before-define": [ + "error", + { + "ignoreTypeReferences": true + } + ] + } +} diff --git a/dist/bot/bot.js b/dist/bot/bot.js new file mode 100644 index 00000000..2eb4ee25 --- /dev/null +++ b/dist/bot/bot.js @@ -0,0 +1,41 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const node_fs_1 = __importDefault(require("node:fs")); +const node_path_1 = __importDefault(require("node:path")); +const discord_client_js_1 = require("./discord_client.js"); +//---------------------------------------------------------------------------------------------------------------// +async function main() { + const event_files_path = node_path_1.default.join(process.cwd(), './src/bot/events/'); + const event_files = node_fs_1.default.readdirSync(event_files_path).filter(file => file.endsWith('.js')); + /* register events */ + for (const event_file of event_files) { + const { default: bot_event } = await Promise.resolve().then(() => __importStar(require(node_path_1.default.join(event_files_path, event_file)))); + discord_client_js_1.client.on(bot_event.name, bot_event.handler); + } +} +main(); +//# sourceMappingURL=bot.js.map \ No newline at end of file diff --git a/dist/bot/bot.js.map b/dist/bot/bot.js.map new file mode 100644 index 00000000..245ee147 --- /dev/null +++ b/dist/bot/bot.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bot.js","sourceRoot":"","sources":["../../src/bot/bot.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;AAExD,mHAAmH;AAEnH,sDAAyB;AAEzB,0DAA6B;AAE7B,2DAA6C;AAE7C,mHAAmH;AAEnH,KAAK,UAAU,IAAI;IACf,MAAM,gBAAgB,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,iBAAE,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAE1F,qBAAqB;IACrB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,wDAAa,mBAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAC,CAAC;QACrF,0BAAM,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;KAChD;AACL,CAAC;AAED,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/ban.js b/dist/bot/commands/ban.js new file mode 100644 index 00000000..382848b2 --- /dev/null +++ b/dist/bot/commands/ban.js @@ -0,0 +1,109 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { command_permission_levels } = require('../common/bot.js'); +const { logModerationActionToDatabase } = require('../handlers/log_moderation_action_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'ban', + description: 'bans a user from the server', + usage: '@mention reason', + aliases: ['ban'], + permission_level: command_permission_levels.MODERATORS, + cooldown: 2_000, + async execute(message, args) { + const { command_args } = args; + const staff_member = message.member; + const member_lookup_query = message.mentions.members.first()?.id ?? command_args[0]; + const member = message.guild.members.resolve(member_lookup_query); + const reason = command_args.slice(1).join(' ').trim() || 'no reason was specified'; + /* handle when a member is not specified */ + if (!member) { + await message.reply({ + content: 'You need to specify a user when using this command!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies themself */ + if (staff_member.id === member.id) { + await message.reply({ + content: 'You aren\'t allowed to ban yourself!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies this bot */ + if (member.id === message.client.user.id) { + await message.reply({ + content: 'You aren\'t allowed to ban me!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies the guild owner */ + if (member.id === message.guild.ownerId) { + await message.reply({ + content: 'You aren\'t allowed to ban the owner of this server!', + }); + return; + } + /* handle when a staff member tries to moderate someone with an equal/higher role */ + if (staff_member.roles.highest.comparePositionTo(member.roles.highest) <= 0) { + await message.reply({ + content: 'You aren\'t allowed to ban someone with an equal/higher role!', + }).catch(console.warn); + return; + } + const moderation_message_options = { + content: [ + `${member}`, + `You were banned from the Inertia Lighting discord by ${staff_member.user} for:`, + '\`\`\`', + `${reason}`, + '\`\`\`', + ].join('\n'), + }; + /* dm the member */ + try { + const dm_channel = await member.createDM(); + await dm_channel.send(moderation_message_options); + } + catch { + // ignore any errors + } + /* message the member in the server */ + await message.channel.send(moderation_message_options).catch(console.warn); + /* perform the moderation action on the member */ + try { + await member.ban({ reason: reason }); + } + catch (error) { + console.trace(error); + await message.reply({ + content: 'Failed to ban that member!', + }).catch(console.warn); + return; + } + /* log to the database */ + const successfully_logged_to_database = await logModerationActionToDatabase({ + discord_user_id: member.id, + }, { + type: 'BAN', + epoch: Date.now(), + reason: reason, + staff_member_id: message.member.id, + }); + /* if logging to the database failed, dm the staff member */ + if (!successfully_logged_to_database) { + try { + const staff_member_dm_channel = await message.author.createDM(); + staff_member_dm_channel.send({ + content: `${message.author}, something went wrong while logging to the database, please contact our development team!`, + }); + } + catch { + // ignore any errors + } + } + }, +}; +//# sourceMappingURL=ban.js.map \ No newline at end of file diff --git a/dist/bot/commands/ban.js.map b/dist/bot/commands/ban.js.map new file mode 100644 index 00000000..81f2c9d7 --- /dev/null +++ b/dist/bot/commands/ban.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ban.js","sourceRoot":"","sources":["../../../src/bot/commands/ban.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAClE,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAElG,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,6BAA6B;IAC1C,KAAK,EAAE,iBAAiB;IACxB,OAAO,EAAE,CAAC,KAAK,CAAC;IAChB,gBAAgB,EAAE,yBAAyB,CAAC,UAAU;IACtD,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAE9B,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;QACpC,MAAM,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,YAAY,C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I,CAAC,+BAA+B,EAAE;YAClC,IAAI;gBACA,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAChE,uBAAuB,CAAC,IAAI,CAAC;oBACzB,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,4FAA4F;iBACzH,CAAC,CAAC;aACN;YAAC,MAAM;gBACJ,oBAAoB;aACvB;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/blacklist.js b/dist/bot/commands/blacklist.js new file mode 100644 index 00000000..0af031a8 --- /dev/null +++ b/dist/bot/commands/blacklist.js @@ -0,0 +1,287 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const moment = require('moment-timezone'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * Fetches a user in the users database + * @param {String} user_lookup_query either a discord_user_id or roblox_user_id + * @returns {Promise} db_user_data + */ +async function findUserInUsersDatabase(user_lookup_query) { + if (typeof user_lookup_query !== 'string') + throw new TypeError('\`user_lookup_query\` must be a string'); + const [db_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + $or: [ + { 'identity.discord_user_id': user_lookup_query }, + { 'identity.roblox_user_id': user_lookup_query }, + ], + }, { + projection: { + '_id': false, + }, + }); + return db_user_data; +} +/** + * Fetches a user in the blacklisted-users database + * @param {String} user_lookup_query either a discord_user_id or roblox_user_id + * @returns {Promise} db_blacklisted_user_data + */ +async function findUserInBlacklistedUsersDatabase(user_lookup_query) { + if (typeof user_lookup_query !== 'string') + throw new TypeError('\`user_lookup_query\` must be a string'); + const [db_blacklisted_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + $or: [ + { 'identity.discord_user_id': user_lookup_query }, + { 'identity.roblox_user_id': user_lookup_query }, + ], + }, { + projection: { + '_id': false, + }, + }); + return db_blacklisted_user_data; +} +/** + * Adds a user to the blacklisted-users database + * @param {Object} identity + * @param {String} identity.discord_user_id + * @param {String} identity.roblox_user_id + * @param {Object} blacklist_metadata + * @param {Number} blacklist_metadata.epoch + * @param {String} blacklist_metadata.reason + * @param {String} blacklist_metadata.staff_member_id + * @returns {Promise} success or failure + */ +async function addUserToBlacklistedUsersDatabase({ discord_user_id, roblox_user_id }, { epoch, reason, staff_member_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string'); + if (typeof roblox_user_id !== 'string') + throw new TypeError('\`roblox_user_id\` must be a string'); + if (typeof epoch !== 'number') + throw new TypeError('\`epoch\` must be a number'); + if (typeof reason !== 'string') + throw new TypeError('\`reason\` must be a string'); + if (typeof staff_member_id !== 'string') + throw new TypeError('\`staff_member_id\` must be a string'); + try { + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': discord_user_id, + 'identity.roblox_user_id': roblox_user_id, + }, { + $set: { + 'epoch': epoch, + 'reason': reason, + 'staff_member_id': staff_member_id, + }, + }, { + upsert: true, + }); + } + catch (error) { + console.trace(error); + return false; // user was not added to blacklist + } + return true; // user was added to blacklist +} +/** + * Removes a user from the blacklisted-users database + * @param {Object} identity + * @param {String} identity.discord_user_id + * @param {String} identity.roblox_user_id + * @returns {Promise} success or failure + */ +async function removeUserFromBlacklistedUsersDatabase({ discord_user_id, roblox_user_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string'); + if (typeof roblox_user_id !== 'string') + throw new TypeError('\`roblox_user_id\` must be a string'); + try { + await go_mongo_db.remove(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': discord_user_id, + 'identity.roblox_user_id': roblox_user_id, + }); + } + catch (error) { + console.trace(error); + return false; // user was not removed from blacklist + } + return true; // user was removed from blacklist +} +//---------------------------------------------------------------------------------------------------------------// +/** + * Check if the staff member is allowed to blacklist the potential user. + * @param {Guild} guild + * @param {String} staff_member_id + * @param {String} discord_user_id + * @returns {Promise} + */ +async function isStaffMemberAllowedToBlacklistUser(guild, staff_member_id, discord_user_id) { + if (!guild) + throw new TypeError('\`guild\` was undefined'); + if (!staff_member_id) + throw new TypeError('\`staff_member_id\` was undefined'); + if (!discord_user_id) + throw new TypeError('\`user_id\` was undefined'); + /* don't let staff blacklist themselves */ + if (staff_member_id === discord_user_id) + return false; + /* check that the staff member exists in the guild */ + const staff_member = await guild.members.fetch(staff_member_id).catch(() => undefined); + if (!staff_member) + return false; // if the staff member somehow doesn't exist in the guild, don't allow them to blacklist users + /* check if the user exists in the guild */ + const member_being_blacklisted = await guild.members.fetch(discord_user_id).catch(() => undefined); + if (!member_being_blacklisted) + return true; // assume that the user can be blacklisted since they don't exist in the guild + /* check the role hierarchy since they exist in the guild */ + const staff_member_role_hierarchy_is_greater = staff_member.roles.highest.comparePositionTo(member_being_blacklisted.roles.highest) > 0; + return staff_member_role_hierarchy_is_greater; +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'blacklist', + description: 'blacklists a specified user in the database', + aliases: ['blacklist'], + permission_level: command_permission_levels.ADMINS, + async execute(message, args) { + const { command_prefix, command_name, command_args } = args; + const sub_command_name = (command_args[0] ?? '').toLowerCase(); + const sub_command_args = command_args.slice(1); + switch (sub_command_name) { + case 'add': { + const db_user_lookup_query = (sub_command_args[0] ?? '').replace(/\D/gi, '').trim(); + if (!db_user_lookup_query) { + await message.reply({ + content: 'You need to specify a discord_user_id or roblox_user_id when using this command!', + }).catch(console.warn); + return; + } + const db_user_data_for_case_add = await findUserInUsersDatabase(db_user_lookup_query); + if (!db_user_data_for_case_add) { + await message.reply({ + content: 'You can only blacklist users that are verified in the product hub!', + }).catch(console.warn); + return; + } + const staff_member_id = message.author.id; + const staff_member_can_add_user_to_blacklist = await isStaffMemberAllowedToBlacklistUser(message.guild, staff_member_id, db_user_data_for_case_add.identity.discord_user_id); + if (!staff_member_can_add_user_to_blacklist) { + await message.reply({ + content: 'You aren\'t allowed to blacklist that user!', + }).catch(console.warn); + return; + } + const added_successfully = await addUserToBlacklistedUsersDatabase(db_user_data_for_case_add.identity, { + epoch: Date.now(), + reason: sub_command_args.slice(1).join(' ').trim() || 'no reason was specified', + staff_member_id: staff_member_id, + }); + if (!added_successfully) { + await message.reply({ + content: 'I was unable to add that user to the blacklist!\nDid you specify them after the command?', + }).catch(console.warn); + return; + } + await message.reply({ + content: `I added <@${db_user_data_for_case_add.identity.discord_user_id}> to the blacklist!`, + }).catch(console.warn); + break; + } + case 'remove': { + const db_user_lookup_query = (sub_command_args[0] ?? '').replace(/\D/gi, '').trim(); + if (!db_user_lookup_query) { + await message.reply({ + content: 'You need to specify a @mention or roblox_user_id when using this command!', + }).catch(console.warn); + return; + } + const db_user_data_for_case_remove = await findUserInUsersDatabase(db_user_lookup_query); + if (!db_user_data_for_case_remove) { + await message.reply({ + content: 'You can only un-blacklist users that are verified in the product hub!', + }).catch(console.warn); + return; + } + const staff_member_id = message.author.id; + const staff_member_can_remove_user_from_blacklist = await isStaffMemberAllowedToBlacklistUser(message.guild, staff_member_id, db_user_data_for_case_remove.identity.discord_user_id); + if (!staff_member_can_remove_user_from_blacklist) { + await message.reply({ + content: 'You aren\'t allowed to un-blacklist that user!', + }).catch(console.warn); + return; + } + const removed_successfully = await removeUserFromBlacklistedUsersDatabase(db_user_data_for_case_remove.identity); + if (!removed_successfully) { + await message.reply({ + content: 'I was unable to remove that user from the blacklist!\nDid you specify them after the command?', + }).catch(console.warn); + return; + } + await message.reply({ + content: `I removed <@${db_user_data_for_case_remove.identity.discord_user_id}> from the blacklist!`, + }).catch(console.warn); + break; + } + case 'lookup': { + const db_user_lookup_query = (sub_command_args[0] ?? '').replace(/\D/gi, '').trim(); + if (!db_user_lookup_query) { + await message.reply({ + content: 'You need to specify a @mention or roblox_user_id when using this command!', + }).catch(console.warn); + return; + } + const db_blacklisted_user_data = await findUserInBlacklistedUsersDatabase(db_user_lookup_query); + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Blacklisted User Document', + }, + description: (db_blacklisted_user_data ? [ + `**User:** <@${db_blacklisted_user_data.identity.discord_user_id}>`, + `**Roblox Id:** \`${db_blacklisted_user_data.identity.roblox_user_id}\``, + `**Staff:** <@${db_blacklisted_user_data.staff_member_id}>`, + `**Date:** \`${moment(db_blacklisted_user_data.epoch).tz('America/New_York').format('YYYY[-]MM[-]DD | hh:mm A | [GMT]ZZ')}\``, + `**Reason:** ${'```'}\n${db_blacklisted_user_data.reason}\n${'```'}`, + ].join('\n') : `${'```'}\nUser is not blacklisted!\n${'```'}`), + }), + ], + }).catch(console.warn); + break; + } + default: { + await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Blacklist System', + }, + description: [ + 'Please use one of the following sub-commands:', + '\`\`\`', + ...[ + 'add [reason]', + 'remove ', + 'lookup ', + ].map(sub_command => `${command_prefix}${command_name} ${sub_command}`), + '\`\`\`', + ].join('\n'), + }), + ], + }).catch(console.warn); + break; + } + } + }, +}; +//# sourceMappingURL=blacklist.js.map \ No newline at end of file diff --git a/dist/bot/commands/blacklist.js.map b/dist/bot/commands/blacklist.js.map new file mode 100644 index 00000000..1e4b3c75 --- /dev/null +++ b/dist/bot/commands/blacklist.js.map @@ -0,0 +1 @@ +{"version":3,"file":"blacklist.js","sourceRoot":"","sources":["../../../src/bot/commands/blacklist.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH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,CAAC,IAAI;gCAC7H,eAAe,KAAK,KAAK,wBAAwB,CAAC,MAAM,KAAK,KAAK,EAAE;6BACvE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,+BAA+B,KAAK,EAAE,CAAC;yBACjE,CAAC;qBACL;iBACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvB,MAAM;aACT;YACD,OAAO,CAAC,CAAC;gBACL,MAAM,OAAO,CAAC,KAAK,CAAC;oBAChB,MAAM,EAAE;wBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;4BACrB,KAAK,EAAE,QAAQ;4BACf,MAAM,EAAE;gCACJ,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;gCAC7D,IAAI,EAAE,qCAAqC;6BAC9C;4BACD,WAAW,EAAE;gCACT,+CAA+C;gCAC/C,QAAQ;gCACR,GAAG;oCACC,iDAAiD;oCACjD,2CAA2C;oCAC3C,2CAA2C;iCAC9C,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,cAAc,GAAG,YAAY,IAAI,WAAW,EAAE,CAAC;gCACvE,QAAQ;6BACX,CAAC,IAAI,CAAC,IAAI,CAAC;yBACf,CAAC;qBACL;iBACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvB,MAAM;aACT;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/demo.js b/dist/bot/commands/demo.js new file mode 100644 index 00000000..78aa3510 --- /dev/null +++ b/dist/bot/commands/demo.js @@ -0,0 +1,38 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'demo', + description: 'why does this even exist', + aliases: ['demo', 'test', 'testing'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'You can try out our products from the testing game!', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Testing Game', + url: 'https://demo.inertia.lighting/', + }, + ], + }, + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=demo.js.map \ No newline at end of file diff --git a/dist/bot/commands/demo.js.map b/dist/bot/commands/demo.js.map new file mode 100644 index 00000000..5f68c489 --- /dev/null +++ b/dist/bot/commands/demo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../../src/bot/commands/demo.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,0BAA0B;IACvC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;IACpC,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,qDAAqD;iBACrE,CAAC;aACL;YACD,UAAU,EAAE;gBACR;oBACI,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE;wBACR;4BACI,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,cAAc;4BACrB,GAAG,EAAE,gCAAgC;yBACxC;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/downloads.js b/dist/bot/commands/downloads.js new file mode 100644 index 00000000..69f65268 --- /dev/null +++ b/dist/bot/commands/downloads.js @@ -0,0 +1,38 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'downloads', + description: 'why does this even exist', + aliases: ['downloads', 'download', 'roles', 'retrieve', 'get'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'You can download purchased products from our website!', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Products & Downloads', + url: 'https://inertia.lighting/products', + }, + ], + }, + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=downloads.js.map \ No newline at end of file diff --git a/dist/bot/commands/downloads.js.map b/dist/bot/commands/downloads.js.map new file mode 100644 index 00000000..722d2c69 --- /dev/null +++ b/dist/bot/commands/downloads.js.map @@ -0,0 +1 @@ +{"version":3,"file":"downloads.js","sourceRoot":"","sources":["../../../src/bot/commands/downloads.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,0BAA0B;IACvC,OAAO,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC;IAC9D,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,uDAAuD;iBACvE,CAAC;aACL;YACD,UAAU,EAAE;gBACR;oBACI,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE;wBACR;4BACI,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,sBAAsB;4BAC7B,GAAG,EAAE,mCAAmC;yBAC3C;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/echo.js b/dist/bot/commands/echo.js new file mode 100644 index 00000000..8366fd10 --- /dev/null +++ b/dist/bot/commands/echo.js @@ -0,0 +1,35 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Timer } = require('../../utilities.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'echo', + description: 'echoes what a user says into the same channel', + aliases: ['echo'], + permission_level: command_permission_levels.TEAM_LEADERS, + async execute(message, args) { + const { command_prefix, command_name, command_args } = args; + const message_content_to_echo = command_args.join(' ').trim(); + if (message_content_to_echo.length === 0) { + message.reply({ + content: [ + 'Please provide a message to echo!', + 'Example:', + '\`\`\`', + `${command_prefix}${command_name} Hello world!`, + '\`\`\`', + ].join('\n'), + }).catch(console.warn); + return; + } + message.channel.send({ + content: `${message_content_to_echo}`, + }).catch(console.warn); + await Timer(500); // prevent api abuse + message.delete().catch(console.warn); + }, +}; +//# sourceMappingURL=echo.js.map \ No newline at end of file diff --git a/dist/bot/commands/echo.js.map b/dist/bot/commands/echo.js.map new file mode 100644 index 00000000..7c85c2ee --- /dev/null +++ b/dist/bot/commands/echo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"echo.js","sourceRoot":"","sources":["../../../src/bot/commands/echo.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEhD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,+CAA+C;IAC5D,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,gBAAgB,EAAE,yBAAyB,CAAC,YAAY;IACxD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAE5D,MAAM,uBAAuB,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAE9D,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC,EAAE;YACtC,OAAO,CAAC,KAAK,CAAC;gBACV,OAAO,EAAE;oBACL,mCAAmC;oBACnC,UAAU;oBACV,QAAQ;oBACR,GAAG,cAAc,GAAG,YAAY,eAAe;oBAC/C,QAAQ;iBACX,CAAC,IAAI,CAAC,IAAI,CAAC;aACf,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,OAAO;SACV;QAED,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,OAAO,EAAE,GAAG,uBAAuB,EAAE;SACxC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEvB,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB;QACtC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/help.js b/dist/bot/commands/help.js new file mode 100644 index 00000000..038fd5c2 --- /dev/null +++ b/dist/bot/commands/help.js @@ -0,0 +1,71 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../discord_client.js'); +const { getUserPermissionLevel, command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'help', + description: 'shows a list of commands for you to use.', + usage: '[command_name]', + aliases: ['help', 'commands'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 2_500, + async execute(message, args) { + const { command_prefix, command_args } = args; + const user_permission_level = getUserPermissionLevel(message.member); + const commands_visible_to_user = client.$.commands.filter(cmd => user_permission_level >= cmd.permission_level).sort((a, b) => a.permission_level - b.permission_level); + const specified_command_alias = command_args[0]; + if (specified_command_alias?.length > 0) { + /* display help for a specified command alias */ + const specified_command = commands_visible_to_user.find(cmd => cmd.aliases.includes(specified_command_alias.toLowerCase())); + if (specified_command) { + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${message.author.displayAvatarURL({ dynamic: true })}`, + name: `${message.author.tag}`, + }, + description: [ + `**Name:** ${specified_command.name}`, + `**Aliases:** ${specified_command.aliases.join(', ') ?? 'n/a'}`, + `**Description:** ${specified_command.description ?? 'n/a'}`, + `**Usage:** ${specified_command.usage ? `\`${command_prefix}${specified_command.name} ${specified_command.usage}\`` : 'n/a'}`, + `**Permission Level:** \`${specified_command.permission_level}\``, + ].join('\n'), + }), + ], + }).catch(console.warn); + } + else { + message.reply({ + content: `\`${specified_command_alias}\` is not a valid command alias to lookup!`, + }).catch(console.warn); + } + } + else { + /* display all commands visible to the user */ + const commands_visible_to_user_with_prefix = commands_visible_to_user.map(command => command.aliases.map(command_alias => `${command_prefix}${command_alias.replace('#{cp}', `${command_prefix}`)}`).join(' | ')); + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${message.author.displayAvatarURL({ dynamic: true })}`, + name: `${message.author.tag}`, + }, + title: 'Here\'s a list of all commands that you may use!', + description: [ + `You can send \`${command_prefix}help [command name]\` to get info on a specific command!`, + `\`\`\`\n${commands_visible_to_user_with_prefix.join('\n')}\n\`\`\``, + ].join('\n'), + }), + ], + }).catch(console.warn); + } + }, +}; +//# sourceMappingURL=help.js.map \ No newline at end of file diff --git a/dist/bot/commands/help.js.map b/dist/bot/commands/help.js.map new file mode 100644 index 00000000..98e8221a --- /dev/null +++ b/dist/bot/commands/help.js.map @@ -0,0 +1 @@ +{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/bot/commands/help.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,MAAM,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,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AC,MAAM,CAAC,GAAG,EAAE;yBAChC;wBACD,KAAK,EAAE,kDAAkD;wBACzD,WAAW,EAAE;4BACT,kBAAkB,cAAc,0DAA0D;4BAC1F,WAAW,oCAAoC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU;yBACvE,CAAC,IAAI,CAAC,IAAI,CAAC;qBACf,CAAC;iBACL;aACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/identity_token.js b/dist/bot/commands/identity_token.js new file mode 100644 index 00000000..9f2ef43b --- /dev/null +++ b/dist/bot/commands/identity_token.js @@ -0,0 +1,26 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'identity_token', + description: 'n/a', + aliases: ['identity_token'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 15_000, + async execute(message, args) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'What are Identity Tokens?', + description: 'We don\'t use identity tokens anymore, please just ignore identity tokens anytime that you see it.', + }), + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=identity_token.js.map \ No newline at end of file diff --git a/dist/bot/commands/identity_token.js.map b/dist/bot/commands/identity_token.js.map new file mode 100644 index 00000000..99e8ded3 --- /dev/null +++ b/dist/bot/commands/identity_token.js.map @@ -0,0 +1 @@ +{"version":3,"file":"identity_token.js","sourceRoot":"","sources":["../../../src/bot/commands/identity_token.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,OAAO,CAAC,KAAK,CAAC;YACV,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,KAAK,EAAE,2BAA2B;oBAClC,WAAW,EAAE,oGAAoG;iBACpH,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/kick.js b/dist/bot/commands/kick.js new file mode 100644 index 00000000..1bbb1161 --- /dev/null +++ b/dist/bot/commands/kick.js @@ -0,0 +1,107 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { command_permission_levels } = require('../common/bot.js'); +const { logModerationActionToDatabase } = require('../handlers/log_moderation_action_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'kick', + description: 'kicks a user from the server', + usage: '@mention reason', + aliases: ['kick'], + permission_level: command_permission_levels.MODERATORS, + cooldown: 2_000, + async execute(message, args) { + const { command_args } = args; + const staff_member = message.member; + const member_lookup_query = message.mentions.members.first()?.id ?? command_args[0]; + const member = message.guild.members.resolve(member_lookup_query); + const reason = command_args.slice(1).join(' ').trim() || 'no reason was specified'; + /* handle when a member is not specified */ + if (!member) { + await message.reply({ + content: 'You need to specify a user when using this command!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies themself */ + if (staff_member.id === member.id) { + await message.reply({ + content: 'You aren\'t allowed to kick yourself!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies this bot */ + if (member.id === message.client.user.id) { + await message.reply({ + content: 'You aren\'t allowed to kick me!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies the guild owner */ + if (member.id === message.guild.ownerId) { + await message.reply({ + content: 'You aren\'t allowed to kick the owner of this server!', + }); + return; + } + /* handle when a staff member tries to moderate someone with an equal/higher role */ + if (staff_member.roles.highest.comparePositionTo(member.roles.highest) <= 0) { + await message.reply({ + content: 'You aren\'t allowed to kick someone with an equal/higher role!', + }).catch(console.warn); + return; + } + const moderation_message_options = { + content: [ + `${member}`, + `You were kicked from the Inertia Lighting discord by ${staff_member.user} for:`, + '\`\`\`', + `${reason}`, + '\`\`\`', + ].join('\n'), + }; + /* dm the member */ + try { + const dm_channel = await member.createDM(); + await dm_channel.send(moderation_message_options); + } + catch { + // ignore any errors + } + /* message the member in the server */ + await message.channel.send(moderation_message_options).catch(console.warn); + /* perform the moderation action on the member */ + try { + await member.kick(reason); + } + catch (error) { + console.trace(error); + await message.reply({ + content: 'Failed to kick that member!', + }).catch(console.warn); + return; + } + /* log to the database */ + const successfully_logged_to_database = await logModerationActionToDatabase({ + discord_user_id: member.id, + }, { + type: 'KICK', + epoch: Date.now(), + reason: reason, + staff_member_id: message.member.id, + }); + /* if logging to the database failed, dm the staff member */ + if (!successfully_logged_to_database) { + try { + const staff_member_dm_channel = await message.author.createDM(); + staff_member_dm_channel.send(`${message.author}, something went wrong while logging to the database, please contact our development team!`); + } + catch { + // ignore any errors + } + } + }, +}; +//# sourceMappingURL=kick.js.map \ No newline at end of file diff --git a/dist/bot/commands/kick.js.map b/dist/bot/commands/kick.js.map new file mode 100644 index 00000000..0992dd98 --- /dev/null +++ b/dist/bot/commands/kick.js.map @@ -0,0 +1 @@ +{"version":3,"file":"kick.js","sourceRoot":"","sources":["../../../src/bot/commands/kick.js"],"names":[],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AI,CAAC,0BAA0B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE3E,iDAAiD;QACjD,IAAI;YACA,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM,OAAO,CAAC,KAAK,CAAC;gBAChB,OAAO,EAAE,6BAA6B;aACzC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,OAAO;SACV;QAED,yBAAyB;QACzB,MAAM,+BAA+B,GAAG,MAAM,6BAA6B,CAAC;YACxE,eAAe,EAAE,MAAM,CAAC,EAAE;SAC7B,EAAE;YACC,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE;YACjB,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;SACrC,CAAC,CAAC;QAEH,4DAA4D;QAC5D,IAAI,CAAC,+BAA+B,EAAE;YAClC,IAAI;gBACA,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAChE,uBAAuB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,4FAA4F,CAAC,CAAC;aAC/I;YAAC,MAAM;gBACJ,oBAAoB;aACvB;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/lookup.js b/dist/bot/commands/lookup.js new file mode 100644 index 00000000..ac472175 --- /dev/null +++ b/dist/bot/commands/lookup.js @@ -0,0 +1,85 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'lookup', + description: 'looks up a specified user in the database', + aliases: ['lookup'], + permission_level: command_permission_levels.STAFF, + cooldown: 2_500, + async execute(message, args) { + const { command_args } = args; + const lookup_discord_user_id = message.mentions.members.first()?.id; + const lookup_roblox_user_id = command_args[0]; + if (!(lookup_discord_user_id || lookup_roblox_user_id)) { + message.reply({ + content: 'provide a \`roblox_user_id\` or a discord @user mention!', + }).catch(console.warn); + return; + } + /* fetch blacklisted user data */ + const [db_blacklisted_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + ...(lookup_discord_user_id ? { + 'identity.discord_user_id': lookup_discord_user_id, + } : { + 'identity.roblox_user_id': lookup_roblox_user_id, + }), + }, { + projection: { + '_id': false, + }, + }); + /* fetch the user document */ + const [db_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + ...(lookup_discord_user_id ? { + 'identity.discord_user_id': lookup_discord_user_id, + } : { + 'identity.roblox_user_id': lookup_roblox_user_id, + }), + }, { + projection: { + '_id': false, + }, + }); + /* send the user document */ + await message.channel.send({ + embeds: [ + ...(db_blacklisted_user_data ? [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Blacklist System', + }, + description: [ + '\`\`\`', + 'User is blacklisted from using Inertia Lighting products!', + '\`\`\`', + '\`\`\`json', + `${Discord.Util.cleanCodeBlockContent(JSON.stringify(db_blacklisted_user_data, null, 2))}`, + '\`\`\`', + ].join('\n'), + }), + ] : []), + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Lookup System', + }, + description: [ + '\`\`\`json', + `${Discord.Util.cleanCodeBlockContent(JSON.stringify(db_user_data ?? 'user not found in database', null, 2))}`, + '\`\`\`', + ].join('\n'), + }), + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=lookup.js.map \ No newline at end of file diff --git a/dist/bot/commands/lookup.js.map b/dist/bot/commands/lookup.js.map new file mode 100644 index 00000000..afc13487 --- /dev/null +++ b/dist/bot/commands/lookup.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../../src/bot/commands/lookup.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAExD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,2CAA2C;IACxD,OAAO,EAAE,CAAC,QAAQ,CAAC;IACnB,gBAAgB,EAAE,yBAAyB,CAAC,KAAK;IACjD,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAE9B,MAAM,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QACpE,MAAM,qBAAqB,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAE9C,IAAI,CAAC,CAAC,sBAAsB,IAAI,qBAAqB,CAAC,EAAE;YACpD,OAAO,CAAC,KAAK,CAAC;gBACV,OAAO,EAAE,0DAA0D;aACtE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,OAAO;SACV;QAED,iCAAiC;QACjC,MAAM,CA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AE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;4BAC1F,QAAQ;yBACX,CAAC,IAAI,CAAC,IAAI,CAAC;qBACf,CAAC;iBACL,CAAC,CAAC,CAAC,EAAE,CAAC;gBACP,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,MAAM,EAAE;wBACJ,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;wBAC7D,IAAI,EAAE,uCAAuC;qBAChD;oBACD,WAAW,EAAE;wBACT,YAAY;wBACZ,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,4BAA4B,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;wBAC9G,QAAQ;qBACX,CAAC,IAAI,CAAC,IAAI,CAAC;iBACf,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/moderation_actions.js b/dist/bot/commands/moderation_actions.js new file mode 100644 index 00000000..fa8f7457 --- /dev/null +++ b/dist/bot/commands/moderation_actions.js @@ -0,0 +1,451 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const moment = require('moment-timezone'); +const { array_chunks, string_ellipses, Timer } = require('../../utilities.js'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * Displays moderation actions (for / from) the specified (member / staff member) + * @param {Discord.Message} message + * @param {'all'|'member'|'staff'|'id'} lookup_mode (default: 'member') + * @returns {Promise} + */ +async function listModerationActions(message, lookup_mode = 'member') { + if (!(message instanceof Discord.Message)) + throw new TypeError('\`message\` must be a Discord.Message'); + if (!['all', 'member', 'staff', 'id'].includes(lookup_mode)) + throw new RangeError('\`lookup_mode\` must be \'all\', \'member\', \'staff\', or \'id\''); + /* get the command arguments */ + const sub_command_args = message.content.split(/\s+/g).slice(2); + /* lookup query for database */ + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + /* send an initial message to the user */ + const bot_message = await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Loading moderation actions...', + }), + ], + }); + /* create a small user-experience delay */ + await Timer(500); + /* check if a valid query was specified */ + if (lookup_mode !== 'all' && (typeof lookup_query !== 'string' || lookup_query.length === 0)) { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'You need to specify a valid lookup query!', + }), + ], + }).catch(console.warn); + return; + } + /* fetch all moderation actions from the database */ + const db_moderation_actions = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_MODERATION_ACTION_RECORDS_COLLECTION_NAME, { + ...(lookup_mode === 'staff' ? { + 'record.staff_member_id': lookup_query, + } : lookup_mode === 'member' ? { + 'identity.discord_user_id': lookup_query, + } : lookup_mode === 'id' ? { + 'record.id': lookup_query, + } : { + /* assume that lookup_mode: 'all' is the default */ + /* in that case, we want to return all moderation actions */ + }), + }); + /* check if the member has any records */ + if (db_moderation_actions.length === 0) { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'I wasn\'t able to find any moderation actions for the specified lookup query!', + }), + ], + }).catch(console.warn); + return; + } + await bot_message.edit({ + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 2, + custom_id: 'previous', + emoji: { + id: null, + name: '⬅️', + }, + }, { + type: 2, + style: 2, + custom_id: 'next', + emoji: { + id: null, + name: '➡️', + }, + }, { + type: 2, + style: 2, + custom_id: 'stop', + emoji: { + id: null, + name: '⏹️', + }, + }, + ], + }, + ], + }); + /* sort the moderation actions by epoch (newest -> oldest) */ + const sorted_moderation_actions = db_moderation_actions.sort((a, b) => b.record.epoch - a.record.epoch); + /* split the moderation actions into a 2-dimensional array of chunks */ + const moderation_actions_chunks = array_chunks(sorted_moderation_actions, 5); + /* send a carousel containing 10 moderation actions per page */ + let page_index = 0; + async function editEmbedWithNextModerationActionsChunk() { + const moderation_actions_chunk = moderation_actions_chunks[page_index]; + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: moderation_actions_chunk.map(moderation_action => [ + `**Id** \`${moderation_action.record.id}\``, + `**Staff** <@${moderation_action.record.staff_member_id}>`, + `**Member** <@${moderation_action.identity.discord_user_id}>`, + `**Date** \`${moment(moderation_action.record.epoch).tz('America/New_York').format('YYYY[-]MM[-]DD | hh:mm A | [GMT]ZZ')}\``, + `**Type** \`${moderation_action.record.type}\``, + '**Reason**', + '\`\`\`', + `${string_ellipses(Discord.Util.cleanCodeBlockContent(moderation_action.record.reason), 250)}`, + '\`\`\`', + ].join('\n')).join('\n'), + }), + ], + }).catch(console.warn); + return; // complete async + } + await editEmbedWithNextModerationActionsChunk(); + const message_button_collector_filter = (button_interaction) => button_interaction.user.id === message.author.id; + const message_button_collector = bot_message.createMessageComponentCollector({ + filter: message_button_collector_filter, + time: 5 * 60_000, // 5 minutes + }); + message_button_collector.on('collect', async (button_interaction) => { + message_button_collector.resetTimer(); + switch (button_interaction.customId) { + case 'previous': { + page_index = page_index < moderation_actions_chunks.length - 1 ? page_index + 1 : 0; + break; + } + case 'next': { + page_index = page_index > 0 ? page_index - 1 : moderation_actions_chunks.length - 1; + break; + } + case 'stop': { + message_button_collector.stop(); + break; + } + default: { + break; + } + } + await button_interaction.deferUpdate(); + if (message_button_collector.ended) + return; + await editEmbedWithNextModerationActionsChunk(); + }); + message_button_collector.on('end', async () => { + await bot_message.delete().catch(console.warn); + }); + return; // complete async +} +/** + * Update moderation action subcommand + * @param {Discord.Message} message + */ +async function updateModerationAction(message) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + if (lookup_query.length === 0) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'You need to specify a moderation-actions id when using this command.', + }), + ], + }).catch(console.warn); + return; + } + const [db_moderation_action] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_MODERATION_ACTION_RECORDS_COLLECTION_NAME, { + 'record.id': lookup_query, + }); + if (!db_moderation_action) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'Unable to find a moderation action with the specified id!', + }), + ], + }).catch(console.warn); + return; + } + const updated_ma_reason = sub_command_args.slice(1).join(' '); + if (updated_ma_reason.length < 5) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'The supplied reason was less than 5 characters long, please be more descriptive.', + }), + ], + }).catch(console.warn); + return; + } + try { + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_MODERATION_ACTION_RECORDS_COLLECTION_NAME, { + 'record.id': db_moderation_action.record.id, + }, { + $set: { + 'record.reason': `${updated_ma_reason} `, + }, + }); + } + catch { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'Unable to update the moderation action with the specified id!', + }), + ], + }).catch(console.warn); + return; + } + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'Successfully updated the moderation action with the specified id!', + }), + ], + }).catch(console.warn); + return; // complete async +} +/** + * Removes moderation actions + * @param {Discord.Message} message + * @returns {Promise} + */ +async function clearModerationActions(message) { + if (!(message instanceof Discord.Message)) + throw new TypeError('\`message\` must be a Discord.Message'); + /* get the command arguments */ + const sub_command_args = message.content.split(/\s+/g).slice(2); + /* lookup query for database */ + const db_lookup_query = sub_command_args[0]; + /* send an initial message to the user */ + const bot_message = await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Loading moderation actions...', + }), + ], + }); + /* create a small user-experience delay */ + await Timer(500); + /* check if a valid query was specified */ + if (typeof db_lookup_query !== 'string' || db_lookup_query.length === 0) { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: 'You need to specify a @user mention or moderation action id!', + }), + ], + }).catch(console.warn); + return; + } + /* remove the member's moderation actions from the database */ + let db_delete_operation_count = 0; + try { + const db_deletion_result = await go_mongo_db.remove(process.env.MONGO_DATABASE_NAME, process.env.MONGO_MODERATION_ACTION_RECORDS_COLLECTION_NAME, { + $or: [ + { 'record.id': db_lookup_query.trim() }, + { 'identity.discord_user_id': db_lookup_query.replace(/\D/g, '').trim() }, + ], + }); + db_delete_operation_count = db_deletion_result.deletedCount ?? 0; + } + catch { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + title: 'Something went wrong!', + description: 'Please inform my developers that an error occurred while clearing moderation actions from the database!', + }), + ], + }).catch(console.warn); + return; + } + if (db_delete_operation_count === 0) { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: `No moderation actions were found for the specified query: \`${db_lookup_query}\``, + }), + ], + }).catch(console.warn); + return; + } + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + description: `Successfully cleared ${db_delete_operation_count} moderation action(s)!`, + }), + ], + }).catch(console.warn); + return; // complete async +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'moderation_actions', + description: 'displays moderation actions from the database', + aliases: ['moderation_actions', 'ma'], + permission_level: command_permission_levels.STAFF, + cooldown: 10_000, + async execute(message, args) { + const { command_prefix, command_name, command_args } = args; + const sub_command_name = `${command_args[0]}`.toLowerCase(); + switch (sub_command_name) { + case 'list': { + await listModerationActions(message, 'all'); + break; + } + case 'for': { + await listModerationActions(message, 'member'); + break; + } + case 'from': { + await listModerationActions(message, 'staff'); + break; + } + case 'lookup': { + await listModerationActions(message, 'id'); + break; + } + case 'update': { + await updateModerationAction(message); + break; + } + case 'clear': { + await clearModerationActions(message); + break; + } + default: { + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Moderation Actions', + }, + title: 'Here are the available sub-commands!', + description: [ + 'Displaying all moderation actions in the server:', + '\`\`\`', + `${command_prefix}${command_name} list`, + '\`\`\`', + 'Displaying a moderation action in the server:', + '\`\`\`', + `${command_prefix}${command_name} lookup `, + '\`\`\`', + 'Displaying moderation actions for a member in the server:', + '\`\`\`', + `${command_prefix}${command_name} for `, + '\`\`\`', + 'Displaying moderation actions from a staff member in the server:', + '\`\`\`', + `${command_prefix}${command_name} from `, + '\`\`\`', + 'Updating a moderation action in the server:', + '\`\`\`', + `${command_prefix}${command_name} update `, + '\`\`\`', + 'Clearing all moderation actions for a member in the server:', + '\`\`\`', + `${command_prefix}${command_name} clear `, + '\`\`\`', + ].join('\n'), + }), + ], + }).catch(console.warn); + break; + } + } + }, +}; +//# sourceMappingURL=moderation_actions.js.map \ No newline at end of file diff --git a/dist/bot/commands/moderation_actions.js.map b/dist/bot/commands/moderation_actions.js.map new file mode 100644 index 00000000..63b504e3 --- /dev/null +++ b/dist/bot/commands/moderation_actions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"moderation_actions.js","sourceRoot":"","sources":["../../../src/bot/commands/moderation_actions.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1C,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE/E,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAExD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH;;;;;GAKG;AACH,KAAK,UAAU,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAC,QAAQ;IAC9D,IAAI,CAAC,CAAC,OAAO,YAAY,OAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;IACxG,IAA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/E,QAAQ;6BACX,CAAC,IAAI,CAAC,IAAI,CAAC;yBACf,CAAC;qBACL;iBACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACvB,MAAM;aACT;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/notes.js b/dist/bot/commands/notes.js new file mode 100644 index 00000000..0811566e --- /dev/null +++ b/dist/bot/commands/notes.js @@ -0,0 +1,536 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +// create update remove purge lookup +//---------------------------------------------------------------------------------------------------------------// +const { command_permission_levels } = require('../common/bot.js'); +const { Discord, client } = require('../discord_client.js'); +const { Timer, array_chunks, string_ellipses } = require('../../utilities'); +const { createNoteForUser, updateNoteForUser, removeNoteFromUser, purgeNotesFromUser, lookupNotesForUser, lookupNoteForUser } = require('../handlers/user_notes_handler'); +//---------------------------------------------------------------------------------------------------------------// +/** + * Create note subcommand + * @param {Discord.Message} message + */ +async function createNoteCommand(message) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + try { + await client.users.fetch(lookup_query); + } + catch { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: `\"${lookup_query}\" is not a valid user...`, + }), + ], + }).catch(console.warn); + return; + } + const note_contents = sub_command_args.slice(1).join(' '); + if (note_contents.length < 5) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'The supplied note was less then 5 characters, please be more descriptive next time.', + }), + ], + }).catch(console.warn); + return; + } + const note_was_created_successfully = await createNoteForUser({ + discord_user_id: lookup_query, + }, { + epoch: Date.now(), + note: note_contents, + staff_member_id: message.author.id, + }); + if (!note_was_created_successfully) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'An error occurred while creating a note for the user.', + }), + ], + }).catch(console.warn); + return; + } + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'Successfully created note for user.', + }), + ], + }).catch(console.warn); +} +/** + * Update note subcommand + * @param {Discord.Message} message + */ +async function updateNoteCommand(message) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + if (lookup_query.length === 0) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'You need to specify a note id when using this command.', + }), + ], + }).catch(console.warn); + return; + } + const note_in_database = await lookupNoteForUser({ + id: lookup_query, + }); + if (!note_in_database) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'Unable to find specified note id in the database!', + }), + ], + }).catch(console.warn); + return; + } + const note_contents = sub_command_args.slice(1).join(' '); + if (note_contents.length < 5) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'The supplied note was less then 5 characters, please be more descriptive next time.', + }), + ], + }).catch(console.warn); + return; + } + const successfully_updated_note = await updateNoteForUser({ + id: note_in_database.record.id, + epoch: Date.now(), + note: note_contents, + staff_member_id: message.author.id, + }); + if (!successfully_updated_note) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'An error occurred while updating a note for the user.', + }), + ], + }).catch(console.warn); + return; + } + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'Successfully updated note for user.', + }), + ], + }).catch(console.warn); +} +/** + * Remove note subcommand + * @param {Discord.Message} message + */ +async function removeNoteCommand(message) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + if (lookup_query.length === 0) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'You need to specify a note id when using this command.', + }), + ], + }).catch(console.warn); + return; + } + const note_in_database = await lookupNoteForUser({ + id: lookup_query, + }); + if (!note_in_database) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'That note ID was not found in the database!', + }), + ], + }).catch(console.warn); + return; + } + const successfully_removed_note = await removeNoteFromUser({ id: note_in_database.record.id }); + if (!successfully_removed_note) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'An error occurred while removing a note for the user.', + }), + ], + }).catch(console.warn); + return; + } + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'Successfully removed a note from user.', + }), + ], + }).catch(console.warn); +} +/** + * Purge notes subcommand + * @param {Discord.Message} message + */ +async function purgeNotesCommand(message) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + try { + await client.users.fetch(lookup_query); + } + catch { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: `\"${lookup_query}\" is not a valid user...`, + }), + ], + }).catch(console.warn); + return; + } + const successfully_purged_notes = await purgeNotesFromUser({ discord_user_id: lookup_query }); + if (!successfully_purged_notes) { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: `An error occurred while removing all notes from <@${lookup_query}>.`, + }), + ], + }).catch(console.warn); + return; + } + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: `Successfully removed all notes from <@${lookup_query}>.`, + }), + ], + }).catch(console.warn); +} +/** + * Lookup notes subcommand + * @param {Discord.Message} message + * @param {'user_mention'|'note_id'} lookup_method + */ +async function lookupNotesCommand(message, lookup_method) { + const sub_command_args = message.content.split(/\s+/g).slice(2); + const lookup_query = (sub_command_args[0] ?? '').replace(/[^\d\w\-]/g, ''); + if (lookup_method === 'user_mention') { + try { + await client.users.fetch(lookup_query); + } + catch { + message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: `\"${lookup_query}\" was not a valid user id.`, + }), + ], + }).catch(console.warn); + return; + } + } + const bot_message = await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Loading user notes...', + }), + ], + }); + /* create a small user-experience delay */ + await Timer(500); + const user_notes = lookup_method === 'user_mention' ? (await lookupNotesForUser({ + discord_user_id: lookup_query, + })) : ([ + await lookupNoteForUser({ + id: lookup_query, + }), + ]); + if (user_notes.length === 0 || (lookup_method === 'note_id' && message.mentions.users.size > 0)) { + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: 'I wasn\'t able to find any user notes for the specified query!', + }), + ], + }).catch(console.warn); + return; + } + const sorted_user_notes = user_notes.sort((a, b) => b.record.epoch - a.record.epoch); + const user_notes_chunks = array_chunks(sorted_user_notes, 5); + if (user_notes_chunks.length > 1) { + await bot_message.edit({ + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 2, + custom_id: 'previous', + emoji: { + id: null, + name: '⬅️', + }, + }, { + type: 2, + style: 2, + custom_id: 'next', + emoji: { + id: null, + name: '➡️', + }, + }, { + type: 2, + style: 2, + custom_id: 'stop', + emoji: { + id: null, + name: '⏹️', + }, + }, + ], + }, + ], + }); + } + let page_index = 0; + async function editEmbedWithNextUserNotesChunk() { + const user_notes_chunk = user_notes_chunks[page_index]; + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + description: user_notes_chunk.map(user_note => [ + `**Id** \`${user_note.record.id}\``, + `**Staff** <@${user_note.record.staff_member_id}>`, + `**Member** <@${user_note.identity.discord_user_id}>`, + `**Date** `, + '**Content**', + '\`\`\`', + `${string_ellipses(Discord.Util.cleanCodeBlockContent(user_note.record.note), 250)}`, + '\`\`\`', + ].join('\n')).join('\n'), + }), + ], + }).catch(console.warn); + return; // complete async + } + await editEmbedWithNextUserNotesChunk(); + const message_button_collector_filter = (button_interaction) => button_interaction.user.id === message.author.id; + const message_button_collector = bot_message.createMessageComponentCollector({ + filter: message_button_collector_filter, + time: 5 * 60_000, // 5 minutes + }); + message_button_collector.on('collect', async (button_interaction) => { + message_button_collector.resetTimer(); + switch (button_interaction.customId) { + case 'previous': { + page_index = page_index < user_notes_chunks.length - 1 ? page_index + 1 : 0; + break; + } + case 'next': { + page_index = page_index > 0 ? page_index - 1 : user_notes_chunks.length - 1; + break; + } + case 'stop': { + message_button_collector.stop(); + break; + } + default: { + break; + } + } + await button_interaction.deferUpdate(); + if (message_button_collector.ended) + return; + await editEmbedWithNextUserNotesChunk(); + }); + message_button_collector.on('end', async () => { + await bot_message.delete().catch(console.warn); + }); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'notes', + description: 'N/A', + aliases: ['notes'], + permission_level: command_permission_levels.STAFF, + async execute(message, args) { + const { command_prefix, command_name, command_args } = args; + const subcommand_name = `${command_args[0]}`.toLowerCase(); + switch (subcommand_name) { + case 'create': { + await createNoteCommand(message); + break; + } + case 'update': { + await updateNoteCommand(message); + break; + } + case 'remove': { + await removeNoteCommand(message); + break; + } + case 'purge': { + await purgeNotesCommand(message); + break; + } + case 'for': { + await lookupNotesCommand(message, 'user_mention'); + break; + } + case 'lookup': { + await lookupNotesCommand(message, 'note_id'); + break; + } + default: { + await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Notes', + }, + title: 'Here are the available sub-commands!', + description: [ + 'Creates a note for a user.', + '\`\`\`', + `${command_prefix}${command_name} create `, + '\`\`\`', + 'Updates a note.', + '\`\`\`', + `${command_prefix}${command_name} update `, + '\`\`\`', + 'Removes a note.', + '\`\`\`', + `${command_prefix}${command_name} remove `, + '\`\`\`', + 'Removes all notes from a user.', + '\`\`\`', + `${command_prefix}${command_name} purge `, + '\`\`\`', + 'Displays all notes for a user', + '\`\`\`', + `${command_prefix}${command_name} for `, + '\`\`\`', + 'Displays a note.', + '\`\`\`', + `${command_prefix}${command_name} lookup `, + '\`\`\`', + ].join('\n'), + }), + ], + }).catch(console.warn); + break; + } + } + }, +}; +//# sourceMappingURL=notes.js.map \ No newline at end of file diff --git a/dist/bot/commands/notes.js.map b/dist/bot/commands/notes.js.map new file mode 100644 index 00000000..7071da51 --- /dev/null +++ b/dist/bot/commands/notes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"notes.js","sourceRoot":"","sources":["../../../src/bot/commands/notes.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,oCAAoC;AAEpC,mHAAmH;AAEnH,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE5E,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAG1K,mHAAmH;AAEnH;;;GAGG;AACH,KAAK,UAAU,iBAAiB,CAAC,OAAO;IACpC,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,YAAY,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAE3E,IAAI;QACA,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KAC1C;IAAC,MAAM;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AAS,CAAC,CAAC;gBAE7C,MAAM;aACT;YAED,OAAO,CAAC,CAAC;gBACL,MAAM,OAAO,CAAC,KAAK,CAAC;oBAChB,MAAM,EAAE;wBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;4BACrB,KAAK,EAAE,QAAQ;4BACf,MAAM,EAAE;gCACJ,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;gCAC7D,IAAI,EAAE,+BAA+B;6BACxC;4BACD,KAAK,EAAE,sCAAsC;4BAC7C,WAAW,EAAE;gCACT,4BAA4B;gCAC5B,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,kCAAkC;gCAClE,QAAQ;gCACR,iBAAiB;gCACjB,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,6BAA6B;gCAC7D,QAAQ;gCACR,iBAAiB;gCACjB,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,mBAAmB;gCACnD,QAAQ;gCACR,gCAAgC;gCAChC,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,uBAAuB;gCACvD,QAAQ;gCACR,+BAA+B;gCAC/B,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,qBAAqB;gCACrD,QAAQ;gCACR,kBAAkB;gCAClB,QAAQ;gCACR,GAAG,cAAc,GAAG,YAAY,mBAAmB;gCACnD,QAAQ;6BACX,CAAC,IAAI,CAAC,IAAI,CAAC;yBACf,CAAC;qBACL;iBACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvB,MAAM;aACT;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/product_hub.js b/dist/bot/commands/product_hub.js new file mode 100644 index 00000000..99dadfea --- /dev/null +++ b/dist/bot/commands/product_hub.js @@ -0,0 +1,38 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'product_hub', + description: 'why does this even exist', + aliases: ['product_hub', 'producthub', 'hub'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Check out our Product Hub!', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Product Hub', + url: 'https://product-hub.inertia.lighting/', + }, + ], + }, + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=product_hub.js.map \ No newline at end of file diff --git a/dist/bot/commands/product_hub.js.map b/dist/bot/commands/product_hub.js.map new file mode 100644 index 00000000..8e136ec7 --- /dev/null +++ b/dist/bot/commands/product_hub.js.map @@ -0,0 +1 @@ +{"version":3,"file":"product_hub.js","sourceRoot":"","sources":["../../../src/bot/commands/product_hub.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,0BAA0B;IACvC,OAAO,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC;IAC7C,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,4BAA4B;iBAC5C,CAAC;aACL;YACD,UAAU,EAAE;gBACR;oBACI,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE;wBACR;4BACI,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,aAAa;4BACpB,GAAG,EAAE,uCAAuC;yBAC/C;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/products.js b/dist/bot/commands/products.js new file mode 100644 index 00000000..8c66f369 --- /dev/null +++ b/dist/bot/commands/products.js @@ -0,0 +1,140 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Timer, string_ellipses, } = require('../../utilities.js'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client, } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'products', + description: 'lists all of the products', + aliases: ['products'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + /* send an initial message to the user */ + const bot_message = await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Loading products...', + }), + ], + }); + /* create a small user-experience delay */ + await Timer(500); + /* fetch products from the database */ + const db_roblox_products = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, { + 'public': true, + }); + await bot_message.edit({ + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 2, + custom_id: 'previous', + emoji: { + id: null, + name: '⬅️', + }, + }, { + type: 2, + style: 2, + custom_id: 'next', + emoji: { + id: null, + name: '➡️', + }, + }, { + type: 2, + style: 2, + custom_id: 'stop', + emoji: { + id: null, + name: '⏹️', + }, + }, { + type: 2, + style: 5, + label: 'Products & Downloads', + url: 'https://inertia.lighting/products', + }, { + type: 2, + style: 5, + label: 'Testing Game', + url: 'https://demo.inertia.lighting/', + }, + ], + }, + ], + }); + /* send a carousel containing 1 product per page */ + let page_index = 0; + async function editEmbedWithNextProduct() { + const public_roblox_product = db_roblox_products[page_index]; + await bot_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Products', + }, + description: [ + `**Product Name:** ${public_roblox_product.name}`, + `**Price:** ${public_roblox_product.price_in_robux} <:robux:759699085439139871>`, + `**PayPal Price:** $${Number.parseFloat(public_roblox_product.price_in_usd).toFixed(2)} USD`, + '**Description:**', + '\`\`\`', + `${string_ellipses(Discord.Util.cleanCodeBlockContent(public_roblox_product.description), 1500)}`, + '\`\`\`', + ].join('\n'), + image: { + url: `https://inertia.lighting/assets/media/images/products/${public_roblox_product.code}.png`, + }, + }), + ], + }).catch(console.warn); + return; // complete async + } + await editEmbedWithNextProduct(); + const message_button_collector_filter = (button_interaction) => button_interaction.user.id === message.author.id; + const message_button_collector = bot_message.createMessageComponentCollector({ + filter: message_button_collector_filter, + time: 5 * 60_000, // 5 minutes + }); + message_button_collector.on('collect', async (button_interaction) => { + message_button_collector.resetTimer(); + switch (button_interaction.customId) { + case 'previous': { + page_index = page_index < db_roblox_products.length - 1 ? page_index + 1 : 0; + break; + } + case 'next': { + page_index = page_index > 0 ? page_index - 1 : db_roblox_products.length - 1; + break; + } + case 'stop': { + message_button_collector.stop(); + break; + } + default: { + break; + } + } + await button_interaction.deferUpdate(); + if (message_button_collector.ended) + return; + await editEmbedWithNextProduct(); + }); + message_button_collector.on('end', async () => { + await bot_message.delete().catch(console.warn); + }); + }, +}; +//# sourceMappingURL=products.js.map \ No newline at end of file diff --git a/dist/bot/commands/products.js.map b/dist/bot/commands/products.js.map new file mode 100644 index 00000000..ca182643 --- /dev/null +++ b/dist/bot/commands/products.js.map @@ -0,0 +1 @@ +{"version":3,"file":"products.js","sourceRoot":"","sources":["../../../src/bot/commands/products.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EACF,KAAK,EACL,eAAe,GAClB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAExD,MAAM,EACF,OAAO,EACP,MAAM,GACT,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpC,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,2BAA2B;IACxC,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,yCAAyC;QACzC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAC3C,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,qBAAqB;iBACrC,CAAC;aACL;SACJ,CAAC,CAAC;QAEH,0CAA0C;QAC1C,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAEjB,sCAAsC;QACtC,MAAM,kBAAkB,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE;YAC3H,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,MAAM,WAAW,CAAC,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AAC;oBAC7E,MAAM;iBACT;gBACD,KAAK,MAAM,CAAC,CAAC;oBACT,UAAU,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;oBAC7E,MAAM;iBACT;gBACD,KAAK,MAAM,CAAC,CAAC;oBACT,wBAAwB,CAAC,IAAI,EAAE,CAAC;oBAChC,MAAM;iBACT;gBACD,OAAO,CAAC,CAAC;oBACL,MAAM;iBACT;aACJ;YAED,MAAM,kBAAkB,CAAC,WAAW,EAAE,CAAC;YAEvC,IAAI,wBAAwB,CAAC,KAAK;gBAAE,OAAO;YAE3C,MAAM,wBAAwB,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;YAC1C,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/profile.js b/dist/bot/commands/profile.js new file mode 100644 index 00000000..a742c41e --- /dev/null +++ b/dist/bot/commands/profile.js @@ -0,0 +1,44 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +const { userProfileHandler } = require('../handlers/user_profile_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'profile', + description: 'displays a user\'s profile', + usage: '[user_mention]', + aliases: ['profile'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 5_000, + async execute(message, args) { + const { command_prefix, command_name, command_args } = args; + const user_lookup_query = message.mentions.users.first()?.id ?? command_args[0] ?? ''; + /** @type {Discord.User?} */ + const user = client.users.cache.get(user_lookup_query) ?? message.author; + if (user_lookup_query.length > 0 && !user) { + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Profiles', + }, + title: 'Invalid User Mention', + description: [ + 'Please provide a valid @user mention to view their profile!', + '', + 'Example:', + `> ${command_prefix}${command_name} <@!163646957783482370>`, + ].join('\n'), + }), + ], + }).catch(console.warn); + } + userProfileHandler(message, user.id); + }, +}; +//# sourceMappingURL=profile.js.map \ No newline at end of file diff --git a/dist/bot/commands/profile.js.map b/dist/bot/commands/profile.js.map new file mode 100644 index 00000000..19681b62 --- /dev/null +++ b/dist/bot/commands/profile.js.map @@ -0,0 +1 @@ +{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/bot/commands/profile.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAE9E,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,4BAA4B;IACzC,KAAK,EAAE,gBAAgB;IACvB,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAE5D,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEtF,4BAA4B;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC;QAEzE,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;YACvC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gBACvB,MAAM,EAAE;oBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;wBACrB,KAAK,EAAE,QAAQ;wBACf,MAAM,EAAE;4BACJ,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;4BAC7D,IAAI,EAAE,kCAAkC;yBAC3C;wBACD,KAAK,EAAE,sBAAsB;wBAC7B,WAAW,EAAE;4BACT,6DAA6D;4BAC7D,EAAE;4BACF,UAAU;4BACV,KAAK,cAAc,GAAG,YAAY,yBAAyB;yBAC9D,CAAC,IAAI,CAAC,IAAI,CAAC;qBACf,CAAC;iBACL;aACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAED,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/purge.js b/dist/bot/commands/purge.js new file mode 100644 index 00000000..a6f84cbd --- /dev/null +++ b/dist/bot/commands/purge.js @@ -0,0 +1,40 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'purge', + description: 'removes up to 100 messages sent within 2 weeks', + usage: '', + aliases: ['purge', 'clear'], + permission_level: command_permission_levels.ADMINS, + cooldown: 5_000, + async execute(message, args) { + const { command_args } = args; + const amount_of_messages_to_remove = Number.parseInt(command_args[0]); + /* validate the amount of messages to purge */ + if (Number.isNaN(amount_of_messages_to_remove) || amount_of_messages_to_remove < 1 || amount_of_messages_to_remove > 100) { + await message.reply({ + content: `${message.author}, you need to specify a number within 1-100 next time.`, + }).catch(console.warn); + return; + } + /* remove the message sent by staff */ + await message.delete().catch(console.warn); + /** @type {Number} */ + const number_of_messages_removed = await message.channel.bulkDelete(amount_of_messages_to_remove, true).then((removed_messages) => removed_messages.size).catch(() => 0); + /* check if messages were removed */ + if (number_of_messages_removed === 0) { + await message.reply({ + content: `${message.author}, I was unable to purge any messages.`, + }).catch(console.warn); + return; + } + await message.reply({ + content: `${message.author}, purged ${number_of_messages_removed} / ${amount_of_messages_to_remove} message(s) from the channel.`, + }).catch(console.warn); + } +}; +//# sourceMappingURL=purge.js.map \ No newline at end of file diff --git a/dist/bot/commands/purge.js.map b/dist/bot/commands/purge.js.map new file mode 100644 index 00000000..9d37b0a2 --- /dev/null +++ b/dist/bot/commands/purge.js.map @@ -0,0 +1 @@ +{"version":3,"file":"purge.js","sourceRoot":"","sources":["../../../src/bot/commands/purge.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB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new file mode 100644 index 00000000..7c17907d --- /dev/null +++ b/dist/bot/commands/support.js @@ -0,0 +1,950 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const fs = require('node:fs'); +const path = require('node:path'); +//---------------------------------------------------------------------------------------------------------------// +const { Timer } = require('../../utilities.js'); +const { Discord, client, } = require('../discord_client.js'); +const { getUserPermissionLevel, command_permission_levels, } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +const support_tickets_category_id = process.env.BOT_SUPPORT_TICKETS_CATEGORY_ID; +const support_tickets_transcripts_channel_id = process.env.BOT_SUPPORT_TICKETS_TRANSCRIPTS_CHANNEL_ID; +//---------------------------------------------------------------------------------------------------------------// +const support_instructions_reminder_timeout_in_ms = 5 * 60_000; // 5 minutes +const support_instructions_collector_timeout_in_ms = 60 * 60_000; // 1 hour +const support_ticket_cleanup_timeout_in_ms = 10_000; // 10 seconds +const user_feedback_survey_collector_timeout_in_ms = 30 * 60_000; // 30 minutes +//---------------------------------------------------------------------------------------------------------------// +const satisfaction_levels = { + highest_satisfaction: { + label: 'Excellent', + description: 'Support went above and beyond expectations!', + color: '#00ff00', + }, + high_satisfaction: { + label: 'Good', + description: 'Support was able to help me without issues!', + color: '#77ff00', + }, + medium_satisfaction: { + label: 'Decent', + description: 'Support was able to help me with little issues!', + color: '#ffff00', + }, + low_satisfaction: { + label: 'Bad', + description: 'Support wasn\'t able to help me properly!', + color: '#ff7700', + }, + lowest_satisfaction: { + label: 'Horrible', + description: 'Support staff need better training!', + color: '#ff0000', + }, +}; +//---------------------------------------------------------------------------------------------------------------// +const display_database_documents_button = { + type: 2, + style: 2, + custom_id: 'display_support_ticket_database_documents', + label: 'Display database documents', +}; +const ready_for_support_staff_button = { + type: 2, + style: 3, + custom_id: 'ready_for_support_staff', + label: 'I have completed the instructions', +}; +const cancel_support_ticket_button = { + type: 2, + style: 4, + custom_id: 'cancel_support_ticket', + label: 'Cancel support ticket', +}; +//---------------------------------------------------------------------------------------------------------------// +const template_instructions_text = [ + '**Please fill out the template shown below.**', + '*Number your responses to match each question.*', +].join('\n'); +const template_instructions_footer_text = [ + '**Please follow the instructions above properly;**', + '**to ensure our support staff can assist you.**', + '*Once you have completed the instructions, please wait for*', + `*the \"${ready_for_support_staff_button.label}\" button to appear.*`, +].join('\n'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {String} SupportCategoryId + * @typedef {{ + * id: SupportCategoryId, + * name: String, + * description: String, + * qualified_support_role_ids: Discord.Snowflake[], + * automatically_save_when_closed: Boolean, + * instructions_message_options: Discord.MessageOptions, + * }} SupportCategory + * @typedef {Discord.Collection} SupportCategories + */ +const support_categories = new Discord.Collection([ + { + id: 'ISSUES', + name: 'Product Tech Support', + description: 'Product technical support can be found here.', + qualified_support_role_ids: [ + process.env.BOT_SUPPORT_STAFF_PRODUCT_ISSUES_ROLE_ID, + ], + automatically_save_when_closed: true, + instructions_message_options: { + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support Ticket Instructions', + }, + description: [ + template_instructions_text, + '', + '\`(1)\` **What product(s) are you having issues with?**', + '', + '\`(2)\` **Did you read the \`README\`?**', + '\` \` *( yes | kinda | maybe | no )*', + '', + '\`(3)\` **Do you have any \"anti-virus\" plugins?**', + '\` \` *( yes | maybe | idk | no )*', + '', + '\`(4)\` **Did you save and publish your game?**', + '\` \` *( yes | idk | no )*', + '\` \` Watch [this](https://us-east-1.tixte.net/uploads/inertia.wtf/kvck4ln9y0a.mp4) to see how to publish your game.', + '\` \` Or, simply press \`[ALT] + [P]\` to publish your game.', + '\` \` After publishing your game, you must restart roblox studio completely.', + '', + '\`(5)\` **Did you enable HTTP Requests and**', + '\` \` **Studio Access to API Services?**', + '\` \` *( yes | idk | no )*', + '\` \` Watch [this](https://us-east-1.tixte.net/uploads/inertia.wtf/kvcihjnz10a.png) to see how to enable HTTP Requests', + '\` \` and Studio Access to API Services in your game.', + '', + '\`(6)\` **We need you to do the following:**', + '\` \` Open your game inside of Roblox Studio.', + '\` \` Click on the \`View\` tab at the top of the screen.', + '\` \` Enable the \`Output\` and \`Command Bar\` buttons.', + '\` \` Click on the \`Home\` tab at the top of the screen.', + '\` \` Enter \"Play Here\" mode by clicking on the \`Play Here\` button.', + '\` \` Attempt to use the product(s) that you are having issues with.', + '\` \` Modify your \`Output\` settings to be the same as [this](https://us-east-1.tixte.net/uploads/inertia.wtf/RobloxStudioBeta_LNje9Lvzhs.mp4).', + '\` \` Right-click the text contained in the \`Output\` window.', + '\` \` Click on the \`Select All\` button.', + '\` \` Right-click the text again.', + '\` \` Click on the \`Copy\` button.', + '\` \` Use a service like [Source Bin](https://sourceb.in/) or [Pastebin](https://pastebin.com/) to upload the text to.', + '\` \` Send us the link here.', + '', + '\`(7)\` **What are you having issues with?**', + '\` \` Please be very specific about what you are having issues with.', + '\` \` Also let us know what you have already tried to do to fix the issue.', + '', + template_instructions_footer_text, + ].join('\n'), + }), + ], + }, + }, { + id: 'RECOVERY', + name: 'Account Recovery', + description: 'Recover products from an inaccessible account.', + qualified_support_role_ids: [ + process.env.BOT_SUPPORT_STAFF_DATABASE_ROLE_ID, + ], + automatically_save_when_closed: true, + instructions_message_options: { + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support Ticket Instructions', + }, + description: [ + template_instructions_text, + '', + '\`(1)\` **What is your old Roblox account?**', + '\` \` *( profile url | roblox id | unknown | n/a )*', + '\` \` Example: ', + '\` \` Example: 2010759283', + '\` \` Example: unknown', + '\` \` Example: n/a', + '', + '\`(2)\` **What is your new Roblox account?**', + '\` \` *( profile url | roblox id )*', + '\` \` Example: ', + '\` \` Example: 2010759283', + '', + '\`(3)\` **What is your old Discord account?**', + '\` \` *( @mention#0001 | discord id | unknown | n/a )*', + '\` \` Example: <@!163646957783482370>', + '\` \` Example: 163646957783482370', + '\` \` Example: unknown', + '\` \` Example: n/a', + '', + '\`(4)\` **What is your new Discord account?**', + '\` \` *( @mention#0001 | discord id )*', + '\` \` Example: <@!163646957783482370>', + '\` \` Example: 163646957783482370', + '', + '\`(5)\` **Explanation:**', + '\` \` Tell us why you are requesting an account recovery.', + '\` \` Please provide as much information as possible!', + '', + template_instructions_footer_text, + ].join('\n'), + }), + ], + }, + }, { + id: 'TRANSFERS', + name: 'Transfer Products', + description: 'Transfer or gift products to a different account.', + qualified_support_role_ids: [ + process.env.BOT_SUPPORT_STAFF_DATABASE_ROLE_ID, + ], + automatically_save_when_closed: true, + instructions_message_options: { + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support Ticket Instructions', + }, + description: [ + template_instructions_text, + '', + '\`(1)\` **What product(s) do you want to transfer?**', + '', + '\`(2)\` **What is the Discord account you want to transfer to?**', + '\` \` *( @mention#0001 | discord id | n/a )*', + '\` \` Example: @MidSpike#4322', + '\` \` Example: 163646957783482370', + '\` \` Example: n/a', + '', + '\`(3)\` **What is the Roblox account you want to transfer to?**', + '\` \` *( profile url | n/a )*', + '\` \` Example: roblox.com/users/2010759283/profile', + '\` \` Example: n/a', + '', + '\`(4)\` **Why are you transferring your products?**', + '\` \` *( re-linking account | gifting products | other, please specify )*', + '\` \` Example: re-linking account, no longer using old roblox account', + '', + template_instructions_footer_text, + ].join('\n'), + }), + ], + }, + }, { + id: 'TRANSACTIONS', + name: 'Transactions', + description: 'Failed transactions or monetary issues with purchases.', + qualified_support_role_ids: [ + process.env.BOT_SUPPORT_STAFF_PRODUCT_PURCHASES_ROLE_ID, + ], + automatically_save_when_closed: true, + instructions_message_options: { + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support Ticket Instructions', + }, + description: [ + template_instructions_text, + '', + '\`(1)\` **What product(s) are involved?**', + '', + '\`(2)\` **When did you attempt your purchase?**', + '\` \` *( 1970-01-01 )*', + '', + '\`(3)\` **Please provide a valid proof of purchase.**', + '\` \` Check out [your Roblox transactions](https://www.roblox.com/transactions) here.', + '\` \` Screenshot your roblox transactions or receipt from paypal.', + '\` \` The screenshot must be fullscreen and include the current date / time.', + '', + '\`(4)\` **Fully describe the issue you are encountering.**', + '', + template_instructions_footer_text, + ].join('\n'), + }), + ], + }, + }, + // { + // id: 'PARTNERS', + // name: 'Partner Requests', + // description: 'Apply to become a partner of Inertia Lighting.', + // qualified_support_role_ids: [ + // process.env.BOT_SUPPORT_STAFF_PARTNER_REQUESTS_ROLE_ID, + // ], + // automatically_save_when_closed: false, + // instructions_message_options: { + // embeds: [ + // new Discord.MessageEmbed({ + // color: 0x60A0FF, + // author: { + // iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + // name: 'Inertia Lighting | Support Ticket Instructions', + // }, + // description: [ + // template_instructions_text, + // '', + // '\`(1)\` **What is your group called?**', + // '\` \` Example: Inertia Lighting (formerly: C-Tech Lighting)', + // '', + // '\`(2)\` **Who is the owner of the group?**', + // '\` \` *( discord account | roblox account | etc )*', + // '\` \` Example: <@!163646957783482370>, roblox.com/users/2010759283/profile', + // '', + // '\`(3)\` **Describe your group in detail.**', + // '', + // '\`(4)\` **How many people are in your group?**', + // '', + // '\`(5)\` **Social Links:**', + // '\` \` *( discord, roblox, website, etc )*', + // '\` \` Please provide links to the group\'s public presences.', + // '', + // '\`(6)\` **Why do you want to partner with us?**', + // '', + // '\`(7)\` **Why should we partner with you?**', + // '', + // template_instructions_footer_text, + // ].join('\n'), + // }), + // ], + // }, + // }, + { + id: 'OTHER', + name: 'Other & Quick Questions', + description: 'For all other forms of support.', + qualified_support_role_ids: [ + process.env.BOT_SUPPORT_STAFF_OTHER_ROLE_ID, + ], + automatically_save_when_closed: false, + instructions_message_options: { + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support Ticket Instructions', + }, + description: [ + '**Tell us why you opened this ticket, and how we can help!**', + '*If you have a question, please explain the details.*', + '', + template_instructions_footer_text, + ].join('\n'), + }), + ], + }, + }, +].map((item) => [item.id, item])); +//---------------------------------------------------------------------------------------------------------------// +/** + * Creates a support ticket channel + * @param {Discord.Guild} guild + * @param {Discord.GuildMember} guild_member + * @param {SupportCategory} support_category + * @returns {Promise} + */ +async function createSupportTicketChannel(guild, guild_member, support_category) { + const support_tickets_category = guild.channels.resolve(support_tickets_category_id); + if (!support_tickets_category) + throw new Error('Can\'t find the support ticket category!'); + const support_channel_name = `${support_category.id}-${guild_member.id}`.toLowerCase(); + const potential_open_ticket_channel = guild.channels.cache.find(channel => channel.parentID === support_tickets_category.id && channel.name === support_channel_name); + if (potential_open_ticket_channel) + throw new Error('A support ticket channel is already open!'); + const support_ticket_channel = await guild.channels.create(support_channel_name, { + type: 'GUILD_TEXT', + topic: `${guild_member} | ${support_category.name} | Opened on | Staff may close this ticket using the \`close_ticket\` command.`, + parent: support_tickets_category, + permissionOverwrites: [ + ...support_tickets_category.permissionOverwrites.cache.values(), + { + id: process.env.BOT_STAFF_ROLE_ID, + allow: ['VIEW_CHANNEL'], + deny: ['SEND_MESSAGES'], // staff must wait for the user to active the support ticket + }, { + id: guild_member.id, + allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'], + }, + ], + }); + return support_ticket_channel; +} +/** + * @typedef {{ + * id: string | null, + * type: string | null, + * system: boolean | null, + * nonce: string | null, + * author: { + * id: string | null, + * display_name: string | null, + * }, + * created_timestamp: number | null, + * edited_timestamp: number | null, + * content: string | null, + * clean_content: string | null, + * embeds: { + * type: string | null, + * title: string | null, + * description: string | null, + * fields: { + * name: string | null, + * value: string | null, + * }[], + * thumbnail_url: string | null, + * image_url: string | null, + * } | null, + * attachments: unknown[] | null, + * stickers: unknown[] | null, + * components: unknown[] | null, + * }} TranscriptMessageData + * + * @typedef {{ + * metadata: { + * channel: { + * id: string | null, + * name: string | null, + * topic: string | null, + * }, + * user: { + * id: string | null, + * }, + * }, + */ +/** + * Creates a JSON-transcript from a support ticket channel + * @param {Discord.TextChannel} support_ticket_channel + */ +async function createTranscriptForSupportTicket(support_ticket_channel) { + /** @type {TranscriptMessageData[]} */ + const transcript_messages = []; + let before_message_id; + do { + const messages = await support_ticket_channel.messages.fetch({ + before: before_message_id ?? undefined, + limit: 100, + }); + if (messages.size === 0) + break; + const oldest_message_id = messages.last().id ?? undefined; + if (before_message_id && oldest_message_id === before_message_id) + break; + for (const [message_id, message] of messages) { + transcript_messages.push({ + id: message_id ?? null, + type: message.type ?? null, + system: message.system ?? null, + nonce: message.nonce ?? null, + author: { + id: message.author.id ?? null, + display_name: message.author.displayName ?? null, + }, + created_timestamp: message.createdTimestamp ?? null, + edited_timestamp: message.editedTimestamp ?? null, + content: message.content ?? null, + clean_content: message.cleanContent ?? null, + embeds: message.embeds.map(embed => ({ + type: embed.type ?? null, + title: embed.title ?? null, + description: embed.description ?? null, + fields: embed.fields.map(field => ({ + name: field.name ?? null, + value: field.value ?? null, + })), + thumbnail_url: embed.thumbnail?.url ?? null, + image_url: embed.image?.url ?? null, + })) ?? null, + attachments: message.attachments.map(attachment => ({ + name: attachment.name ?? null, + url: attachment.url ?? null, + })) ?? null, + stickers: message.stickers.map(sticker => ({ + name: sticker.name ?? null, + url: sticker.url ?? null, + })) ?? null, + components: message.components.map(component => ({ + type: component.type ?? null, + data: component.data ?? null, + })) ?? null, + }); + } + before_message_id = oldest_message_id; + await Timer(2_500); // prevent rate-limiting + } while (before_message_id); + const support_ticket_owner_id = support_ticket_channel.name.match(/(?!.*\-)?([0-9])+/i)?.[0]; + if (!support_ticket_owner_id) + throw new Error('Unable to find the support ticket owner id!'); + return { + metadata: { + channel: { + id: support_ticket_channel.id ?? null, + name: support_ticket_channel.name ?? null, + topic: support_ticket_channel.topic ?? null, + created_timestamp: support_ticket_channel.createdTimestamp ?? null, + }, + user: { + id: support_ticket_owner_id ?? null, + }, + }, + messages: transcript_messages?.reverse() ?? null, // reverse the array to get the messages in order of creation + }; +} +/** + * Closes a support ticket channel + * @param {Discord.TextChannel} support_channel + * @param {Boolean} save_transcript + * @param {Discord.GuildMember?} member_that_closed_ticket + * @param {Boolean} send_feedback_survey + * @returns {Promise} + */ +async function closeSupportTicketChannel(support_channel, save_transcript, member_that_closed_ticket, send_feedback_survey = false) { + await support_channel.send({ + content: `${member_that_closed_ticket ? `${member_that_closed_ticket},` : 'automatically'} closing support ticket in 10 seconds...`, + }).catch(console.warn); + if (save_transcript && member_that_closed_ticket) { + const support_ticket_topic_name = support_channel.name.match(/([a-zA-Z\-\_])+(?![\-\_])\D/i)?.[0]; + const support_ticket_owner_id = support_channel.name.match(/(?!.*\-)?([0-9])+/i)?.[0]; + const support_category = support_categories.find(support_category => support_category.id === support_ticket_topic_name.toUpperCase()); + const support_ticket_owner = await client.users.fetch(support_ticket_owner_id); + const transcript_data = await createTranscriptForSupportTicket(support_channel); + const channel_participant_ids = new Set(transcript_data.messages.map(msg => msg.author.id)); + const temp_file_path = path.join(process.cwd(), 'temporary', `transcript_${support_channel.name}.json`); + fs.writeFileSync(temp_file_path, JSON.stringify(transcript_data, null, 2), { flag: 'w' }); + const createTranscriptAttachment = () => { + const temp_file_read_stream = fs.createReadStream(temp_file_path); + return new Discord.MessageAttachment(temp_file_read_stream); + }; + const transcript_embed = new Discord.MessageEmbed({ + color: 0x60A0FF, + fields: [ + { + name: 'Ticket Id', + value: `${'```'}\n${support_channel.name}\n${'```'}`, + inline: false, + }, { + name: 'Category', + value: `${'```'}\n${support_category.name}\n${'```'}`, + inline: false, + }, { + name: 'Creation Timestamp', + value: ``, + inline: false, + }, { + name: 'Closure Timestamp', + value: ``, + inline: false, + }, { + name: 'Opened By', + value: `<@!${support_ticket_owner.id}>`, + inline: true, + }, { + name: 'Closed By', + value: `<@!${member_that_closed_ticket.id}>`, + inline: true, + }, { + name: 'Participants', + value: `${Array.from(channel_participant_ids).map(user_id => `<@!${user_id}>`).join(' - ')}`, + inline: false, + }, + ], + }); + /* send the transcript to transcripts channel */ + const support_ticket_transcripts_channel = await client.channels.fetch(support_tickets_transcripts_channel_id); + const transcript_message = await support_ticket_transcripts_channel.send({ + embeds: [ + transcript_embed, + ], + files: [ + createTranscriptAttachment(), + ], + }).catch(console.warn); + /* send the feedback survey to the user */ + if (send_feedback_survey) { + try { + const support_ticket_owner_dms = await support_ticket_owner.createDM(); + await support_ticket_owner_dms.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Your support ticket transcript is attached to this message.', + }), + ], + files: [ + createTranscriptAttachment(), + ], + }); + const user_feedback_survey_message = await support_ticket_owner_dms.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'How was your most recent support ticket experience?', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 3, + custom_id: 'support_user_feedback_survey_color', + placeholder: 'Please select a rating to give our support staff!', + min_values: 1, + max_values: 1, + options: Object.entries(satisfaction_levels).map(([key, value]) => ({ + label: value.label, + description: value.description, + value: key, + })), + }, + ], + }, + ], + }); + const user_feedback_survey_components_collector = user_feedback_survey_message.createMessageComponentCollector({ + filter: (interaction) => interaction.user.id === support_ticket_owner.id, + time: user_feedback_survey_collector_timeout_in_ms, + max: 1, + }); + user_feedback_survey_components_collector.on('collect', async (interaction) => { + await interaction.deferUpdate(); + if (!interaction.isSelectMenu()) + return; + switch (interaction.customId) { + case 'support_user_feedback_survey_color': { + const satisfaction_level = satisfaction_levels[interaction.values[0]]; + const customer_review_embed = new Discord.MessageEmbed({ + color: satisfaction_level.color ?? 0x60A0FF, + title: `User feedback: ${satisfaction_level.label}`, + description: `${satisfaction_level.description}`, + }); + await transcript_message.edit({ + embeds: [ + transcript_embed, + customer_review_embed, + ], + }).catch(console.warn); + await user_feedback_survey_message.edit({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'Thanks for the feedback!', + }), + ], + }).catch(console.warn); + break; + } + default: { + return; // don't continue if a valid custom_id is missing + } + } + }); + user_feedback_survey_components_collector.on('end', async () => { + await user_feedback_survey_message.edit({ + components: [], + }).catch(console.warn); + }); + } + catch { } // ignore any errors + } + /* delete the temporary file */ + fs.unlinkSync(temp_file_path); + } + await Timer(support_ticket_cleanup_timeout_in_ms); // wait 10 seconds before deleting the channel + await support_channel.delete().catch(console.warn); + return support_channel; +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'support', + description: 'support tickets and stuff', + aliases: ['support', 'close_ticket'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + const { command_name } = args; + const user_permission_level = getUserPermissionLevel(message.member); + async function supportTicketCommand() { + /** @type {Discord.Message} */ + const category_selection_message = await message.channel.send({ + content: `${message.author}`, + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Support System', + }, + description: [ + '**Hi there, how can we help you today?**', + '**Please choose the category that you need assistance for.**', + '*Picking the wrong category will result in longer wait times!*', + ].join('\n\n'), + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 3, + custom_id: 'support_category_selection_menu', + placeholder: 'Select a support category!', + min_values: 1, + max_values: 1, + options: support_categories.map(({ id, name, description }) => ({ + label: name, + description: description.slice(0, 100), + value: id, + })), + }, + ], + }, + ], + }).catch(console.warn); + const category_selection_menu_interaction_collector = await category_selection_message.createMessageComponentCollector({ + filter: (interaction) => interaction.user.id === message.author.id, + time: 5 * 60_000, + }); + category_selection_menu_interaction_collector.on('collect', async (category_selection_menu_interaction) => { + await category_selection_menu_interaction.deferUpdate(); + const category_selection_menu_value = category_selection_menu_interaction.values[0]; + const matching_support_category = support_categories.find((support_category) => support_category.id === category_selection_menu_value); + if (!matching_support_category) { + console.trace('Support category selection menu supplied an invalid value:', { category_selection_menu_value }); + return; // failed to find a matching support category + } + /* stop the collector since we have what we need */ + category_selection_menu_interaction_collector.stop(); + let support_channel; + try { + support_channel = await createSupportTicketChannel(message.guild, message.member, matching_support_category); + } + catch { + return; // don't continue if we can't create a new support ticket channel + } + /* respond to the user with a mention for the support ticket channel */ + await category_selection_menu_interaction.followUp({ + content: [ + `You selected ${matching_support_category.name}!`, + `Go to ${support_channel} to continue.`, + ].join('\n'), + }).catch(console.warn); + /* send the category-specific instructions */ + const category_instructions_message = await support_channel.send({ + ...matching_support_category.instructions_message_options, + content: `${message.author}, welcome to your support ticket!`, + components: [ + { + type: 1, + components: [ + cancel_support_ticket_button, + ], + }, + ], + }); + /* pin the category-specific instructions */ + support_channel.messages.pin(category_instructions_message.id).catch(console.warn); + /** @type {Discord.Message?} */ + let notice_to_press_button_message; // declared here so we can access it later + setTimeout(async () => { + category_instructions_message.edit({ + components: [ + { + type: 1, + components: [ + ready_for_support_staff_button, + cancel_support_ticket_button, + ], + }, + ], + }).catch(() => null); + const time_remaining_to_press_button_in_ms = support_instructions_collector_timeout_in_ms - support_instructions_reminder_timeout_in_ms; + notice_to_press_button_message = await category_instructions_message.reply({ + content: [ + `${message.author}, if you have completed the instructions above;`, + `please click the \"${ready_for_support_staff_button.label}\" button.`, + '', + 'If you have not completed the instructions above;', + `please complete them within ${Number.parseInt(time_remaining_to_press_button_in_ms / 1000 / 60)} minutes.`, + `After completing the instructions, press the \"${ready_for_support_staff_button.label}\" button.`, + ].join('\n'), + }).catch(() => null); + }, support_instructions_reminder_timeout_in_ms); + const category_instructions_message_components_collector = category_instructions_message.createMessageComponentCollector({ + filter: (interaction) => interaction.user.id === message.author.id, + time: support_instructions_collector_timeout_in_ms, + }); + category_instructions_message_components_collector.on('collect', async (interaction) => { + await interaction.deferUpdate(); + switch (interaction.customId) { + case 'ready_for_support_staff': { + /* allow staff to interact in the support ticket */ + await support_channel.permissionOverwrites.set([ + ...support_channel.permissionOverwrites.cache.values(), + ...matching_support_category.qualified_support_role_ids.map((qualified_support_role_id) => ({ + id: qualified_support_role_id, + allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'], + })), + ]).catch(console.trace); + const qualified_support_role_mentions = matching_support_category.qualified_support_role_ids.map(role_id => `<@&${role_id}>`).join(', '); + await interaction.channel.send({ + content: [ + `${message.author}, Our ${qualified_support_role_mentions} staff will help you with your issue soon!`, + '', + 'Our support staff are unscheduled volunteers, so please be patient.', + '', + 'If you have an urgent issue, like someone making death threats;', + 'please @mention one of our high-ranked staff members!', + ].join('\n'), + }).catch(console.warn); + break; + } + case 'cancel_support_ticket': { + await interaction.channel.send({ + content: `${message.author}, Cancelling support ticket...`, + }).catch(console.warn); + await closeSupportTicketChannel(support_channel, false, message.member, false); + break; + } + default: { + return; // don't continue if we don't have a valid custom_id + } + } + if (notice_to_press_button_message) + notice_to_press_button_message.delete().catch(console.warn); + category_instructions_message_components_collector.stop(); + }); + category_instructions_message_components_collector.on('end', async (collected_interactions, reason) => { + /* remove all components from the message */ + await category_instructions_message.edit({ + components: [ + { + type: 1, + components: [ + display_database_documents_button, + ], + }, + ], + }).catch(console.warn); + /* check if the collector has exceeded the specified time */ + if (reason === 'time') { + await closeSupportTicketChannel(support_channel, false, undefined, false); + } + }); + }); + category_selection_menu_interaction_collector.on('end', () => { + /* remove the selection menu as it is no longer needed */ + category_selection_message.delete().catch(console.warn); + }); + /* automatically cancel the category selection collector */ + setTimeout(() => { + category_selection_menu_interaction_collector.stop(); + }, 5 * 60_000); // 5 minutes + } + async function closeTicketCommand() { + if (user_permission_level < command_permission_levels.STAFF) { + message.reply({ + content: 'Sorry, only staff may close active support tickets.', + }).catch(console.warn); + return; + } + const channel_exists_in_support_tickets_category = message.channel.parentId === support_tickets_category_id; + const channel_is_not_transcripts_channel = message.channel.id !== support_tickets_transcripts_channel_id; + if (!(channel_exists_in_support_tickets_category && channel_is_not_transcripts_channel)) { + message.reply({ + content: 'This channel is not an active support ticket.', + }).catch(console.warn); + return; + } + const support_channel = message.channel; + const support_ticket_topic_name = support_channel.name.match(/([a-zA-Z\-\_])+(?![\-\_])\D/i)?.[0]; + const support_category = support_categories.find(support_category => support_category.id === support_ticket_topic_name.toUpperCase()); + if (support_category?.automatically_save_when_closed) { + await closeSupportTicketChannel(support_channel, true, message.member, true); + return; + } + /** @type {Discord.Message} */ + const save_transcript_message = await message.reply({ + content: 'Would you like to save the transcript for this support ticket before closing it?', + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 2, + custom_id: 'save_transcript', + label: 'Yes', + }, { + type: 2, + style: 2, + custom_id: 'discard_transcript', + label: 'No', + }, + ], + }, + ], + }).catch(console.warn); + let save_transcript = false; + const save_transcript_message_components_collector = save_transcript_message.createMessageComponentCollector({ + filter: (interaction) => interaction.user.id === message.author.id, + max: 1, + }); + save_transcript_message_components_collector.on('collect', async (interaction) => { + await interaction.deferUpdate(); + switch (interaction.customId) { + case 'save_transcript': { + save_transcript = true; + break; + } + case 'discard_transcript': { + save_transcript = false; + break; + } + default: { + return; // don't continue if we don't have a valid custom_id + } + } + }); + save_transcript_message_components_collector.on('end', async () => { + /* remove all components from the message */ + await save_transcript_message.edit({ + components: [], + }).catch(console.warn); + /* close the support ticket */ + await closeSupportTicketChannel(support_channel, save_transcript, message.member, true); + }); + } + switch (command_name) { + case 'support': { + await supportTicketCommand(); + break; + } + case 'close_ticket': { + await closeTicketCommand(); + break; + } + default: { + break; + } + } + }, +}; +//# sourceMappingURL=support.js.map \ No newline at end of file diff --git a/dist/bot/commands/support.js.map b/dist/bot/commands/support.js.map new file mode 100644 index 00000000..fe5cbf41 --- /dev/null +++ b/dist/bot/commands/support.js.map @@ -0,0 +1 @@ +{"version":3,"file":"support.js","sourceRoot":"","sources":["../../../src/bot/commands/support.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CA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AAE,KAAK,EAAE,WAAW,EAAE,EAAE;gBAC7E,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;gBAEhC,QAAQ,WAAW,CAAC,QAAQ,EAAE;oBAC1B,KAAK,iBAAiB,CAAC,CAAC;wBACpB,eAAe,GAAG,IAAI,CAAC;wBACvB,MAAM;qBACT;oBAED,KAAK,oBAAoB,CAAC,CAAC;wBACvB,eAAe,GAAG,KAAK,CAAC;wBACxB,MAAM;qBACT;oBAED,OAAO,CAAC,CAAC;wBACL,OAAO,CAAC,oDAAoD;qBAC/D;iBACJ;YACL,CAAC,CAAC,CAAC;YAEH,4CAA4C,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;gBAC9D,4CAA4C;gBAC5C,MAAM,uBAAuB,CAAC,IAAI,CAAC;oBAC/B,UAAU,EAAE,EAAE;iBACjB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvB,8BAA8B;gBAC9B,MAAM,yBAAyB,CAAC,eAAe,EAAE,eAAe,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC5F,CAAC,CAAC,CAAC;QACP,CAAC;QAED,QAAQ,YAAY,EAAE;YAClB,KAAK,SAAS,CAAC,CAAC;gBACZ,MAAM,oBAAoB,EAAE,CAAC;gBAC7B,MAAM;aACT;YACD,KAAK,cAAc,CAAC,CAAC;gBACjB,MAAM,kBAAkB,EAAE,CAAC;gBAC3B,MAAM;aACT;YACD,OAAO,CAAC,CAAC;gBACL,MAAM;aACT;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/verify.js b/dist/bot/commands/verify.js new file mode 100644 index 00000000..1822758b --- /dev/null +++ b/dist/bot/commands/verify.js @@ -0,0 +1,244 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { default: axios } = require('axios'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +const { disableMessageComponents } = require('../common/message.js'); +const { userProfileHandler } = require('../handlers/user_profile_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'verify', + description: 'verifies and adds a user to the database', + usage: 'CODE_HERE', + aliases: ['verify', 'link'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 5_000, + /** + * @param {Discord.Message} message + * @param {Object.} args + */ + async execute(message, args) { + const { command_args } = args; + const [db_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': message.author.id, + }, { + projection: { + '_id': false, + }, + }); + if (db_user_data) { + /** @type {Discord.Message} */ + const bot_msg = await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username} | Verification System`, + }, + title: 'You are already verified!', + description: [ + `${message.author} is already verified and linked in our database!`, + 'Click the \"Your User Profile\" button below to view your profile!', + 'To modify your linked accounts, please open an \"Account Recovery\" support ticket.', + ].join('\n'), + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 2, + custom_id: 'verify_command_user_profile_button', + label: 'Your User Profile', + }, + ], + }, + ], + }); + const message_component_collector = await message.channel.createMessageComponentCollector(); + message_component_collector.on('collect', async (message_component) => { + switch (message_component.customId) { + case 'verify_command_user_profile_button': { + if (!message_component.isButton()) + return; + await message_component.deferReply({ ephemeral: true }); + if (message_component.user.id !== message.author.id) { + await message_component.followUp({ + ephemeral: true, + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + description: 'That button is not for you!', + }), + ], + }).catch(console.warn); + return; + } + await disableMessageComponents(bot_msg).catch(console.warn); + userProfileHandler(message_component, message.author.id); + break; + } + default: { + return; // keep the message_component_collector running + } + } + message_component_collector.stop(); + }); + message_component_collector.on('end', () => { + disableMessageComponents(bot_msg); + }); + return; // don't allow the user to verify if they're already verified + } + const verification_code_to_lookup = `${command_args[0]}`.replace(/\s+/gi).trim(); + if (verification_code_to_lookup.length === 0) { + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + title: 'Missing Verification Code', + description: 'You need to provide a verification code to verify!', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Product Hub', + url: 'https://product-hub.inertia.lighting/', + }, + ], + }, + ], + }).catch(console.warn); + return; + } + let fetch_pending_verification_response; + try { + fetch_pending_verification_response = await axios({ + method: 'post', + url: 'https://api.inertia.lighting/v2/user/verification/context/fetch', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `InertiaAuthUserVerificationEndpoints ${process.env.API_BASE64_ENCODED_TOKEN_FOR_USER_VERIFICATION_ENDPOINTS}`, + }, + data: { + verification_code: verification_code_to_lookup, + }, + validateStatus: (status) => [200, 404].includes(status), + }); + } + catch (error) { + console.error(error); + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + description: [ + 'There was an error while verifying your account.', + 'Please contact our support staff for assistance!', + ].join('\n'), + }), + ], + }).catch(console.warn); + return; + } + if (fetch_pending_verification_response.status === 404) { + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username} | Verification System`, + }, + title: 'Unknown Verification Code', + description: [ + 'That verification code was not recognized!', + ].join('\n'), + }), + ], + }).catch(console.warn); + return; + } + try { + await axios({ + method: 'post', + url: 'https://api.inertia.lighting/v2/user/verification/context/update', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `InertiaAuthUserVerificationEndpoints ${process.env.API_BASE64_ENCODED_TOKEN_FOR_USER_VERIFICATION_ENDPOINTS}`, + }, + data: { + verification_code: fetch_pending_verification_response.data.verification_code, + discord_user_id: message.author.id, + }, + validateStatus: (status) => status === 200, + }); + await axios({ + method: 'post', + url: 'https://api.inertia.lighting/v2/user/verification/context/submit', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `InertiaAuthUserVerificationEndpoints ${process.env.API_BASE64_ENCODED_TOKEN_FOR_USER_VERIFICATION_ENDPOINTS}`, + }, + data: { + verification_code: fetch_pending_verification_response.data.verification_code, + }, + validateStatus: (status) => status === 200, + }); + } + catch (error) { + console.error(error); + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username} | Verification System`, + }, + title: 'Failed to verify!', + description: [ + 'Something went wrong while verifying your account!', + ...(axios.isAxiosError(error) ? [ + '', + 'Debug Information:', + `\`\`\`js\n${error.response?.data ?? 'Unknown error, please contact support!'}\n\`\`\``, + ] : []) + ].join('\n'), + }), + ], + }).catch(console.warn); + return; + } + /* inform the user */ + await message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username} | Verification System`, + }, + title: 'You have successfully verified!', + description: [ + 'You can now return to the Product Hub to continue.', + '', + 'Make sure to stay in our Discord server after making a purchase.', + 'Our whitelist requires you to be in our Discord server.', + ].join('\n'), + }), + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=verify.js.map \ No newline at end of file diff --git a/dist/bot/commands/verify.js.map b/dist/bot/commands/verify.js.map new file mode 100644 index 00000000..faba2adb --- /dev/null +++ b/dist/bot/commands/verify.js.map @@ -0,0 +1 @@ +{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/bot/commands/verify.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE5C,MAAM,EAAE,WAAW,EAAE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yBACxD;wBACD,KAAK,EAAE,mBAAmB;wBAC1B,WAAW,EAAE;4BACT,oDAAoD;4BACpD,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gCAC5B,EAAE;gCACF,oBAAoB;gCACpB,aAAa,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,wCAAwC,UAAU;6BAC1F,CAAC,CAAC,CAAC,EAAE,CAAC;yBACV,CAAC,IAAI,CAAC,IAAI,CAAC;qBACf,CAAC;iBACL;aACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvB,OAAO;SACV;QAED,qBAAqB;QACrB,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACvB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,MAAM,EAAE;wBACJ,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;wBAC7D,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,wBAAwB;qBACxD;oBACD,KAAK,EAAE,iCAAiC;oBACxC,WAAW,EAAE;wBACT,oDAAoD;wBACpD,EAAE;wBACF,kEAAkE;wBAClE,yDAAyD;qBAC5D,CAAC,IAAI,CAAC,IAAI,CAAC;iBACf,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/warn.js b/dist/bot/commands/warn.js new file mode 100644 index 00000000..08c59b2b --- /dev/null +++ b/dist/bot/commands/warn.js @@ -0,0 +1,98 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { command_permission_levels } = require('../common/bot.js'); +const { logModerationActionToDatabase } = require('../handlers/log_moderation_action_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'warn', + description: 'warns a user from the server', + usage: '@mention reason', + aliases: ['warn'], + permission_level: command_permission_levels.MODERATORS, + cooldown: 2_000, + async execute(message, args) { + const { command_args } = args; + const staff_member = message.member; + const member_lookup_query = message.mentions.members.first()?.id ?? command_args[0]; + const member = message.guild.members.resolve(member_lookup_query); + const reason = command_args.slice(1).join(' ').trim() || 'no reason was specified'; + /* handle when a member is not specified */ + if (!member) { + await message.reply({ + content: 'You need to specify a user when using this command!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies themself */ + if (staff_member.id === member.id) { + await message.reply({ + content: 'You aren\'t allowed to warn yourself!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies this bot */ + if (member.id === message.client.user.id) { + await message.reply({ + content: 'You aren\'t allowed to warn me!', + }).catch(console.warn); + return; + } + /* handle when a staff member specifies the guild owner */ + if (member.id === message.guild.ownerId) { + await message.reply({ + content: 'You aren\'t allowed to warn the owner of this server!', + }); + return; + } + /* handle when a staff member tries to moderate someone with an equal/higher role */ + if (staff_member.roles.highest.comparePositionTo(member.roles.highest) <= 0) { + await message.reply({ + content: 'You aren\'t allowed to warn someone with an equal/higher role!', + }).catch(console.warn); + return; + } + const moderation_message_options = { + content: [ + `${member}`, + `You were warned in the Inertia Lighting discord by ${staff_member.user} for:`, + '\`\`\`', + `${reason}`, + '\`\`\`', + ].join('\n'), + }; + /* dm the member */ + try { + const dm_channel = await member.createDM(); + await dm_channel.send(moderation_message_options); + } + catch { + // ignore any errors + } + /* message the member in the server */ + await message.channel.send(moderation_message_options).catch(console.warn); + /* log to the database */ + const successfully_logged_to_database = await logModerationActionToDatabase({ + discord_user_id: member.id, + }, { + type: 'WARN', + epoch: Date.now(), + reason: reason, + staff_member_id: message.member.id, + }); + /* if logging to the database failed, dm the staff member */ + if (!successfully_logged_to_database) { + try { + const staff_member_dm_channel = await message.author.createDM(); + staff_member_dm_channel.send({ + content: `${message.author}, something went wrong while logging to the database, please contact our development team!`, + }); + } + catch { + // ignore any errors + } + } + }, +}; +//# sourceMappingURL=warn.js.map \ No newline at end of file diff --git a/dist/bot/commands/warn.js.map b/dist/bot/commands/warn.js.map new file mode 100644 index 00000000..7ceeca85 --- /dev/null +++ b/dist/bot/commands/warn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"warn.js","sourceRoot":"","sources":["../../../src/bot/commands/warn.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAClE,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAElG,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,8BAA8B;IAC3C,KAAK,EAAE,iBAAiB;IACxB,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,gBAAgB,EAAE,yBAAyB,CAAC,UAAU;IACtD,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAE9B,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;QACpC,MAAM,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAClE,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,yBAAyB,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GAAG,MAAM,EAAE;gBACX,QAAQ;aACX,CAAC,IAAI,CAAC,IAAI,CAAC;SACf,CAAC;QAEF,mBAAmB;QACnB,IAAI;YACA,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3C,MAAM,UAAU,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;SACrD;QAAC,MAAM;YACJ,oBAAoB;SACvB;QAED,sCAAsC;QACtC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE3E,yBAAyB;QACzB,MAAM,+BAA+B,GAAG,MAAM,6BAA6B,CAAC;YACxE,eAAe,EAAE,MAAM,CAAC,EAAE;SAC7B,EAAE;YACC,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE;YACjB,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;SACrC,CAAC,CAAC;QAEH,4DAA4D;QAC5D,IAAI,CAAC,+BAA+B,EAAE;YAClC,IAAI;gBACA,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAChE,uBAAuB,CAAC,IAAI,CAAC;oBACzB,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,4FAA4F;iBACzH,CAAC,CAAC;aACN;YAAC,MAAM;gBACJ,oBAAoB;aACvB;SACJ;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/commands/website.js b/dist/bot/commands/website.js new file mode 100644 index 00000000..f7c079a0 --- /dev/null +++ b/dist/bot/commands/website.js @@ -0,0 +1,38 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord } = require('../discord_client.js'); +const { command_permission_levels } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'website', + description: 'why does this even exist', + aliases: ['website', 'site'], + permission_level: command_permission_levels.PUBLIC, + cooldown: 10_000, + async execute(message, args) { + message.channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Check out our Website!', + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Our Website', + url: 'https://inertia.lighting/', + }, + ], + }, + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=website.js.map \ No newline at end of file diff --git a/dist/bot/commands/website.js.map b/dist/bot/commands/website.js.map new file mode 100644 index 00000000..7e5028f2 --- /dev/null +++ b/dist/bot/commands/website.js.map @@ -0,0 +1 @@ +{"version":3,"file":"website.js","sourceRoot":"","sources":["../../../src/bot/commands/website.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,MAAM,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElE,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,0BAA0B;IACvC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,yBAAyB,CAAC,MAAM;IAClD,QAAQ,EAAE,MAAM;IAChB,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QACvB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,WAAW,EAAE,wBAAwB;iBACxC,CAAC;aACL;YACD,UAAU,EAAE;gBACR;oBACI,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE;wBACR;4BACI,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,aAAa;4BACpB,GAAG,EAAE,2BAA2B;yBACnC;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/common/bot.js b/dist/bot/common/bot.js new file mode 100644 index 00000000..c8a6509c --- /dev/null +++ b/dist/bot/common/bot.js @@ -0,0 +1,79 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getUserPermissionLevel = exports.command_permission_levels = exports.user_is_not_allowed_access_to_command_message_options = void 0; +//---------------------------------------------------------------------------------------------------------------// +const Discord = __importStar(require("discord.js")); +//---------------------------------------------------------------------------------------------------------------// +const guild_staff_role_id = process.env.BOT_STAFF_ROLE_ID; +const guild_moderator_role_id = process.env.BOT_MODERATOR_ROLE_ID; +const guild_admin_role_id = process.env.BOT_ADMIN_ROLE_ID; +const guild_team_leaders_role_id = process.env.BOT_TEAM_LEADERS_ROLE_ID; +const guild_directors_role_id = process.env.BOT_DIRECTORS_ROLE_ID; +const guild_founders_role_id = process.env.BOT_FOUNDERS_ROLE_ID; +//---------------------------------------------------------------------------------------------------------------// +const user_is_not_allowed_access_to_command_message_options = { + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF00FF, + title: 'Nice try, this command is protected!', + description: 'You aren\'t allowed to use this command!', + }), + ], +}; +exports.user_is_not_allowed_access_to_command_message_options = user_is_not_allowed_access_to_command_message_options; +//---------------------------------------------------------------------------------------------------------------// +const command_permission_levels = { + PUBLIC: 1, + STAFF: 2, + MODERATORS: 3, + ADMINS: 4, + TEAM_LEADERS: 5, + DIRECTORS: 6, + FOUNDERS: 7, +}; +exports.command_permission_levels = command_permission_levels; +//---------------------------------------------------------------------------------------------------------------// +function getUserPermissionLevel(guild_member) { + let user_permission_level = command_permission_levels.PUBLIC; + if (guild_member.roles.cache.has(guild_staff_role_id)) { + user_permission_level = command_permission_levels.STAFF; + } + if (guild_member.roles.cache.has(guild_moderator_role_id)) { + user_permission_level = command_permission_levels.MODERATORS; + } + if (guild_member.roles.cache.has(guild_admin_role_id)) { + user_permission_level = command_permission_levels.ADMINS; + } + if (guild_member.roles.cache.has(guild_team_leaders_role_id)) { + user_permission_level = command_permission_levels.TEAM_LEADERS; + } + if (guild_member.roles.cache.has(guild_directors_role_id)) { + user_permission_level = command_permission_levels.DIRECTORS; + } + if (guild_member.roles.cache.has(guild_founders_role_id)) { + user_permission_level = command_permission_levels.FOUNDERS; + } + return user_permission_level; +} +exports.getUserPermissionLevel = getUserPermissionLevel; +//# sourceMappingURL=bot.js.map \ No newline at end of file diff --git a/dist/bot/common/bot.js.map b/dist/bot/common/bot.js.map new file mode 100644 index 00000000..4d87679c --- /dev/null +++ b/dist/bot/common/bot.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bot.js","sourceRoot":"","sources":["../../../src/bot/common/bot.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;;;;;;;;;;;;;;;;;;;;AAExD,mHAAmH;AAEnH,oDAAsC;AAEtC,mHAAmH;AAEnH,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC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AC,mBAAmB,CAAC,EAAE;QACnD,qBAAqB,GAAG,yBAAyB,CAAC,MAAM,CAAC;KAC5D;IAED,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE;QAC1D,qBAAqB,GAAG,yBAAyB,CAAC,YAAY,CAAC;KAClE;IAED,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE;QACvD,qBAAqB,GAAG,yBAAyB,CAAC,SAAS,CAAC;KAC/D;IAED,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE;QACtD,qBAAqB,GAAG,yBAAyB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC;AAOG,wDAAsB"} \ No newline at end of file diff --git a/dist/bot/common/message.js b/dist/bot/common/message.js new file mode 100644 index 00000000..8055754a --- /dev/null +++ b/dist/bot/common/message.js @@ -0,0 +1,28 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const discord_client_js_1 = require("../discord_client.js"); +//---------------------------------------------------------------------------------------------------------------// +/** + * Disables all message components on a message. + */ +function disableMessageComponents(message) { + if (!(message instanceof discord_client_js_1.Discord.Message)) + throw new TypeError('message must be an instance of Discord.Message'); + return message.fetch(true).then(message => message.edit({ + embeds: message.embeds, + components: message.components.map(component_row => ({ + ...component_row.toJSON(), + components: component_row.components.map(component => ({ + ...component.toJSON(), + disabled: true, + })), + })), + })); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + disableMessageComponents, +}; +//# sourceMappingURL=message.js.map \ No newline at end of file diff --git a/dist/bot/common/message.js.map b/dist/bot/common/message.js.map new file mode 100644 index 00000000..2afb22b8 --- /dev/null +++ b/dist/bot/common/message.js.map @@ -0,0 +1 @@ +{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/bot/common/message.ts"],"names":[],"mappings":";AAAA,wDAAwD;;AAExD,mHAAmH;AAEnH,4DAA+C;AAE/C,mHAAmH;AAEnH;;GAEG;AACH,SAAS,wBAAwB,CAAC,OAAwB;IACtD,IAAI,CAAC,CAAC,OAAO,YAAY,2BAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IAEjH,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;QACpD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YACjD,GAAG,aAAa,CAAC,MAAM,EAAE;YACzB,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBACnD,GAAG,SAAS,CAAC,MAAM,EAAE;gBACrB,QAAQ,EAAE,IAAI;aACjB,CAAC,CAAC;SACN,CAAC,CAA0C;KAC/C,CAAC,CAAC,CAAC;AACR,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,wBAAwB;CAC3B,CAAC"} \ No newline at end of file diff --git a/dist/bot/discord_client.js b/dist/bot/discord_client.js new file mode 100644 index 00000000..13a5933b --- /dev/null +++ b/dist/bot/discord_client.js @@ -0,0 +1,69 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.client = exports.Discord = void 0; +//---------------------------------------------------------------------------------------------------------------// +const Discord = __importStar(require("discord.js")); +exports.Discord = Discord; +//---------------------------------------------------------------------------------------------------------------// +const client = new Discord.Client({ + allowedMentions: { + parse: [ + 'users', + 'roles', + ], + repliedUser: true, + }, + intents: [ + Discord.Intents.FLAGS.GUILDS, + Discord.Intents.FLAGS.GUILD_MEMBERS, + Discord.Intents.FLAGS.GUILD_MESSAGES, + Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS, + Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, + Discord.Intents.FLAGS.GUILD_INTEGRATIONS, + Discord.Intents.FLAGS.GUILD_WEBHOOKS, + Discord.Intents.FLAGS.GUILD_INVITES, + Discord.Intents.FLAGS.GUILD_BANS, + Discord.Intents.FLAGS.DIRECT_MESSAGES, + ], + partials: [ + 'CHANNEL', + ], + presence: { + status: 'online', + activities: [ + { + type: 'LISTENING', + name: `${process.env.BOT_COMMAND_PREFIX}help`, + }, + ], + }, +}); +exports.client = client; +client.$ = { + commands: new Discord.Collection(), + interactions: new Discord.Collection(), +}; +//---------------------------------------------------------------------------------------------------------------// +/* login the discord bot */ +client.login(process.env.BOT_TOKEN); +//# sourceMappingURL=discord_client.js.map \ No newline at end of file diff --git a/dist/bot/discord_client.js.map b/dist/bot/discord_client.js.map new file mode 100644 index 00000000..cd60ffb4 --- /dev/null +++ b/dist/bot/discord_client.js.map @@ -0,0 +1 @@ +{"version":3,"file":"discord_client.js","sourceRoot":"","sources":["../../src/bot/discord_client.ts"],"names":[],"mappings":";AAAA,wDAAwD;;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at end of file diff --git a/dist/bot/events/guild_member_add.js b/dist/bot/events/guild_member_add.js new file mode 100644 index 00000000..27b0f85b --- /dev/null +++ b/dist/bot/events/guild_member_add.js @@ -0,0 +1,49 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { guildMemberAddLogger } = require('../handlers/logs/guild_member_retention.js'); +const { welcomeMessageHandler } = require('../handlers/welcome_message_handler.js'); +const { illegalNicknameHandler } = require('../handlers/illegal_nickname_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +if (typeof bot_guild_id !== 'string') + throw new TypeError('bot_guild_id is not a string'); +const new_to_the_server_role_ids_string = process.env.BOT_NEW_TO_THE_SERVER_AUTO_ROLE_IDS; +if (typeof new_to_the_server_role_ids_string !== 'string') + throw new TypeError('new_to_the_server_role_ids_string is not a string'); +//---------------------------------------------------------------------------------------------------------------// +const new_to_the_server_role_ids = new_to_the_server_role_ids_string.split(','); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'guildMemberAdd', + async handler(member) { + if (member.user.system) + return; // don't operate on system accounts + if (member.user.bot) + return; // don't operate on bots to prevent feedback-loops + if (member.guild.id !== bot_guild_id) + return; // don't operate on other guilds + try { + await member.fetch(true); + } + catch (error) { + console.trace('Failed to fetch member:', error); + return; + } + /* give new-to-the-server roles to the member */ + try { + await member.roles.add(new_to_the_server_role_ids); + } + catch (error) { + console.trace('Failed to give new-to-the-server roles to the member:', error); + } + /* log members joining */ + await guildMemberAddLogger(member).catch(console.trace); + /* send the welcome message to the member */ + await welcomeMessageHandler(member).catch(console.trace); + /* handle nicknames for new members */ + await illegalNicknameHandler(member).catch(console.trace); + }, +}; +//# sourceMappingURL=guild_member_add.js.map \ No newline at end of file diff --git a/dist/bot/events/guild_member_add.js.map b/dist/bot/events/guild_member_add.js.map new file mode 100644 index 00000000..278894d7 --- /dev/null +++ b/dist/bot/events/guild_member_add.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_add.js","sourceRoot":"","sources":["../../../src/bot/events/guild_member_add.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AACvF,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACpF,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AAEtF,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC9C,IAAI,OAAO,YAAY,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;AAE1F,MAAM,iCAAiC,GAAG,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC;AAC1F,IAAI,OAAO,iCAAiC,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;AAEpI,mHAAmH;AAEnH,MAAM,0BAA0B,GAAG,iCAAiC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAEhF,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,gBAAgB;IACtB,KAAK,CAAC,OAAO,CAAC,MAAM;QAChB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,mCAAmC;QACnE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,kDAAkD;QAC/E,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY;YAAE,OAAO,CAAC,gCAAgC;QAE9E,IAAI;YACA,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC5B;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,OAAO;SACV;QAED,gDAAgD;QAChD,IAAI;YACA,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;SACtD;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,uDAAuD,EAAE,KAAK,CAAC,CAAC;SACjF;QAED,yBAAyB;QACzB,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExD,4CAA4C;QAC5C,MAAM,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEzD,sCAAsC;QACtC,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/guild_member_remove.js b/dist/bot/events/guild_member_remove.js new file mode 100644 index 00000000..67b7c46e --- /dev/null +++ b/dist/bot/events/guild_member_remove.js @@ -0,0 +1,24 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { guildMemberRemoveLogger } = require('../handlers/logs/guild_member_retention.js'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +if (typeof bot_guild_id !== 'string') + throw new TypeError('bot_guild_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'guildMemberRemove', + async handler(member) { + if (member.user.system) + return; // don't operate on system accounts + if (member.user.bot) + return; // don't operate on bots to prevent feedback-loops + if (member.guild.id !== bot_guild_id) + return; // don't operate on other guilds + /* log members leaving */ + await guildMemberRemoveLogger(member).catch(console.trace); + }, +}; +//# sourceMappingURL=guild_member_remove.js.map \ No newline at end of file diff --git a/dist/bot/events/guild_member_remove.js.map b/dist/bot/events/guild_member_remove.js.map new file mode 100644 index 00000000..2169abbe --- /dev/null +++ b/dist/bot/events/guild_member_remove.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_remove.js","sourceRoot":"","sources":["../../../src/bot/events/guild_member_remove.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC9C,IAAI,OAAO,YAAY,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,OAAO,CAAC,MAAM;QAChB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,mCAAmC;QACnE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,kDAAkD;QAC/E,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY;YAAE,OAAO,CAAC,gCAAgC;QAE9E,yBAAyB;QACzB,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/guild_member_update.js b/dist/bot/events/guild_member_update.js new file mode 100644 index 00000000..30638ad3 --- /dev/null +++ b/dist/bot/events/guild_member_update.js @@ -0,0 +1,37 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { illegalNicknameHandler } = require('../handlers/illegal_nickname_handler.js'); +const { guildMemberRolesAddedLogger, guildMemberRolesRemovedLogger } = require('../handlers/logs/guild_member_roles.js'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +if (typeof bot_guild_id !== 'string') + throw new TypeError('bot_guild_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'guildMemberUpdate', + async handler(old_member, new_member) { + if (!(old_member || new_member)) + return; + if (new_member.user.system) + return; // don't operate on system accounts + if (new_member.user.bot) + return; // don't operate on bots to prevent feedback-loops + if (old_member.guild.id !== bot_guild_id) + return; // don't operate on other guilds + /* user nickname validator */ + if (old_member.displayName !== new_member.displayName) { + await illegalNicknameHandler(new_member); + } + /* roles added logger */ + if (old_member.roles.cache.size < new_member.roles.cache.size) { + await guildMemberRolesAddedLogger(old_member, new_member); + } + /* roles removed logger */ + if (old_member.roles.cache.size > new_member.roles.cache.size) { + await guildMemberRolesRemovedLogger(old_member, new_member); + } + }, +}; +//# sourceMappingURL=guild_member_update.js.map \ No newline at end of file diff --git a/dist/bot/events/guild_member_update.js.map b/dist/bot/events/guild_member_update.js.map new file mode 100644 index 00000000..1b4b1848 --- /dev/null +++ b/dist/bot/events/guild_member_update.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_update.js","sourceRoot":"","sources":["../../../src/bot/events/guild_member_update.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AACtF,MAAM,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAEzH,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC9C,IAAI,OAAO,YAAY,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU;QAChC,IAAI,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC;YAAE,OAAO;QACxC,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,mCAAmC;QACvE,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,CAAC,kDAAkD;QACnF,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY;YAAE,OAAO,CAAC,gCAAgC;QAElF,6BAA6B;QAC7B,IAAI,UAAU,CAAC,WAAW,KAAK,UAAU,CAAC,WAAW,EAAE;YACnD,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;SAC5C;QAED,wBAAwB;QACxB,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;YAC3D,MAAM,2BAA2B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SAC7D;QAED,0BAA0B;QAC1B,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE;YAC3D,MAAM,6BAA6B,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SAC/D;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/interaction_create.js b/dist/bot/events/interaction_create.js new file mode 100644 index 00000000..2ecaee02 --- /dev/null +++ b/dist/bot/events/interaction_create.js @@ -0,0 +1,17 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { interactionHandler } = require('../handlers/interaction_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'interactionCreate', + async handler(interaction) { + /* don't allow bots */ + if (interaction.user.bot) + return; + /* handle interactions */ + interactionHandler(interaction); + }, +}; +//# sourceMappingURL=interaction_create.js.map \ No newline at end of file diff --git a/dist/bot/events/interaction_create.js.map b/dist/bot/events/interaction_create.js.map new file mode 100644 index 00000000..335542af --- /dev/null +++ b/dist/bot/events/interaction_create.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interaction_create.js","sourceRoot":"","sources":["../../../src/bot/events/interaction_create.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AAE7E,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,OAAO,CAAC,WAAW;QACrB,sBAAsB;QACtB,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjC,yBAAyB;QACzB,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/message_create.js b/dist/bot/events/message_create.js new file mode 100644 index 00000000..50d37fd9 --- /dev/null +++ b/dist/bot/events/message_create.js @@ -0,0 +1,56 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { client } = require('../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +const { automatedQuickSupportHandler } = require('../handlers/automated_quick_support_handler.js'); +const { suggestionsCategoryHandler } = require('../handlers/suggestions_category_handler.js'); +const { oneWordStoryChannelHandler } = require('../handlers/one_word_story_channel_handler.js'); +const { commandHandler } = require('../handlers/command_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +const command_prefix = process.env.BOT_COMMAND_PREFIX; +const suggestions_category_id = process.env.BOT_SUGGESTIONS_CATEGORY_ID; +const one_word_story_channel_id = process.env.BOT_ONE_WORD_STORY_CHANNEL_ID; +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'messageCreate', + async handler(message) { + /* don't allow bots */ + if (message.author.bot) + return; + /* only allow text channels */ + if (message.channel.type !== 'GUILD_TEXT') + return; + /* handle messages sent in suggestions channels */ + if (message.channel.parent?.id === suggestions_category_id) { + suggestionsCategoryHandler(message); + return; + } + /* handle messages sent in the one-word-story channel */ + if (message.channel.id === one_word_story_channel_id) { + oneWordStoryChannelHandler(message); + return; + } + /* respond to mentions of this bot */ + if (message.content.startsWith(`<@!${client.user.id}>`)) { + message.reply({ + content: [ + `The command_prefix for me is \`${command_prefix}\`.`, + `To see a list of commands do \`${command_prefix}help\`!`, + ].join('\n'), + }).catch(console.warn); + return; + } + /* handle commands */ + const command_prefix_regex = new RegExp(`^${command_prefix}[a-z0-9_-]+`, 'i'); + const message_starts_with_command_prefix = command_prefix_regex.test(message.cleanContent); + if (message_starts_with_command_prefix) { + commandHandler(message); + return; + } + /* attempt automated quick support */ + automatedQuickSupportHandler(message).catch(console.trace); + }, +}; +//# sourceMappingURL=message_create.js.map \ No newline at end of file diff --git a/dist/bot/events/message_create.js.map b/dist/bot/events/message_create.js.map new file mode 100644 index 00000000..d9f1eb99 --- /dev/null +++ b/dist/bot/events/message_create.js.map @@ -0,0 +1 @@ +{"version":3,"file":"message_create.js","sourceRoot":"","sources":["../../../src/bot/events/message_create.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEnD,mHAAmH;AAEnH,MAAM,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC,gDAAgD,CAAC,CAAC;AACnG,MAAM,EAAE,0BAA0B,EAAE,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC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rB,MAAM,oBAAoB,GAAG,IAAI,MAAM,CAAC,IAAI,cAAc,aAAa,EAAE,GAAG,CAAC,CAAC;QAC9E,MAAM,kCAAkC,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3F,IAAI,kCAAkC,EAAE;YACpC,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,OAAO;SACV;QAED,qCAAqC;QACrC,4BAA4B,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/message_delete.js b/dist/bot/events/message_delete.js new file mode 100644 index 00000000..52eddb53 --- /dev/null +++ b/dist/bot/events/message_delete.js @@ -0,0 +1,24 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { guildMemberMessageDeleteLogger } = require('../handlers/logs/guild_member_messages'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +if (typeof bot_guild_id !== 'string') + throw new TypeError('bot_guild_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'messageDelete', + async handler(message) { + if (message.author.system) + return; // don't operate on system accounts + if (message.author.bot) + return; // don't operate on bots to prevent feedback-loops + if (message.guild.id !== bot_guild_id) + return; // don't operate on other guilds + /* log message deletions */ + await guildMemberMessageDeleteLogger(message).catch(console.trace); + }, +}; +//# sourceMappingURL=message_delete.js.map \ No newline at end of file diff --git a/dist/bot/events/message_delete.js.map b/dist/bot/events/message_delete.js.map new file mode 100644 index 00000000..0c32b3b8 --- /dev/null +++ b/dist/bot/events/message_delete.js.map @@ -0,0 +1 @@ +{"version":3,"file":"message_delete.js","sourceRoot":"","sources":["../../../src/bot/events/message_delete.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,8BAA8B,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAE7F,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC9C,IAAI,OAAO,YAAY,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,eAAe;IACrB,KAAK,CAAC,OAAO,CAAC,OAAO;QACjB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,CAAC,mCAAmC;QACtE,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,CAAC,kDAAkD;QAClF,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY;YAAE,OAAO,CAAC,gCAAgC;QAE/E,2BAA2B;QAC3B,MAAM,8BAA8B,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/message_update.js b/dist/bot/events/message_update.js new file mode 100644 index 00000000..e68650ae --- /dev/null +++ b/dist/bot/events/message_update.js @@ -0,0 +1,24 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { guildMemberMessageUpdateLogger } = require('../handlers/logs/guild_member_messages'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +if (typeof bot_guild_id !== 'string') + throw new TypeError('bot_guild_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'messageUpdate', + async handler(old_message, new_message) { + if (old_message.author.system) + return; // don't operate on system accounts + if (old_message.author.bot) + return; // don't operate on bots to prevent feedback-loops + if (old_message.guild.id !== bot_guild_id) + return; // don't operate on other guilds + /* log message edits */ + await guildMemberMessageUpdateLogger(old_message, new_message).catch(console.trace); + }, +}; +//# sourceMappingURL=message_update.js.map \ No newline at end of file diff --git a/dist/bot/events/message_update.js.map b/dist/bot/events/message_update.js.map new file mode 100644 index 00000000..b5dd6595 --- /dev/null +++ b/dist/bot/events/message_update.js.map @@ -0,0 +1 @@ +{"version":3,"file":"message_update.js","sourceRoot":"","sources":["../../../src/bot/events/message_update.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,8BAA8B,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAE7F,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC9C,IAAI,OAAO,YAAY,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;AAE1F,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,IAAI,EAAE,eAAe;IACrB,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW;QAClC,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,CAAC,mCAAmC;QAC1E,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG;YAAE,OAAO,CAAC,kDAAkD;QACtF,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY;YAAE,OAAO,CAAC,gCAAgC;QAEnF,uBAAuB;QACvB,MAAM,8BAA8B,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxF,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/events/ready.js b/dist/bot/events/ready.js new file mode 100644 index 00000000..97f0ad78 --- /dev/null +++ b/dist/bot/events/ready.js @@ -0,0 +1,107 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const fs = require('node:fs'); +const path = require('node:path'); +const axios = require('axios'); +const moment = require('moment-timezone'); +const recursiveReadDirectory = require('recursive-read-directory'); +//---------------------------------------------------------------------------------------------------------------// +const { Timer } = require('../../utilities.js'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { client } = require('../discord_client.js'); +const { illegalNicknameHandler } = require('../handlers/illegal_nickname_handler.js'); +//---------------------------------------------------------------------------------------------------------------// +const bot_guild_id = process.env.BOT_GUILD_ID; +//---------------------------------------------------------------------------------------------------------------// +const setProductPricesInDB = async () => { + /* fetch all products from the database */ + const db_roblox_products = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, {}); + /* fetch the product prices from roblox and apply it to the database */ + for (const db_roblox_product of db_roblox_products) { + let product_price_in_robux; + try { + const response = await axios({ + method: 'get', + url: `https://api.roblox.com/marketplace/productDetails?productId=${encodeURIComponent(db_roblox_product.roblox_product_id)}`, + headers: { + 'Content-Type': 'application/json', + }, + validateStatus: (status) => status === 200, + }); + product_price_in_robux = response?.data?.PriceInRobux ?? null; + if (!product_price_in_robux) + throw new Error('Failed to fetch product price from Roblox!'); + } + catch { + console.warn(`Unable to fetch price for product: ${db_roblox_product.code}; skipping product!`); + continue; // skip this product since the price cannot be fetched + } + const parsed_product_price_in_robux = Number.parseInt(product_price_in_robux); // Robux can only be an integer + if (Number.isNaN(parsed_product_price_in_robux)) { + console.warn(`Unable to parse price for product: ${db_roblox_product.code}; skipping product!`); + continue; // skip this product since the price cannot be parsed + } + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, { + roblox_product_id: db_roblox_product.roblox_product_id, + }, { + $set: { + 'price_in_robux': parsed_product_price_in_robux, + }, + }); + await Timer(250); // prevent api abuse + } + return; // complete async +}; +const updateBotNickname = async () => { + const bot_guild = client.guilds.resolve(bot_guild_id); + await bot_guild.me.setNickname(`${process.env.BOT_COMMAND_PREFIX} | ${client.user.username}`, 'fixing my nickname').catch(console.trace); + return; // complete async +}; +const removeIllegalNicknames = async () => { + const bot_guild = client.guilds.resolve(bot_guild_id); + const bot_guild_members = await bot_guild.members.fetch(); + for (const bot_guild_member of bot_guild_members.values()) { + illegalNicknameHandler(bot_guild_member); + await Timer(10_000); // prevent api abuse + } + return; // complete async +}; +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + name: 'ready', + async handler() { + const ready_timestamp = `${moment()}`; + console.log('----------------------------------------------------------------------------------------------------------------'); + console.log(`Discord Bot Logged in as ${client.user.tag} on ${ready_timestamp}`); + console.log('----------------------------------------------------------------------------------------------------------------'); + /* register commands */ + const command_files_path = path.join(process.cwd(), './src/bot/commands/'); + const command_files = fs.readdirSync(command_files_path).filter(file => file.endsWith('.js')); + for (const command_file of command_files) { + const bot_command = require(path.join(command_files_path, command_file)); + client.$.commands.set(bot_command.name, bot_command); + } + /* register interactions */ + const interaction_files_path = path.join(process.cwd(), './src/bot/interactions/'); + const interaction_file_names = recursiveReadDirectory(interaction_files_path); + for (const interaction_file_name of interaction_file_names) { + const interaction_file_path = path.join(interaction_files_path, interaction_file_name); + const interaction = require(interaction_file_path); + const interaction_exists = client.$.interactions.has(interaction.identifier); + if (interaction_exists) { + console.warn(`Interaction: ${interaction.name}; already exists; skipping \'${interaction_file_path}\'.`); + continue; + } + client.$.interactions.set(interaction.identifier, interaction); + } + /* set the product prices in the database after 1 minute */ + setTimeout(() => setProductPricesInDB(), 1 * 60_000); + /* update the bot nickname after 10 minutes */ + setTimeout(() => updateBotNickname(), 10 * 60_000); + /* remove illegal nicknames after 30 minutes */ + setTimeout(() => removeIllegalNicknames(), 30 * 60_000); + }, +}; +//# sourceMappingURL=ready.js.map \ No newline at end of file diff --git a/dist/bot/events/ready.js.map b/dist/bot/events/ready.js.map new file mode 100644 index 00000000..9791e629 --- /dev/null +++ b/dist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AAsB,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;IAC5D,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/automated_quick_support_handler.js b/dist/bot/handlers/automated_quick_support_handler.js new file mode 100644 index 00000000..56d7b7fb --- /dev/null +++ b/dist/bot/handlers/automated_quick_support_handler.js @@ -0,0 +1,113 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const stringSimilarity = require('string-similarity'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { client } = require('../discord_client.js'); +const { math_clamp } = require('../../utilities.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {{ + * id: string, + * title: string, + * searchable_queries: string[], + * support_contents: string, + * }} QuickSupportTopic + * @typedef {QuickSupportTopic[]} QuickSupportTopics + */ +//---------------------------------------------------------------------------------------------------------------// +/** @type {QuickSupportTopics} */ +const quick_support_topics = []; +const confidence_threshold = 0.75; +//---------------------------------------------------------------------------------------------------------------// +async function updateQuickSupportTopics() { + const db_quick_support_topics = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME, {}); + quick_support_topics.length = 0; // empty the array + for (const db_quick_support_topic of db_quick_support_topics) { + quick_support_topics.push(db_quick_support_topic); + } +} +setImmediate(() => updateQuickSupportTopics()); +setInterval(() => updateQuickSupportTopics(), 15 * 60_000); // every 15 minutes +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {string} string_1 + * @param {string} string_2 + * @returns {number} + */ +function getSimilarityScore(string_1, string_2) { + return stringSimilarity.compareTwoStrings(string_1.toLowerCase(), string_2.toLowerCase()); +} +/** + * @param {string} user_input + * @param {QuickSupportTopic} quick_support_topic + * @returns {number} + */ +function generateSimilarityScoreForQuickSupportTopic(user_input, quick_support_topic) { + let similarity_score = 0; + for (const searchable_query of quick_support_topic.searchable_queries) { + const searchable_query_similarity_score = getSimilarityScore(user_input, searchable_query); + if (searchable_query_similarity_score <= similarity_score) + continue; + similarity_score = searchable_query_similarity_score; + } + const title_similarity_score = getSimilarityScore(user_input, quick_support_topic.title); + if (title_similarity_score > similarity_score) { + similarity_score = title_similarity_score; + } + return similarity_score; +} +/** + * @param {string} user_input + * @returns {(QuickSupportTopic & { similarity_score: number })[]} + */ +function findPotentialMatchingQuickSupportTopics(user_input) { + const mapped_quick_support_topics = []; + for (const quick_support_topic of quick_support_topics) { + mapped_quick_support_topics.push({ + ...quick_support_topic, + /** On a scale from (0 -> 1) */ + similarity_score: generateSimilarityScoreForQuickSupportTopic(user_input, quick_support_topic), + }); + } + const matching_qs_topics = mapped_quick_support_topics.filter(quick_support_topic => quick_support_topic.similarity_score >= confidence_threshold).sort((a, b) => b.similarity_score - a.similarity_score); + return matching_qs_topics; +} +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Message} message + */ +async function automatedQuickSupportHandler(message) { + if (message.author.system || message.author.bot) + return; + if (message.cleanContent.length < 5) + return; + if (!(/\w+/gi).test(message.cleanContent)) + return; + const matching_qs_topics = findPotentialMatchingQuickSupportTopics(message.cleanContent).slice(0, 3); + if (matching_qs_topics.length === 0) + return; + message.reply({ + content: [ + `I found ${matching_qs_topics.length} quick support topic(s) that might be related to your message!`, + ].join('\n'), + embeds: matching_qs_topics.map(quick_support_topic => ({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Automatic Quick Support', + }, + title: quick_support_topic.title, + description: quick_support_topic.support_contents, + footer: { + text: `Automated Confidence: ${(math_clamp(quick_support_topic.similarity_score * 100, 0, 100)).toFixed(2)}%`, + }, + })), + }).catch(console.warn); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + automatedQuickSupportHandler, +}; +//# sourceMappingURL=automated_quick_support_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/automated_quick_support_handler.js.map b/dist/bot/handlers/automated_quick_support_handler.js.map new file mode 100644 index 00000000..8d7c3122 --- /dev/null +++ b/dist/bot/handlers/automated_quick_support_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"automated_quick_support_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/automated_quick_support_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEtD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAExD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEnD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAErD,mHAAmH;AAEnH;;;;;;;;GAQG;AAEH,mHAAmH;AAEnH,iCAAiC;AACjC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,mHAAmH;AAEnH,KAAK,UAAU,wBAAwB;IACnC,MAAM,uBAAuB,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,0CAA0C,EAAE,EAAE,CAAC,CAAC;IAEpJ,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,kBAAkB;IACnD,KAAK,MAAM,sBAAsB,IAAI,uBAAuB,EAAE;QAC1D,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;KACrD;AACL,CAAC;AACD,YAAY,CAAC,GAAG,EAAE,CAAC,wBAAwB,EAAE,CAAC,CAAC;AAC/C,WAAW,CAAC,GAAG,EAAE,CAAC,wBAAwB,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,mBAAmB;AAE/E,mHAAmH;AA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IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,4BAA4B;CAC/B,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/command_handler.js b/dist/bot/handlers/command_handler.js new file mode 100644 index 00000000..50001e12 --- /dev/null +++ b/dist/bot/handlers/command_handler.js @@ -0,0 +1,111 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client, } = require('../discord_client.js'); +const { command_permission_levels, getUserPermissionLevel, user_is_not_allowed_access_to_command_message_options, } = require('../common/bot.js'); +//---------------------------------------------------------------------------------------------------------------// +const command_prefix = process.env.BOT_COMMAND_PREFIX; +//---------------------------------------------------------------------------------------------------------------// +const command_cooldown_tracker = new Discord.Collection(); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Message} message + */ +async function commandHandler(message) { + const command_name = message.content.split(/\s+/g)[0].replace(command_prefix, '').toLowerCase(); + const command_args = message.content.split(/\s+/g).slice(1); + if (command_name.length === 0) + return; // don't continue if the only thing sent was the command prefix + /* find the command */ + const command = client.$.commands.find(cmd => cmd.aliases?.includes(command_name)); + if (!command) { + await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + description: 'That command does not exist!', + }), + ], + }); + return; + } + /* command validation */ + if (typeof command.name !== 'string') + throw new TypeError(`\`command.name\` is not a string for command: ${command}`); + if (typeof command.description !== 'string') + throw new TypeError(`\`command.description\` is not a string for command: ${command}`); + if (!Array.isArray(command.aliases)) + throw new TypeError(`\`command.aliases\` is not an array for command: ${command}`); + if (typeof command.permission_level !== 'number') + throw new TypeError(`\`command.permission_level\` is not a number for command: ${command}`); + /* command permission preparation */ + const user_permission_level = getUserPermissionLevel(message.member); + /* command permission checking */ + const user_has_access_to_command = user_permission_level >= command.permission_level; + if (!user_has_access_to_command) { + await message.channel.send(user_is_not_allowed_access_to_command_message_options).catch(console.warn); + return; + } + /* command cooldown */ + const command_cooldown_in_ms = command.cooldown ?? 5_000; + const last_command_epoch_for_user = command_cooldown_tracker.get(message.author.id)?.last_command_epoch ?? Date.now() - command_cooldown_in_ms; + const current_command_epoch = Date.now(); + command_cooldown_tracker.set(message.author.id, { last_command_epoch: current_command_epoch }); + const user_triggered_command_cooldown = current_command_epoch - last_command_epoch_for_user < command_cooldown_in_ms; + const user_is_a_staff_member = user_permission_level >= command_permission_levels.STAFF; + if (user_triggered_command_cooldown && !user_is_a_staff_member) { + await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username} | Command Cooldown System`, + }, + description: `\`${command_name}\` is on a cooldown of \`${command_cooldown_in_ms / 1000}s\`!`, + }), + ], + }).catch(console.warn); + return; + } + /* command logging */ + console.info({ + discord_user_id: message.author.id, + command_name: command_name, + command_args: command_args, + }); + /* command execution */ + try { + await command.execute(message, { + command_prefix, + command_name, + command_args, + }); + } + catch (error) { + console.trace({ + command_name: command_name, + command_args: command_args, + error_message: error, + }); + await message.reply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: `${client.user.username}`, + }, + title: 'Command Error', + description: `It looks like I ran into an error with the \`${command_name}\` command!`, + }), + ], + }).catch(console.warn); + } +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + commandHandler, +}; +//# sourceMappingURL=command_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/command_handler.js.map b/dist/bot/handlers/command_handler.js.map new file mode 100644 index 00000000..31b72198 --- /dev/null +++ b/dist/bot/handlers/command_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"command_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/command_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb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,EAAE;wBAC7D,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;qBAClC;oBACD,KAAK,EAAE,eAAe;oBACtB,WAAW,EAAE,gDAAgD,YAAY,aAAa;iBACzF,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1B;AACL,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,cAAc;CACjB,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/illegal_nickname_handler.js b/dist/bot/handlers/illegal_nickname_handler.js new file mode 100644 index 00000000..4abea6e7 --- /dev/null +++ b/dist/bot/handlers/illegal_nickname_handler.js @@ -0,0 +1,41 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Timer } = require('../../utilities.js'); +//---------------------------------------------------------------------------------------------------------------// +const non_allowed_regex_filter = /[^\w\d]|_/gi; +const display_name_override_nickname = 'Illegal Nickname'; +const display_name_override_reason = 'The user\'s display name contained too many non-allowed characters.'; +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {import('discord.js').GuildMember} GuildMember + */ +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {GuildMember} member + */ +async function illegalNicknameHandler(member) { + if (member.user.bot) + return; + if (member.user.system) + return; + if (!member.manageable) + return; // the user has a higher role than the bot, so don't continue + const user_display_name = `${member.displayName}`; // force to be a string + const non_allowed_occurrences = user_display_name.match(non_allowed_regex_filter) ?? []; // force to be an array + const non_allowed_occurrences_threshold = user_display_name.length / 3; // 1/3rd of the display name + const non_allowed_occurrences_threshold_exceeded = non_allowed_occurrences.length > non_allowed_occurrences_threshold; + if (!non_allowed_occurrences_threshold_exceeded) + return; // only proceed if the non-allowed character threshold is exceeded + await Timer(5_000); // try to prevent the user from spamming nickname changes + try { + await member.setNickname(display_name_override_nickname, display_name_override_reason); + } + catch { } // ignore any errors, as they will most likely be related to missing permissions +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + illegalNicknameHandler, +}; +//# sourceMappingURL=illegal_nickname_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/illegal_nickname_handler.js.map b/dist/bot/handlers/illegal_nickname_handler.js.map new file mode 100644 index 00000000..ddc04318 --- /dev/null +++ b/dist/bot/handlers/illegal_nickname_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"illegal_nickname_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/illegal_nickname_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEhD,mHAAmH;AAEnH,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAE/C,MAAM,8BAA8B,GAAG,kBAAkB,CAAC;AAC1D,MAAM,4BAA4B,GAAG,qEAAqE,CAAC;AAE3G,mHAAmH;AAEnH;;GAEG;AAEH,mHAAmH;AAEnH;;GAEG;AACH,KAAK,UAAU,sBAAsB,CAAC,MAAM;IACxC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG;QAAE,OAAO;IAC5B,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO;IAC/B,IAAI,CAAC,MAAM,CAAC,UAAU;QAAE,OAAO,CAAC,6DAA6D;IAE7F,MAAM,iBAAiB,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,uBAAuB;IAC1E,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,uBAAuB;IAEhH,MAAM,iCAAiC,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,4BAA4B;IACpG,MAAM,0CAA0C,GAAG,uBAAuB,CAAC,MAAM,GAAG,iCAAiC,CAAC;IAEtH,IAAI,CAAC,0CAA0C;QAAE,OAAO,CAAC,kEAAkE;IAE3H,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,yDAAyD;IAE7E,IAAI;QACA,MAAM,MAAM,CAAC,WAAW,CAAC,8BAA8B,EAAE,4BAA4B,CAAC,CAAC;KAC1F;IAAC,MAAM,GAAE,CAAC,gFAAgF;AAC/F,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,sBAAsB;CACzB,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/interaction_handler.js b/dist/bot/handlers/interaction_handler.js new file mode 100644 index 00000000..ad3347fb --- /dev/null +++ b/dist/bot/handlers/interaction_handler.js @@ -0,0 +1,57 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { client } = require('../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {import('discord.js').Interaction} DiscordInteraction + * @typedef {{ + * identifier: string, + * execute(interaction: Discord.Interaction) => Promise, + * }} CustomInteraction + */ +//---------------------------------------------------------------------------------------------------------------// +/** + * Handles raw interaction payloads from Discord + * @param {DiscordInteraction} unknown_interaction + * @returns {Promise} + */ +async function interactionHandler(unknown_interaction) { + /** @type {CustomInteraction?} */ + const client_interaction = client.$.interactions.find(client_interaction => { + const unknown_interaction_identifier = unknown_interaction.type === 'MESSAGE_COMPONENT' ? (unknown_interaction.customId) : (unknown_interaction.type === 'APPLICATION_COMMAND' ? (unknown_interaction.commandName) : (unknown_interaction.type === 'APPLICATION_COMMAND_AUTOCOMPLETE' ? (unknown_interaction.commandName) : (unknown_interaction.type === 'PING' ? (unknown_interaction.id) : (null)))); + return client_interaction.identifier === unknown_interaction_identifier; + }); + /* check if the interaction exists */ + if (!client_interaction) { + console.warn('Unknown interaction:', { unknown_interaction }); + if (unknown_interaction.type === 'APPLICATION_COMMAND' && + unknown_interaction.command.type === 'CHAT_INPUT') { + unknown_interaction?.reply('Sorry but this command doesn\'t work right now!'); + } + return; + } + /* interaction logging */ + console.info({ + client_interaction_identifier: client_interaction.identifier, + interaction_type: unknown_interaction.type, + interaction: unknown_interaction, + }); + /* execute the interaction */ + try { + await client_interaction.execute(unknown_interaction); + } + catch (error) { + console.trace({ + client_interaction_identifier: client_interaction.identifier, + interaction_type: unknown_interaction.type, + error_message: error, + }); + } +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + interactionHandler, +}; +//# sourceMappingURL=interaction_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/interaction_handler.js.map b/dist/bot/handlers/interaction_handler.js.map new file mode 100644 index 00000000..dd931ebc --- /dev/null +++ b/dist/bot/handlers/interaction_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interaction_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/interaction_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEnD,mHAAmH;AAEnH;;;;;;GAMG;AAEH,mHAAmH;AAEnH;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,mBAAmB;IACjD,iCAAiC;IACjC,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE;QACvE,MAAM,8BAA8B,GAAG,mBAAmB,CAAC,IAAI,KAAK,mBAAmB,CAAC,CAAC,CAAC,CACtF,mBAAmB,CAAC,QAAQ,CAC/B,CAAC,CAAC,CAAC,CACA,mBAAmB,CAAC,IAAI,KAAK,qBAAqB,CAAC,CAAC,CAAC,CACjD,mBAAmB,CAAC,WAAW,CAClC,CAAC,CAAC,CAAC,CACA,mBAAmB,CAAC,IAAI,KAAK,kCAAkC,CAAC,CAAC,CAAC,CAC9D,mBAAmB,CAAC,WAAW,CAClC,CAAC,CAAC,CAAC,CACA,mBAAmB,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAClC,mBAAmB,CAAC,EAAE,CACzB,CAAC,CAAC,CAAC,CACA,IAAI,CACP,CACJ,CACJ,CACJ,CAAC;QAEF,OAAO,kBAAkB,CAAC,UAAU,KAAK,8BAA8B,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,qCAAqC;IACrC,IACI,CAAC,kBAAkB,EACrB;QACE,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAE9D,IACI,mBAAmB,CAAC,IAAI,KAAK,qBAAqB;YAClD,mBAAmB,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,EACnD;YACE,mBAAmB,EAAE,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACjF;QAED,OAAO;KACV;IAED,yBAAyB;IACzB,OAAO,CAAC,IAAI,CAAC;QACT,6BAA6B,EAAE,kBAAkB,CAAC,UAAU;QAC5D,gBAAgB,EAAE,mBAAmB,CAAC,IAAI;QAC1C,WAAW,EAAE,mBAAmB;KACnC,CAAC,CAAC;IAEH,6BAA6B;IAC7B,IAAI;QACA,MAAM,kBAAkB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC;YACV,6BAA6B,EAAE,kBAAkB,CAAC,UAAU;YAC5D,gBAAgB,EAAE,mBAAmB,CAAC,IAAI;YAC1C,aAAa,EAAE,KAAK;SACvB,CAAC,CAAC;KACN;AACL,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,kBAAkB;CACrB,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/log_moderation_action_handler.js b/dist/bot/handlers/log_moderation_action_handler.js new file mode 100644 index 00000000..3c9907eb --- /dev/null +++ b/dist/bot/handlers/log_moderation_action_handler.js @@ -0,0 +1,60 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { v4: uuid_v4 } = require('uuid'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {'WARN'|'TIMEOUT'|'MUTE'|'KICK'|'BAN'} ModerationActionType + */ +//---------------------------------------------------------------------------------------------------------------// +/** + * Adds a moderation log to the database + * @param {Object} identity + * @param {String} identity.discord_user_id + * @param {Object} record + * @param {ModerationActionType} record.type + * @param {Number} record.epoch + * @param {String} record.reason + * @param {String} record.staff_member_id + * @returns {Promise} success or failure + */ +async function logModerationActionToDatabase({ discord_user_id }, { type, epoch, reason, staff_member_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string!'); + if (typeof type !== 'string') + throw new TypeError('\`type\` must be a string!'); + if (typeof epoch !== 'number') + throw new TypeError('\`epoch\` must be a number!'); + if (typeof reason !== 'string') + throw new TypeError('\`reason\` must be a string!'); + if (typeof staff_member_id !== 'string') + throw new TypeError('\`staff_member_id\` must be a string!'); + const record_id = uuid_v4(); + try { + await go_mongo_db.add(process.env.MONGO_DATABASE_NAME, process.env.MONGO_MODERATION_ACTION_RECORDS_COLLECTION_NAME, [ + { + 'identity': { + 'discord_user_id': discord_user_id, + }, + 'record': { + 'id': record_id, + 'type': type, + 'epoch': epoch, + 'reason': reason, + 'staff_member_id': staff_member_id, + }, + }, + ]); + } + catch (error) { + console.trace('logModerationActionToDatabase():', error); + return false; + } + return true; +} +module.exports = { + logModerationActionToDatabase, +}; +//# sourceMappingURL=log_moderation_action_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/log_moderation_action_handler.js.map b/dist/bot/handlers/log_moderation_action_handler.js.map new file mode 100644 index 00000000..2f0a1655 --- /dev/null +++ b/dist/bot/handlers/log_moderation_action_handler.js.map @@ -0,0 +1 @@ +{"version":3,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QAAQ,EAAE,MAAM;oBAChB,iBAAiB,EAAE,eAAe;iBACrC;aACJ;SACJ,CAAC,CAAC;KACN;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACb,6BAA6B;CAChC,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_messages.js b/dist/bot/handlers/logs/guild_member_messages.js new file mode 100644 index 00000000..d057220f --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_messages.js @@ -0,0 +1,103 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../../discord_client.js'); +const { string_ellipses, getMarkdownFriendlyTimestamp } = require('../../../utilities.js'); +//---------------------------------------------------------------------------------------------------------------// +const logging_channel_id = process.env.BOT_LOGGING_CHANNEL_ID; +if (typeof logging_channel_id !== 'string') + throw new TypeError('logging_channel_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Message} old_message + * @param {Discord.Message} new_message + */ +async function guildMemberMessageUpdateLogger(old_message, new_message) { + if (new_message.author.bot) + return; + if (new_message.author.system) + return; + if (old_message.content === new_message.content) + return; + const logging_channel = await client.channels.fetch(logging_channel_id); + if (!(logging_channel instanceof Discord.TextChannel)) + throw new Error('Failed to fetch logging channel'); + const message_update_timestamp = getMarkdownFriendlyTimestamp(new_message.editedTimestamp); + await logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + description: `**A message sent by <@${new_message.author.id}> in <#${new_message.channelId}> was modified.**`, + fields: [ + { + name: 'Message', + value: `[${new_message.id}](${new_message.url})`, + inline: false, + }, { + name: 'Author', + value: `@${new_message.author.tag} (${new_message.author.id})`, + inline: false, + }, { + name: 'Modified', + value: ` ()`, + inline: false, + }, { + name: 'Before', + value: old_message.content.length > 0 ? string_ellipses(Discord.Util.escapeMarkdown(old_message.content), 2048) : '\`n/a\`', + inline: false, + }, { + name: 'After', + value: new_message.content.length > 0 ? string_ellipses(Discord.Util.escapeMarkdown(new_message.content), 2048) : '\`n/a\`', + inline: false, + }, + ], + }), + ], + }).catch(console.trace); +} +/** + * @param {Discord.Message} message + */ +async function guildMemberMessageDeleteLogger(message) { + if (message.author.bot) + return; + if (message.author.system) + return; + const logging_channel = await client.channels.fetch(logging_channel_id); + if (!(logging_channel instanceof Discord.TextChannel)) + throw new Error('Failed to fetch logging channel'); + const message_delete_timestamp = getMarkdownFriendlyTimestamp(Date.now()); + await logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF5500, + description: `**A message sent by <@${message.author.id}> in <#${message.channelId}> was deleted.**`, + fields: [ + { + name: 'Message', + value: `[${message.id}](${message.url})`, + inline: false, + }, { + name: 'Author', + value: `@${message.author.tag} (${message.author.id})`, + inline: false, + }, { + name: 'Deleted', + value: ` ()`, + }, { + name: 'Content', + value: message.content.length > 0 ? string_ellipses(Discord.Util.escapeMarkdown(message.content), 2048) : '\`n/a\`', + inline: false, + }, + ], + }), + ], + }).catch(console.trace); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + guildMemberMessageUpdateLogger, + guildMemberMessageDeleteLogger, +}; +//# sourceMappingURL=guild_member_messages.js.map \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_messages.js.map b/dist/bot/handlers/logs/guild_member_messages.js.map new file mode 100644 index 00000000..bc1dab6c --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_messages.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_messages.js","sourceRoot":"","sources":["../../../../src/bot/handlers/logs/guild_member_messages.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAA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;IAE1G,MAAM,wBAAwB,GAAG,4BAA4B,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAE1E,MAAM,eAAe,CAAC,IAAI,CAAC;QACvB,MAAM,EAAE;YACJ,IAAI,OAAO,CAAC,YAAY,CAAC;gBACrB,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,yBAAyB,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,OAAO,CAAC,SAAS,kBAAkB;gBACpG,MAAM,EAAE;oBACJ;wBACI,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,IAAI,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,GAAG,GAAG;wBACxC,MAAM,EAAE,KAAK;qBAChB,EAAE;wBACC,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG;wBACtD,MAAM,EAAE,KAAK;qBAChB,EAAE;wBACC,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,MAAM,wBAAwB,WAAW,wBAAwB,MAAM;qBACjF,EAAE;wBACC,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;wBACnH,MAAM,EAAE,KAAK;qBAChB;iBACJ;aACJ,CAAC;SACL;KACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,8BAA8B;IAC9B,8BAA8B;CACjC,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_retention.js b/dist/bot/handlers/logs/guild_member_retention.js new file mode 100644 index 00000000..15d6c65e --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_retention.js @@ -0,0 +1,90 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../../discord_client.js'); +const { getMarkdownFriendlyTimestamp } = require('../../../utilities.js'); +//---------------------------------------------------------------------------------------------------------------// +const member_retention_logging_channel_id = process.env.BOT_LOGGING_USER_RETENTION_CHANNEL_ID; +if (typeof member_retention_logging_channel_id !== 'string') + throw new TypeError('member_retention_logging_channel_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.GuildMember} member + */ +async function guildMemberAddLogger(member) { + if (!(member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberAddLogger(): member is not a GuildMember'); + const member_retention_logging_channel = await client.channels.fetch(member_retention_logging_channel_id); + if (!member_retention_logging_channel) + throw new Error('Failed to fetch logging channel'); + const user_creation_timestamp = getMarkdownFriendlyTimestamp(member.user.createdTimestamp); + const member_joined_timestamp = getMarkdownFriendlyTimestamp(member.joinedTimestamp); + await member_retention_logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + title: 'A member has joined the server!', + fields: [ + { + name: 'Member', + value: `@${member.user.tag} (${member.user.id})`, + inline: false, + }, { + name: 'Account creation date', + value: ` ()`, + }, { + name: 'Account join date', + value: ` ()`, + }, + ], + }), + ], + }).catch(console.trace); +} +/** + * @param {Discord.GuildMember} member + */ +async function guildMemberRemoveLogger(member) { + if (!(member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberRemoveLogger(): member is not a GuildMember'); + const member_retention_logging_channel = await client.channels.fetch(member_retention_logging_channel_id); + if (!member_retention_logging_channel) + throw new Error('Failed to fetch logging channel'); + const user_creation_timestamp = getMarkdownFriendlyTimestamp(member.user.createdTimestamp); + const member_joined_timestamp = getMarkdownFriendlyTimestamp(member.joinedTimestamp); + const member_left_timestamp = getMarkdownFriendlyTimestamp(Date.now()); + await member_retention_logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + title: 'A member has left the server!', + fields: [ + { + name: 'Member', + value: `@${member.user.tag} (${member.user.id})`, + inline: false, + }, { + name: 'Account creation date', + value: ` ()`, + }, { + name: 'Account join date', + value: ` ()`, + }, { + name: 'Account leave date', + value: ` ()`, + }, { + name: 'Account stayed for', + value: `${Math.floor((member_left_timestamp - member_joined_timestamp) / (60 * 60 * 24))} days`, + }, + ], + }), + ], + }).catch(console.trace); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + guildMemberAddLogger, + guildMemberRemoveLogger, +}; +//# sourceMappingURL=guild_member_retention.js.map \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_retention.js.map b/dist/bot/handlers/logs/guild_member_retention.js.map new file mode 100644 index 00000000..2a0e6966 --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_retention.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_retention.js","sourceRoot":"","sources":["../../../../src/bot/handlers/logs/guild_member_retention.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAE/D,MAAM,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAE1E,mHAAmH;AAEnH,MAAM,mCAAmC,GAAG,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;AAC9F,IAAI,OAAO,mCAAmC,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAC;AAExI,mHAAmH;AAEnH;;GAEG;AACH,KAAK,UAAU,oBAAoB,CAAC,MAAM;IACtC,IAAI,CAAC,CAAC,MAAM,YAAY,OAAO,CAAC,WAAW,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAA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oBAAoB;IACpB,uBAAuB;CAC1B,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_roles.js b/dist/bot/handlers/logs/guild_member_roles.js new file mode 100644 index 00000000..8b8c10c3 --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_roles.js @@ -0,0 +1,82 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +const logging_channel_id = process.env.BOT_LOGGING_CHANNEL_ID; +if (typeof logging_channel_id !== 'string') + throw new TypeError('logging_channel_id is not a string'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.GuildMember} old_member + * @param {Discord.GuildMember} new_member + */ +async function guildMemberRolesAddedLogger(old_member, new_member) { + if (!(old_member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberRolesAddedLogger(): old_member is not a GuildMember'); + if (!(new_member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberRolesAddedLogger(): new_member is not a GuildMember'); + const logging_channel = await client.channels.fetch(logging_channel_id); + if (!logging_channel) + throw new Error('Failed to fetch logging channel'); + const roles_added = new_member.roles.cache.filter(role => !old_member.roles.cache.has(role.id)); + await logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x00FF00, + description: `**Roles were added to ${new_member}.**`, + fields: [ + { + name: 'Member', + value: `@${new_member.user.tag} (${new_member.user.id})`, + inline: false, + }, { + name: 'Roles added', + value: roles_added.map(role => `<@&${role.id}>`).join('\n'), + inline: false, + }, + ], + }), + ], + }).catch(console.trace); +} +/** + * @param {Discord.GuildMember} old_member + * @param {Discord.GuildMember} new_member + */ +async function guildMemberRolesRemovedLogger(old_member, new_member) { + if (!(old_member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberRolesRemovedLogger(): old_member is not a GuildMember'); + if (!(new_member instanceof Discord.GuildMember)) + throw new TypeError('guildMemberRolesRemovedLogger(): new_member is not a GuildMember'); + const logging_channel = await client.channels.fetch(logging_channel_id); + if (!logging_channel) + throw new Error('Failed to fetch logging channel'); + const roles_removed = old_member.roles.cache.filter(role => !new_member.roles.cache.has(role.id)); + await logging_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + description: `**Roles were removed from ${old_member}.**`, + fields: [ + { + name: 'Member', + value: `@${new_member.user.tag} (${new_member.user.id})`, + inline: false, + }, { + name: 'Roles removed', + value: roles_removed.map(role => `<@&${role.id}>`).join('\n'), + inline: false, + }, + ], + }), + ], + }).catch(console.trace); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + guildMemberRolesAddedLogger, + guildMemberRolesRemovedLogger, +}; +//# sourceMappingURL=guild_member_roles.js.map \ No newline at end of file diff --git a/dist/bot/handlers/logs/guild_member_roles.js.map b/dist/bot/handlers/logs/guild_member_roles.js.map new file mode 100644 index 00000000..3c05882a --- /dev/null +++ b/dist/bot/handlers/logs/guild_member_roles.js.map @@ -0,0 +1 @@ +{"version":3,"file":"guild_member_roles.js","sourceRoot":"","sources":["../../../../src/bot/handlers/logs/guild_member_roles.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAE/D,mHAAmH;AAEnH,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;AAC9D,IAAI,OAAO,kBAAkB,KAAK,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;AAEtG,mHAAmH;AAEnH;;;GAGG;AACH,KAAK,UAAU,2BAA2B,CAAC,UAAU,EAAE,UAAU;IAC7D,IAAI,CAAC,CAAC,UAAU,YAAY,OAAO,CAAC,WAAW,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,gEAA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No newline at end of file diff --git a/dist/bot/handlers/one_word_story_channel_handler.js b/dist/bot/handlers/one_word_story_channel_handler.js new file mode 100644 index 00000000..d5a449cf --- /dev/null +++ b/dist/bot/handlers/one_word_story_channel_handler.js @@ -0,0 +1,27 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Timer } = require('../../utilities.js'); +//---------------------------------------------------------------------------------------------------------------// +const oneWordStoryFilter = /^[^\s]*$/i; // match a single word +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Message} message + */ +async function oneWordStoryChannelHandler(message) { + if (message.author.system || message.author.bot) + return; + if (message.content.length === 0) + return; + const message_passes_filter = oneWordStoryFilter.test(message.content); + if (message_passes_filter) + return; // the message is allowed to pass + await Timer(1_000); // prevent api abuse + await message.delete(); // remove the message +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + oneWordStoryChannelHandler, +}; +//# sourceMappingURL=one_word_story_channel_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/one_word_story_channel_handler.js.map b/dist/bot/handlers/one_word_story_channel_handler.js.map new file mode 100644 index 00000000..0b29fe05 --- /dev/null +++ b/dist/bot/handlers/one_word_story_channel_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"one_word_story_channel_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/one_word_story_channel_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEhD,mHAAmH;AAEnH,MAAM,kBAAkB,GAAG,WAAW,CAAC,CAAC,sBAAsB;AAE9D,mHAAmH;AAEnH;;GAEG;AACH,KAAK,UAAU,0BAA0B,CAAC,OAAO;IAC7C,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,OAAO;IACxD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEzC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvE,IAAI,qBAAqB;QAAE,OAAO,CAAC,iCAAiC;IAEpE,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB;IAExC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,qBAAqB;AACjD,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,0BAA0B;CAC7B,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/suggestions_category_handler.js b/dist/bot/handlers/suggestions_category_handler.js new file mode 100644 index 00000000..708f84e8 --- /dev/null +++ b/dist/bot/handlers/suggestions_category_handler.js @@ -0,0 +1,46 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { string_ellipses, Timer } = require('../../utilities.js'); +const { Discord } = require('../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Message} message + */ +async function suggestionsCategoryHandler(message) { + if (message.author.system || message.author.bot) + return; + if (message.content.length === 0) + return; + /* don't allow staff to create suggestions */ + if (message.member.roles.cache.has(process.env.BOT_STAFF_ROLE_ID)) + return; + const suggestions_channel = message.channel; + /* suggestion text */ + const suggestion_text = string_ellipses(message.content, 1000); + /* suggestion embed */ + const bot_suggestion_message = await suggestions_channel.send({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${message.author.displayAvatarURL({ dynamic: true })}`, + name: `@${message.member.user.tag} (${message.member.id})`, + }, + description: `${suggestion_text}`, + }), + ], + }).catch(console.warn); + /* add the reactions to the suggestion embed */ + await bot_suggestion_message.react('<:approved:813023668211810334>'); + await bot_suggestion_message.react('<:declined:813023668187824158>'); + await Timer(500); + /* remove the original message */ + await message.delete(); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + suggestionsCategoryHandler, +}; +//# sourceMappingURL=suggestions_category_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/suggestions_category_handler.js.map b/dist/bot/handlers/suggestions_category_handler.js.map new file mode 100644 index 00000000..6f9cd041 --- /dev/null +++ b/dist/bot/handlers/suggestions_category_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"suggestions_category_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/suggestions_category_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEjE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAEpD,mHAAmH;AAEnH;;GAEG;AACH,KAAK,UAAU,0BAA0B,CAAC,OAAO;IAC7C,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG;QAAE,OAAO;IACxD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEzC,6CAA6C;IAC7C,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;QAAE,OAAO;IAE1E,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAE5C,qBAAqB;IACrB,MAAM,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE/D,sBAAsB;IACtB,MAAM,sBAAsB,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC;QAC1D,MAAM,EAAE;YACJ,IAAI,OAAO,CAAC,YAAY,CAAC;gBACrB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE;oBACJ,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;oBAChE,IAAI,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG;iBAC7D;gBACD,WAAW,EAAE,GAAG,eAAe,EAAE;aACpC,CAAC;SACL;KACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,+CAA+C;IAC/C,MAAM,sBAAsB,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACrE,MAAM,sBAAsB,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAErE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,iCAAiC;IACjC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,0BAA0B;CAC7B,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/user_notes_handler.js b/dist/bot/handlers/user_notes_handler.js new file mode 100644 index 00000000..ef32930a --- /dev/null +++ b/dist/bot/handlers/user_notes_handler.js @@ -0,0 +1,178 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { v4: uuid_v4 } = require('uuid'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @typedef {{ + * 'identity': { + * 'discord_user_id': String, + * }, + * 'record': { + * 'id': String, + * 'epoch': Number, + * 'note': String, + * 'staff_member_id': String, + * }, + * }} UserNote + */ +//---------------------------------------------------------------------------------------------------------------// +/** + * Create note for user + * @param {Object} identity + * @param {String} identity.discord_user_id + * @param {Object} record + * @param {Number} record.epoch + * @param {String} record.note + * @param {String} record.staff_member_id + * @returns {Promise} success or failure + */ +async function createNoteForUser({ discord_user_id }, { epoch, note, staff_member_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string!'); + if (typeof epoch !== 'number') + throw new TypeError('\`epoch\` must be a number!'); + if (typeof note !== 'string') + throw new TypeError('\`note\` must be a string!'); + if (typeof staff_member_id !== 'string') + throw new TypeError('\`staff_member_id\` must be a string!'); + const record_id = uuid_v4(); + try { + await go_mongo_db.add(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, [ + { + 'identity': { + 'discord_user_id': discord_user_id, + }, + 'record': { + 'id': record_id, + 'epoch': epoch, + 'note': note, + 'staff_member_id': staff_member_id, + }, + }, + ]); + } + catch (error) { + console.trace('createNoteForUser():', error); + return false; + } + return true; +} +//---------------------------------------------------------------------------------------------------------------// +/** + * Updates a note + * @param {Object} record + * @param {String} record.id + * @param {Number} record.epoch + * @param {String} record.note + * @param {String} record.staff_member_id + * @returns {Promise} success or failure + */ +async function updateNoteForUser({ id, epoch, note, staff_member_id }) { + if (typeof id !== 'string') + throw new TypeError('\`id\` must be a string!'); + if (typeof epoch !== 'number') + throw new TypeError('\`epoch\` must be a number!'); + if (typeof note !== 'string') + throw new TypeError('\`note\` must be a string!'); + if (typeof staff_member_id !== 'string') + throw new TypeError('\`staff_member_id\` must be a string!'); + try { + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, { + 'record.id': id, + }, { + $set: { + 'record': { + 'epoch': epoch, + 'note': note, + 'staff_member_id': staff_member_id, + }, + }, + }); + } + catch (error) { + console.trace('updateNoteForUser():', error); + return false; + } + return true; +} +//---------------------------------------------------------------------------------------------------------------// +/** + * Removes a note + * @param {Object} record + * @param {String} record.id + * @returns {Promise} success or failure + */ +async function removeNoteFromUser({ id }) { + if (typeof id !== 'string') + throw new TypeError('\`id\` must be a string!'); + try { + await go_mongo_db.remove(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, { + 'record.id': id, + }); + } + catch (error) { + console.trace('removeNoteFromUser():', error); + return false; + } + return true; +} +/** + * Removes all notes from a user + * @param {Object} identity + * @param {String} identity.discord_user_id + * @returns {Promise} success or failure + */ +async function purgeNotesFromUser({ discord_user_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string!'); + try { + await go_mongo_db.remove(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, { + 'identity.discord_user_id': discord_user_id, + }); + } + catch (error) { + console.trace('purgeNotesFromUser():', error); + return false; + } + return true; +} +/** + * Finds all notes for a user + * @param {Object} identity + * @param {String} identity.discord_user_id + * @returns {Promise} + */ +async function lookupNotesForUser({ discord_user_id }) { + if (typeof discord_user_id !== 'string') + throw new TypeError('\`discord_user_id\` must be a string!'); + const user_notes = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, { + 'identity.discord_user_id': discord_user_id, + }); + return user_notes; +} +/** + * Finds a singular note for a user + * @param {Object} record + * @param {String?} record.id + * @returns {Promise} + */ +async function lookupNoteForUser({ id }) { + if (typeof id !== 'string') + throw new TypeError('\`id\` must be a string!'); + const [user_note] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USER_NOTES_COLLECTION_NAME, { + 'record.id': id, + }); + return user_note; +} +module.exports = { + createNoteForUser, + updateNoteForUser, + removeNoteFromUser, + purgeNotesFromUser, + lookupNotesForUser, + lookupNoteForUser, +}; +//# sourceMappingURL=user_notes_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/user_notes_handler.js.map b/dist/bot/handlers/user_notes_handler.js.map new file mode 100644 index 00000000..866996e2 --- /dev/null +++ b/dist/bot/handlers/user_notes_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"user_notes_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E,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAE5E,MAAM,CAAE,SAAS,CAAE,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE;QACxH,WAAW,EAAE,EAAE;KAClB,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACb,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;CACpB,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/user_profile_handler.js b/dist/bot/handlers/user_profile_handler.js new file mode 100644 index 00000000..f08842d9 --- /dev/null +++ b/dist/bot/handlers/user_profile_handler.js @@ -0,0 +1,131 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const axios = require('axios'); +const { go_mongo_db } = require('../../mongo/mongo.js'); +const { Discord, client } = require('../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +function replyToMessageOrEditReplyToInteraction(deferred_interaction_or_message, message_payload) { + if (deferred_interaction_or_message instanceof Discord.BaseCommandInteraction || + deferred_interaction_or_message instanceof Discord.MessageComponentInteraction) { + deferred_interaction_or_message.editReply(message_payload).catch(console.warn); + } + else if (deferred_interaction_or_message instanceof Discord.Message) { + deferred_interaction_or_message.reply(message_payload).catch(console.warn); + } + else { + throw new Error('replyToMessageOrEditReplyToInteraction: deferred_interaction_or_message must be a Discord.Message or Discord.Interaction'); + } +} +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.Interaction|Discord.Message} deferred_interaction_or_message + * @param {string} discord_user_id + */ +async function userProfileHandler(deferred_interaction_or_message, discord_user_id) { + const [db_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': discord_user_id, + }, { + projection: { + '_id': false, + }, + }); + if (!db_user_data) { + replyToMessageOrEditReplyToInteraction(deferred_interaction_or_message, { + embeds: [ + new Discord.MessageEmbed({ + color: 0xFFFF00, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Profile System', + }, + title: 'Unknown User', + description: [ + 'That user doesn\'t exist in our database!', + ].join('\n'), + }), + ], + }); + return; + } + const [db_blacklisted_user_data] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + $or: [ + { 'identity.discord_user_id': db_user_data.identity.discord_user_id }, + { 'identity.roblox_user_id': db_user_data.identity.roblox_user_id }, + ], + }, { + projection: { + '_id': false, + }, + }); + const db_roblox_products = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, { + 'public': true, + }); + const user_product_codes = Object.entries(db_user_data.products) + .filter(([product_code, user_owns_product]) => user_owns_product) + .map(([product_code]) => product_code); + const user_products = db_roblox_products.filter(product => user_product_codes.includes(product.code)); + const { data: roblox_user_data, } = await axios({ + method: 'get', + url: `https://users.roblox.com/v1/users/${encodeURIComponent(db_user_data.identity.roblox_user_id)}`, + timeout: 30_000, + validateStatus: (status) => status === 200, + }).catch(error => { + console.trace(error); + return { + data: { + name: 'Unknown User', + displayName: 'Unknown User', + }, + }; + }); + replyToMessageOrEditReplyToInteraction(deferred_interaction_or_message, { + embeds: [ + ...(db_blacklisted_user_data ? [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Blacklist System', + }, + description: [ + '\`\`\`', + 'User is blacklisted from using Inertia Lighting products!', + '\`\`\`', + '\`\`\`json', + `${JSON.stringify(db_blacklisted_user_data, null, 2)}`, + '\`\`\`', + ].join('\n'), + }), + ] : []), + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Profile System', + }, + fields: [ + { + name: 'Discord', + value: `<@${db_user_data.identity.discord_user_id}>`, + }, { + name: 'Roblox', + value: `[${`@${roblox_user_data.name}` ?? 'n/a'}](https://roblox.com/users/${db_user_data.identity.roblox_user_id}/profile) (${roblox_user_data.displayName ?? 'n/a'})`, + }, { + name: 'Karma', + value: `${db_user_data.karma ?? 0}`, + }, { + name: 'Products', + value: `${user_products.length === 0 ? 'n/a' : user_products.map(product => `- ${product.name}`).join('\n')}`, + }, + ], + }), + ], + }); +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + userProfileHandler, +}; +//# sourceMappingURL=user_profile_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/user_profile_handler.js.map b/dist/bot/handlers/user_profile_handler.js.map new file mode 100644 index 00000000..d7723990 --- /dev/null +++ b/dist/bot/handlers/user_profile_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"user_profile_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/user_profile_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAExD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,mHAAmH;AAEnH,SAAS,sCAAsC,CAAC,+BAA+B,EAAE,eAAe;IAC5F,IACI,+BAA+B,YAAY,OAAO,CAAC,sBAAsB;QACzE,+BAA+B,YAAY,OAAO,CAAC,2BAA2B,EAChF;QACE,+BAA+B,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,OAAO,CA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AAE,GAAG,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;qBAChH;iBACJ;aACJ,CAAC;SACL;KACJ,CAAC,CAAC;AACP,CAAC;AAED,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,kBAAkB;CACrB,CAAC"} \ No newline at end of file diff --git a/dist/bot/handlers/welcome_message_handler.js b/dist/bot/handlers/welcome_message_handler.js new file mode 100644 index 00000000..74a7d1c7 --- /dev/null +++ b/dist/bot/handlers/welcome_message_handler.js @@ -0,0 +1,71 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +//---------------------------------------------------------------------------------------------------------------// +const { Discord, client } = require('../discord_client.js'); +//---------------------------------------------------------------------------------------------------------------// +/** + * @param {Discord.GuildMember} member + */ +async function welcomeMessageHandler(member) { + const welcome_message_options = { + content: `${member}`, + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'Welcome to Inertia Lighting!', + description: [ + 'Please click the button so that we know you are a human!', + ].join('\n'), + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 3, + custom_id: 'welcome_message_captcha_button', + label: 'I am a human!', + }, + ], + }, + ], + }; + let dm_welcome_message_sent_successfully = true; // assume success until proven otherwise + try { + const dm_channel = await member.createDM(); + await dm_channel.send(welcome_message_options); + } + catch { + dm_welcome_message_sent_successfully = false; + } + /** @type {Discord.TextBasedChannel} */ + const welcome_message_channel = await client.channels.fetch('936738838309654610').catch(console.trace); + if (!welcome_message_channel) + return; + const guild_welcome_message = await welcome_message_channel.send(dm_welcome_message_sent_successfully ? { + content: `${member}`, + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'Welcome to Inertia Lighting!', + description: [ + 'Please check your DMs for a CAPTCHA message sent by our bot!', + 'You need to complete the CAPTCHA to gain access to the server!', + ].join('\n'), + }), + ], + } : welcome_message_options).catch(console.trace); + if (!guild_welcome_message) + return; + setTimeout(() => { + welcome_message_channel.messages.delete(guild_welcome_message.id).catch(console.warn); + }, 15 * 60_000); // wait 15 minutes before deleting the welcome message +} +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + welcomeMessageHandler, +}; +//# sourceMappingURL=welcome_message_handler.js.map \ No newline at end of file diff --git a/dist/bot/handlers/welcome_message_handler.js.map b/dist/bot/handlers/welcome_message_handler.js.map new file mode 100644 index 00000000..b9ecdda3 --- /dev/null +++ b/dist/bot/handlers/welcome_message_handler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"welcome_message_handler.js","sourceRoot":"","sources":["../../../src/bot/handlers/welcome_message_handler.js"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;AAEb,mHAAmH;AAEnH,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE5D,mHAAmH;AAEnH;;GAEG;AACH,KAAK,UAAU,qBAAqB,CAAC,MAAM;IACvC,MAAM,uBAAuB,GAAG;QAC5B,OAAO,EAAE,GAAG,MAAM,EAAE;QACpB,MAAM,EAAE;YACJ,IAAI,OAAO,CAAC,YAAY,CAAC;gBACrB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,8BAA8B;gBACrC,WAAW,EAAE;oBACT,0DAA0D;iBAC7D,CAAC,IAAI,CAAC,IAAI,CAAC;aACf,CAAC;SACL;QACD,UAAU,EAAE;YACR;gBACI,IAAI,EAAE,CAAC;gBACP,UAAU,EAAE;oBACR;wBACI,IAAI,EAAE,CAAC;wBACP,KAAK,EAAE,CAAC;wBACR,SAAS,EAAE,gCAAgC;wBAC3C,KAAK,EAAE,eAAe;qBACzB;iBACJ;aACJ;SACJ;KACJ,CAAC;IA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dist/bot/interactions/buttons/display_support_ticket_database_documents.js new file mode 100644 index 00000000..16b14c43 --- /dev/null +++ b/dist/bot/interactions/buttons/display_support_ticket_database_documents.js @@ -0,0 +1,90 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const Discord = __importStar(require("discord.js")); +//---------------------------------------------------------------------------------------------------------------// +const mongo_js_1 = require("../../../mongo/mongo.js"); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + identifier: 'display_support_ticket_database_documents', + async execute(interaction) { + if (!interaction.inCachedGuild()) + return; + await interaction.deferReply({ ephemeral: true }); + const channel = interaction.channel; + const support_ticket_owner_id = channel.name.match(/(?!.*\-)?([0-9])+/i)?.[0]; + /* check if the user is blacklisted */ + const [db_blacklisted_user_data] = await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': support_ticket_owner_id, + }, { + projection: { + '_id': false, + }, + }); + if (db_blacklisted_user_data) { + await interaction.editReply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${interaction.client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Blacklist System', + }, + description: [ + '\`\`\`', + 'User is blacklisted from using Inertia Lighting products!', + '\`\`\`', + '\`\`\`json', + `${JSON.stringify(db_blacklisted_user_data, null, 2)}`, + '\`\`\`', + ].join('\n'), + }), + ], + }).catch(console.warn); + return; // don't continue if the user is blacklisted + } + /* send the user document */ + const [db_user_data] = await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': support_ticket_owner_id, + }, { + projection: { + '_id': false, + }, + }); + await interaction.editReply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${interaction.client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | User Document', + }, + title: 'This embed is for our support staff.', + description: `${'```'}json\n${JSON.stringify(db_user_data ?? 'user not found in database', null, 2)}\n${'```'}`, + }), + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=display_support_ticket_database_documents.js.map \ No newline at end of file diff --git a/dist/bot/interactions/buttons/display_support_ticket_database_documents.js.map b/dist/bot/interactions/buttons/display_support_ticket_database_documents.js.map new file mode 100644 index 00000000..8a5cfbb9 --- /dev/null +++ b/dist/bot/interactions/buttons/display_support_ticket_database_documents.js.map @@ -0,0 +1 @@ +{"version":3,"file":"display_support_ticket_database_documents.js","sourceRoot":"","sources":["../../../../src/bot/interactions/buttons/display_support_ticket_database_documents.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;AAEb,mHAAmH;AAEnH,oDAAsC;AAEtC,mHAAmH;AAEnH,sDAAsD;AAEtD,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,2CAA2C;IACvD,KAAK,CAAC,OAAO,CACT,WAAsC;QAEtC,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;YAAE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AO,CAAC,GAAG,CAAC,mBAA6B,EAAE,OAAO,CAAC,GAAG,CAAC,2BAAqC,EAAE;YAC1I,0BAA0B,EAAE,uBAAuB;SACtD,EAAE;YACC,UAAU,EAAE;gBACR,KAAK,EAAE,KAAK;aACf;SACJ,CAAC,CAAC;QACH,MAAM,WAAW,CAAC,SAAS,CAAC;YACxB,MAAM,EAAE;gBACJ,IAAI,OAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,MAAM,EAAE;wBACJ,OAAO,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,IAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;wBAC1E,IAAI,EAAE,kCAAkC;qBAC3C;oBACD,KAAK,EAAE,sCAAsC;oBAC7C,WAAW,EAAE,GAAG,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,4BAA4B,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;iBAClH,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/src/bot/interactions/buttons/welcome_message_captcha_button.js b/dist/bot/interactions/buttons/welcome_message_captcha_button.js similarity index 86% rename from src/bot/interactions/buttons/welcome_message_captcha_button.js rename to dist/bot/interactions/buttons/welcome_message_captcha_button.js index 00e1c82e..b3b18f31 100644 --- a/src/bot/interactions/buttons/welcome_message_captcha_button.js +++ b/dist/bot/interactions/buttons/welcome_message_captcha_button.js @@ -1,45 +1,31 @@ /* Copyright © Inertia Lighting | All Rights Reserved */ - //---------------------------------------------------------------------------------------------------------------// - 'use strict'; - +Object.defineProperty(exports, "__esModule", { value: true }); //---------------------------------------------------------------------------------------------------------------// - -const { Timer } = require('../../../utilities'); - -const { Discord, client } = require('../../discord_client.js'); - +const utilities_1 = require("../../../utilities"); +const discord_client_js_1 = require("../../discord_client.js"); //---------------------------------------------------------------------------------------------------------------// - const bot_guild_id = process.env.BOT_GUILD_ID; const new_server_member_role_ids = process.env.BOT_SERVER_MEMBER_AUTO_ROLE_IDS.split(','); const new_to_the_server_role_ids = process.env.BOT_NEW_TO_THE_SERVER_AUTO_ROLE_IDS.split(','); - //---------------------------------------------------------------------------------------------------------------// - module.exports = { identifier: 'welcome_message_captcha_button', - /** @param {Discord.ButtonInteraction} interaction */ async execute(interaction) { - interaction.deferUpdate({ ephemeral: false }); - - const guild = client.guilds.cache.get(bot_guild_id); + interaction.deferUpdate(); + const guild = discord_client_js_1.client.guilds.cache.get(bot_guild_id); const member = await guild.members.fetch(interaction.user.id).catch(() => null); - - if (!(member instanceof Discord.GuildMember)) { + if (!(member instanceof discord_client_js_1.Discord.GuildMember)) { console.warn(`Unable to fetch member from user: ${interaction.user.id}; skipping...`); return; } - const welcome_message = await interaction.channel.messages.fetch(interaction.message.id); const user_from_welcome_message = welcome_message.mentions.users.first(); - - if (!(user_from_welcome_message instanceof Discord.User)) { + if (!(user_from_welcome_message instanceof discord_client_js_1.Discord.User)) { console.warn(`Unable to fetch member from welcome message: ${interaction.message.id}; skipping...`); return; } - if (user_from_welcome_message.id !== member.id) { await interaction.followUp({ ephemeral: true, @@ -47,28 +33,26 @@ module.exports = { }).catch(console.warn); return; } - /* give new-server-member roles to the user */ try { await member.roles.add(new_server_member_role_ids); - } catch (error) { + } + catch (error) { console.trace('Failed to give new-server-member roles to the member:', error); } - /* wait 1 second to avoid any potential race conditions */ - await Timer(1_000); - + await (0, utilities_1.Timer)(1_000); /* remove the new-to-the-server roles from the user */ try { await member.roles.remove(new_to_the_server_role_ids); - } catch (error) { + } + catch (error) { console.trace('Failed to remove new-to-the-server roles from the member:', error); } - /* welcome the user to the server */ await interaction.editReply({ embeds: [ - new Discord.MessageEmbed({ + new discord_client_js_1.Discord.MessageEmbed({ color: 0x60A0FF, title: 'Welcome to Inertia Lighting!', description: [ @@ -118,3 +102,4 @@ module.exports = { }); }, }; +//# sourceMappingURL=welcome_message_captcha_button.js.map \ No newline at end of file diff --git a/dist/bot/interactions/buttons/welcome_message_captcha_button.js.map b/dist/bot/interactions/buttons/welcome_message_captcha_button.js.map new file mode 100644 index 00000000..c1786770 --- /dev/null +++ b/dist/bot/interactions/buttons/welcome_message_captcha_button.js.map @@ -0,0 +1 @@ +{"version":3,"file":"welcome_message_captcha_button.js","sourceRoot":"","sources":["../../../../src/bot/interactions/buttons/welcome_message_captcha_button.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;AAEb,mHAAmH;AAEnH,kDAA2C;AAE3C,+DAA0D;AAE1D,mHAAmH;AAEnH,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAsB,CAAC;AACxD,MAAM,0BAA0B,GAAI,OAAO,CAAC,GAAG,CAAC,+BAA0C,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACtG,MAAM,0BAA0B,GAAI,OAAO,CAAC,GAAG,CAAC,mCAA8C,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE1G,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,gCAAgC;IAC5C,KAAK,CAAC,OAAO,CAAC,WAAsC;QAChD,WAAW,CAAC,WAAW,EAAE,CAAC;QAE1B,MAAM,KAAK,GAAG,0BAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAE,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAEhF,IAAI,CAAC,CAAC,MAAM,YAAY,2BAAO,CAAC,WAAW,CAAC,EAAE;YAC1C,OAAO,CAAC,IAAI,CAAC,qCAAqC,WAAW,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,C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AA8B;oBACrC,WAAW,EAAE;wBACT,oEAAoE;wBACpE,EAAE;wBACF,iEAAiE;wBACjE,qEAAqE;wBACrE,EAAE;wBACF,4DAA4D;wBAC5D,iEAAiE;qBACpE,CAAC,IAAI,CAAC,IAAI,CAAC;iBACf,CAAC;aACL;YACD,UAAU,EAAE;gBACR;oBACI,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE;wBACR;4BACI,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,cAAc;4BACrB,GAAG,EAAE,mCAAmC;yBAC3C,EAAE;4BACC,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,aAAa;4BACpB,GAAG,EAAE,uCAAuC;yBAC/C,EAAE;4BACC,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,QAAQ;4BACf,GAAG,EAAE,8BAA8B;yBACtC,EAAE;4BACC,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,gBAAgB;4BACvB,GAAG,EAAE,kCAAkC;yBAC1C,EAAE;4BACC,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,kBAAkB;4BACzB,GAAG,EAAE,oEAAoE;yBAC5E;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/interactions/context_menus/user_profile.js b/dist/bot/interactions/context_menus/user_profile.js new file mode 100644 index 00000000..49dbc9d8 --- /dev/null +++ b/dist/bot/interactions/context_menus/user_profile.js @@ -0,0 +1,30 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const discord_client_js_1 = require("../../discord_client.js"); +const user_profile_handler_js_1 = require("../../handlers/user_profile_handler.js"); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + identifier: 'User Profile', + async execute(interaction) { + if (!interaction.inCachedGuild()) + return; + await interaction.deferReply({ ephemeral: true }); + const user = interaction.options.resolved.users.first(); + if (!user) { + return interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + title: 'An unexpected error occurred!', + description: 'The user you are trying to view does not exist!', + }), + ], + }); + } + (0, user_profile_handler_js_1.userProfileHandler)(interaction, user.id); + }, +}; +//# sourceMappingURL=user_profile.js.map \ No newline at end of file diff --git a/dist/bot/interactions/context_menus/user_profile.js.map b/dist/bot/interactions/context_menus/user_profile.js.map new file mode 100644 index 00000000..da496b88 --- /dev/null +++ b/dist/bot/interactions/context_menus/user_profile.js.map @@ -0,0 +1 @@ +{"version":3,"file":"user_profile.js","sourceRoot":"","sources":["../../../../src/bot/interactions/context_menus/user_profile.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;AAEb,mHAAmH;AAEnH,+DAAkD;AAElD,oFAA4E;AAE5E,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,cAAc;IAC1B,KAAK,CAAC,OAAO,CACT,WAA2C;QAE3C,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;YAAE,OAAO;QAEzC,MAAM,WAAW,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAElD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAM,CAAC,KAAK,EAAE,CAAC;QAEzD,IAAI,CAAC,IAAI,EAAE;YACP,OAAO,WAAW,CAAC,SAAS,CAAC;gBACzB,MAAM,EAAE;oBACJ,IAAI,2BAAO,CAAC,YAAY,CAAC;wBACrB,KAAK,EAAE,QAAQ;wBACf,KAAK,EAAE,+BAA+B;wBACtC,WAAW,EAAE,iDAAiD;qBACjE,CAAC;iBACL;aACJ,CAAC,CAAC;SACN;QAED,IAAA,4CAAkB,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/manage_karma.js b/dist/bot/interactions/message_commands/manage_karma.js new file mode 100644 index 00000000..e7133462 --- /dev/null +++ b/dist/bot/interactions/message_commands/manage_karma.js @@ -0,0 +1,162 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const discord_client_js_1 = require("../../discord_client.js"); +const mongo_js_1 = require("../../../mongo/mongo.js"); +const bot_js_1 = require("../../common/bot.js"); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + identifier: 'manage_karma', + async execute(interaction) { + if (!interaction.isCommand()) + return; + await interaction.deferReply(); + const interaction_guild_member = await interaction.guild.members.fetch(interaction.user.id); + const user_permission_level = (0, bot_js_1.getUserPermissionLevel)(interaction_guild_member); + const user_has_access_to_command = user_permission_level >= bot_js_1.command_permission_levels.ADMINS; + if (!user_has_access_to_command) { + interaction.editReply(bot_js_1.user_is_not_allowed_access_to_command_message_options).catch(console.warn); + return; + } + const user_to_modify = interaction.options.getUser('for', true); + const action_to_perform = interaction.options.getString('action', true); + const amount_to_modify_by = interaction.options.getInteger('amount', true); + const reason = interaction.options.getString('reason', true) || 'No reason was specified.'; + /* find the user in the database */ + const [db_user_data] = await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': user_to_modify.id, + }, { + projection: { + '_id': false, + }, + }); + /* check if the user exists */ + if (!db_user_data) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFFFF00, + description: `${user_to_modify} does not exist in the database!`, + }), + ], + }).catch(console.warn); + return; + } + /** @type {number} */ + const initial_karma_amount = db_user_data.karma ?? 0; + let updated_karma_amount; + switch (action_to_perform) { + case 'add': { + updated_karma_amount = initial_karma_amount + amount_to_modify_by; + break; + } + case 'remove': { + updated_karma_amount = initial_karma_amount - amount_to_modify_by; + break; + } + case 'set': { + updated_karma_amount = amount_to_modify_by; + break; + } + default: { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFFFF00, + description: `Invalid action: \`${action_to_perform}\``, + }), + ], + }).catch(console.warn); + return; + } + } + /* prevent decimals */ + updated_karma_amount = Math.floor(updated_karma_amount); + const karma_too_small = updated_karma_amount <= Number.MIN_SAFE_INTEGER; + if (karma_too_small) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + description: 'New karma amount is too small!', + }), + ], + }).catch(console.warn); + return; + } + const karma_too_large = updated_karma_amount >= Number.MAX_SAFE_INTEGER; + if (karma_too_large) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + description: 'New karma amount is too large!', + }), + ], + }).catch(console.warn); + return; + } + const karma_is_not_a_number = Number.isNaN(updated_karma_amount); + if (karma_is_not_a_number) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + description: 'New karma amount is not a valid number!', + }), + ], + }).catch(console.warn); + return; + } + try { + await mongo_js_1.go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': db_user_data.identity.discord_user_id, + 'identity.roblox_user_id': db_user_data.identity.roblox_user_id, + }, { + $set: { + 'karma': updated_karma_amount, + }, + }); + } + catch (error) { + console.trace(error); + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + author: { + iconURL: `${discord_client_js_1.client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Karma System', + }, + description: 'An error occurred while modifying the user\'s karma!', + }), + ], + }).catch(console.warn); + return; + } + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: action_to_perform === 'add' ? (0x00FF00) : action_to_perform === 'remove' ? (0xFF0000) : (0x60A0FF), + author: { + iconURL: `${discord_client_js_1.client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Karma System', + }, + description: [ + action_to_perform === 'add' ? (`Added \`${amount_to_modify_by}\` karma to ${user_to_modify}.`) : action_to_perform === 'remove' ? (`Removed \`${amount_to_modify_by}\` karma from ${user_to_modify}.`) : (`Set ${user_to_modify}'s karma to a new amount.`), + `New karma amount: \`${updated_karma_amount}\``, + ].join('\n'), + fields: [ + { + name: 'Reason', + value: `${reason}`, + }, + ], + }), + ], + }).catch(console.warn); + }, +}; +//# sourceMappingURL=manage_karma.js.map \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/manage_karma.js.map b/dist/bot/interactions/message_commands/manage_karma.js.map new file mode 100644 index 00000000..65002a41 --- /dev/null +++ b/dist/bot/interactions/message_commands/manage_karma.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manage_karma.js","sourceRoot":"","sources":["../../../../src/bot/interactions/message_commands/manage_karma.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;AAEb,mHAAmH;AAEnH,+DAA0D;AAE1D,sDAAsD;AAEtD,gDAA+I;AAE/I,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,cAAc;IAC1B,KAAK,CAAC,OAAO,CACT,WAAmF;QAEnF,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE;YAAE,OAAO;QAErC,MAAM,WAAW,CAAC,UAAU,EAAE,CAAC;QAE/B,MAAM,wBAAwB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE5F,MAAM,qBAAqB,GAAG,IAAA,+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OAAO,CAAC,IAAI,CAAC,CAAC;YAEvB,OAAO;SACV;QAED,WAAW,CAAC,SAAS,CAAC;YAClB,MAAM,EAAE;gBACJ,IAAI,2BAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,CACjC,QAAQ,CACX,CAAC,CAAC,CAAC,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,CACjC,QAAQ,CACX,CAAC,CAAC,CAAC,CACA,QAAQ,CACX;oBACD,MAAM,EAAE;wBACJ,OAAO,EAAE,GAAG,0BAAM,CAAC,IAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;wBAC9D,IAAI,EAAE,iCAAiC;qBAC1C;oBACD,WAAW,EAAE;wBACT,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,CAC1B,WAAW,mBAAmB,eAAe,cAAc,GAAG,CACjE,CAAC,CAAC,CAAC,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,CACjC,aAAa,mBAAmB,iBAAiB,cAAc,GAAG,CACrE,CAAC,CAAC,CAAC,CACA,OAAO,cAAc,2BAA2B,CACnD;wBACD,uBAAuB,oBAAoB,IAAI;qBAClD,CAAC,IAAI,CAAC,IAAI,CAAC;oBACZ,MAAM,EAAE;wBACJ;4BACI,IAAI,EAAE,QAAQ;4BACd,KAAK,EAAE,GAAG,MAAM,EAAE;yBACrB;qBACJ;iBACJ,CAAC;aACL;SACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/manage_products.js b/dist/bot/interactions/message_commands/manage_products.js new file mode 100644 index 00000000..4497291c --- /dev/null +++ b/dist/bot/interactions/message_commands/manage_products.js @@ -0,0 +1,172 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +Object.defineProperty(exports, "__esModule", { value: true }); +const string_similarity_1 = require("string-similarity"); +const mongo_js_1 = require("../../../mongo/mongo.js"); +const discord_client_js_1 = require("../../discord_client.js"); +//---------------------------------------------------------------------------------------------------------------// +const database_support_staff_role_id = process.env.BOT_SUPPORT_STAFF_DATABASE_ROLE_ID; +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + identifier: 'manage_products', + async execute(interaction) { + const db_roblox_products = (await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, {})); + if (interaction.isAutocomplete()) { + const user_id_to_modify = interaction.options.get('for')?.value; + const action_to_perform = interaction.options.getString('action'); + /** @type {string} */ + const focused_option = interaction.options.getFocused(); + const search_query = focused_option.toUpperCase(); + /* find the user in the database */ + const [db_user_data] = (await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': user_id_to_modify, + }, { + projection: { + '_id': false, + }, + })); + if (!db_user_data) { + return interaction.respond([]); + } + const filtered_db_roblox_products = db_roblox_products.filter(db_roblox_product => { + const user_owns_product = Boolean(db_user_data.products[db_roblox_product.code]); + return ((action_to_perform === 'add' && !user_owns_product) || + (action_to_perform === 'remove' && user_owns_product)); + }); + const mapped_db_roblox_products = []; + for (const db_roblox_product of filtered_db_roblox_products) { + mapped_db_roblox_products.push({ + ...db_roblox_product, + similarity_score: (0, string_similarity_1.compareTwoStrings)(search_query, db_roblox_product.code), + }); + } + const matching_db_roblox_products = mapped_db_roblox_products.sort((a, b) => b.similarity_score - a.similarity_score).sort((a, b) => { + const first_char_of_query = search_query.at(0); + if (a.code.startsWith(first_char_of_query) === b.code.startsWith(first_char_of_query)) + return a.code.localeCompare(b.code); + if (a.code.startsWith(first_char_of_query)) + return -1; + if (b.code.startsWith(first_char_of_query)) + return 1; + return 0; + }).filter(({ similarity_score, code }, index) => search_query.length > 0 ? (similarity_score >= 0.25 || (similarity_score < 0.25 && index < 10)) : true); + if (matching_db_roblox_products.length === 0) { + return interaction.respond([]); + } + interaction.respond(matching_db_roblox_products.slice(0, 5).map(db_roblox_product => ({ + name: db_roblox_product.code, + value: db_roblox_product.code, + }))); + } + else if (interaction.isCommand()) { + await interaction.deferReply(); + const interaction_guild_member = await interaction.guild.members.fetch(interaction.user.id); + /* check if the user is allowed to use this command */ + if (!interaction_guild_member.roles.cache.has(database_support_staff_role_id)) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF00FF, + title: 'Inertia Lighting | Products Manager', + description: 'You aren\'t allowed to use this command!', + }), + ], + }).catch(console.warn); + return; + } + const user_to_modify = interaction.options.getUser('for', true); + const action_to_perform = interaction.options.getString('action', true); + const potential_product_code = interaction.options.getString('product_code', true); + const reason = interaction.options.getString('reason', true) || 'No reason was specified.'; + /* find the user in the database */ + const [db_user_data] = await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': user_to_modify.id, + }, { + projection: { + '_id': false, + }, + }); + /* check if the user exists */ + if (!db_user_data) { + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFFFF00, + title: 'Inertia Lighting | Products Manager', + description: `${user_to_modify} does not exist in the database!`, + }), + ], + }).catch(console.warn); + return; + } + const db_roblox_product = db_roblox_products.find(db_roblox_product => db_roblox_product.code === potential_product_code); + if (!db_roblox_product) { + interaction.followUp({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFFFF00, + title: 'Inertia Lighting | Products Manager', + description: `\`${potential_product_code}\` is not a valid product code!`, + }), + ], + }).catch(console.warn); + return; + } + try { + await mongo_js_1.go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + 'identity.discord_user_id': db_user_data.identity.discord_user_id, + 'identity.roblox_user_id': db_user_data.identity.roblox_user_id, + }, { + $set: { + [`products.${db_roblox_product.code}`]: (action_to_perform === 'add' ? true : false), + }, + }); + } + catch (error) { + console.trace(error); + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0xFF0000, + title: 'Inertia Lighting | Products Manager', + description: 'An error occurred while modifying the user\'s products!', + }), + ], + }).catch(console.warn); + return; + } + const logging_channel = (await interaction.guild.channels.fetch(process.env.BOT_LOGGING_PRODUCTS_MANAGER_CHANNEL_ID)); + logging_channel.send({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: action_to_perform === 'add' ? 0x00FF00 : 0xFF0000, + title: 'Inertia Lighting | Products Manager', + description: `${interaction.user} ${action_to_perform === 'add' ? 'added' : 'removed'} \`${db_roblox_product.code}\` ${action_to_perform === 'add' ? 'to' : 'from'} ${user_to_modify}.`, + fields: [ + { + name: 'Reason', + value: `${reason}`, + }, + ], + }), + ], + }).catch(console.warn); + interaction.editReply({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: action_to_perform === 'add' ? 0x00FF00 : 0xFF0000, + title: 'Inertia Lighting | Products Manager', + description: `${action_to_perform === 'add' ? 'Added' : 'Removed'} \`${db_roblox_product.code}\` ${action_to_perform === 'add' ? 'to' : 'from'} ${user_to_modify}.`, + fields: [ + { + name: 'Reason', + value: `${reason}`, + }, + ], + }), + ], + }).catch(console.warn); + } + }, +}; +//# sourceMappingURL=manage_products.js.map \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/manage_products.js.map b/dist/bot/interactions/message_commands/manage_products.js.map new file mode 100644 index 00000000..4b7d9ce8 --- /dev/null +++ b/dist/bot/interactions/message_commands/manage_products.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manage_products.js","sourceRoot":"","sources":["../../../../src/bot/interactions/message_commands/manage_products.ts"],"names":[],"mappings":";AAAA,wDAAwD;;AAMxD,yDAAsD;AAEtD,sDAAsD;AAEtD,+DAAkD;AAElD,mHAAmH;AAEnH,MAAM,8BAA8B,GAAG,OAAO,CAAC,G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,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,iBAAiB,CAAC,IAAI,MAAM,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,cAAc,GAAG;wBACvL,MAAM,EAAE;4BACJ;gCACI,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,GAAG,MAAM,EAAE;6BACrB;yBACJ;qBACJ,CAAC;iBACL;aACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAEvB,WAAW,CAAC,SAAS,CAAC;gBAClB,MAAM,EAAE;oBACJ,IAAI,2BAAO,CAAC,YAAY,CAAC;wBACrB,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;wBACxD,KAAK,EAAE,qCAAqC;wBAC5C,WAAW,EAAE,GAAG,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,MAAM,iBAAiB,CAAC,IAAI,MAAM,iBAAiB,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,cAAc,GAAG;wBACnK,MAAM,EAAE;4BACJ;gCACI,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,GAAG,MAAM,EAAE;6BACrB;yBACJ;qBACJ,CAAC;iBACL;aACJ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/quick_support.js b/dist/bot/interactions/message_commands/quick_support.js new file mode 100644 index 00000000..d79ec8c9 --- /dev/null +++ b/dist/bot/interactions/message_commands/quick_support.js @@ -0,0 +1,84 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +//---------------------------------------------------------------------------------------------------------------// +const string_similarity_1 = require("string-similarity"); +const utilities_js_1 = require("../../../utilities.js"); +const mongo_js_1 = require("../../../mongo/mongo.js"); +const discord_client_js_1 = require("../../discord_client.js"); +//---------------------------------------------------------------------------------------------------------------// +module.exports = { + identifier: 'quick_support', + /** @param {Discord.AutocompleteInteraction|Discord.CommandInteraction} interaction */ + async execute(interaction) { + if (interaction.isAutocomplete()) { + const search_query = interaction.options.getFocused(); + const qs_topics = (await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME, {})); + const mapped_qs_topics = []; + for (const qs_topic of qs_topics) { + let similarity_score_total = 0; + for (const searchable_query of qs_topic.searchable_queries) { + similarity_score_total += (0, string_similarity_1.compareTwoStrings)(search_query, searchable_query); + } + similarity_score_total += (0, string_similarity_1.compareTwoStrings)(search_query, qs_topic.title) * 1.20; // multiplied for weighted value + const similarity_score_average = similarity_score_total / qs_topic.searchable_queries.length; + mapped_qs_topics.push({ + ...qs_topic, + similarity_score: similarity_score_average, + }); + } + const matching_qs_topics = mapped_qs_topics.filter(qs_topic => qs_topic.similarity_score > 0.20).sort((a, b) => b.similarity_score - a.similarity_score); + console.warn({ + matching_qs_topics, + }); + // eslint-disable-next-line no-inner-declarations + function generateRandomQuickSupportTopic() { + const random_qs_topic = (0, utilities_js_1.array_random)(qs_topics); + const already_matched_qs_topic = matching_qs_topics.find(matching_qs_topic => matching_qs_topic.id === random_qs_topic?.id); + if (!already_matched_qs_topic) + return random_qs_topic; + return generateRandomQuickSupportTopic(); + } + const random_qs_topics = Array.from({ length: 3 }, generateRandomQuickSupportTopic); + interaction.respond([ + ...matching_qs_topics, + ...random_qs_topics, + ].slice(0, 5).map(qs_topic => ({ + name: qs_topic.title, + value: qs_topic.id, + }))); + } + else if (interaction.isCommand()) { + await interaction.deferReply(); + const quick_support_topic_id = interaction.options.get('topic', true)?.value; + const qs_topics = await mongo_js_1.go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME, {}); + const quick_support_topic = qs_topics.find((qs_topic) => qs_topic.id === quick_support_topic_id); + if (!quick_support_topic) { + interaction.followUp({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0x60A0FF, + description: 'Unable to find a matching quick support topic.', + }), + ], + }); + return; + } + interaction.followUp({ + embeds: [ + new discord_client_js_1.Discord.MessageEmbed({ + color: 0x60A0FF, + author: { + iconURL: `${discord_client_js_1.client.user.displayAvatarURL({ dynamic: true })}`, + name: 'Inertia Lighting | Quick Support System', + }, + title: `${quick_support_topic.title}`, + description: `${quick_support_topic.support_contents}`, + }), + ], + }); + } + }, +}; +//# sourceMappingURL=quick_support.js.map \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/quick_support.js.map b/dist/bot/interactions/message_commands/quick_support.js.map new file mode 100644 index 00000000..aab4f88e --- /dev/null +++ b/dist/bot/interactions/message_commands/quick_support.js.map @@ -0,0 +1 @@ +{"version":3,"file":"quick_support.js","sourceRoot":"","sources":["../../../../src/bot/interactions/message_commands/quick_support.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;AAEb,mHAAmH;AAEnH,yDAAsD;AAEtD,wDAAqD;AACrD,sDAAsD;AAEtD,+DAA0D;AAa1D,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,eAAe;IAC3B,sFAAsF;IACtF,KAAK,CAAC,OAAO,CACT,WAAyE;QAEzE,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE;YAC9B,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAEtD,MAAM,SAAS,GAAG,CAAC,MAAM,sBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAA6B,EAAE,OAAO,CAAC,GAAG,CAAC,0CAAoD,EAAE,EAAE,CAAC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EAAE,GAAG,0BAAM,CAAC,IAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;4BAC9D,IAAI,EAAE,yCAAyC;yBAClD;wBACD,KAAK,EAAE,GAAG,mBAAmB,CAAC,KAAK,EAAE;wBACrC,WAAW,EAAE,GAAG,mBAAmB,CAAC,gBAAgB,EAAE;qBACzD,CAAC;iBACL;aACJ,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/src/bot/interactions/message_commands/timeout.js b/dist/bot/interactions/message_commands/timeout.js similarity index 75% rename from src/bot/interactions/message_commands/timeout.js rename to dist/bot/interactions/message_commands/timeout.js index 3255e95c..43125f95 100644 --- a/src/bot/interactions/message_commands/timeout.js +++ b/dist/bot/interactions/message_commands/timeout.js @@ -1,48 +1,22 @@ +"use strict"; /* Copyright © Inertia Lighting | All Rights Reserved */ - +Object.defineProperty(exports, "__esModule", { value: true }); +const log_moderation_action_handler_js_1 = require("../../handlers/log_moderation_action_handler.js"); +const bot_js_1 = require("../../common/bot.js"); //---------------------------------------------------------------------------------------------------------------// - -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - -const { logModerationActionToDatabase } = require('../../handlers/log_moderation_action_handler.js'); - -const { - getUserPermissionLevel, - command_permission_levels, - user_is_not_allowed_access_to_command_message_options, -} = require('../../common/bot.js'); - -//---------------------------------------------------------------------------------------------------------------// - -/** - * @typedef {import('discord.js').CommandInteraction} CommandInteraction - * @typedef {import('discord.js').GuildMember} GuildMember - */ - -//---------------------------------------------------------------------------------------------------------------// - module.exports = { identifier: 'timeout', - /** - * @param {CommandInteraction} interaction - */ async execute(interaction) { - if (!interaction.isCommand()) return; - + if (!interaction.isCommand()) + return; await interaction.deferReply(); - const interaction_guild_member = await interaction.guild.members.fetch(interaction.user.id); - - const user_permission_level = getUserPermissionLevel(interaction_guild_member); - - if (user_permission_level < command_permission_levels.MODERATORS) { - interaction.editReply(user_is_not_allowed_access_to_command_message_options).catch(console.warn); + const user_permission_level = (0, bot_js_1.getUserPermissionLevel)(interaction_guild_member); + if (user_permission_level < bot_js_1.command_permission_levels.MODERATORS) { + interaction.editReply(bot_js_1.user_is_not_allowed_access_to_command_message_options).catch(console.warn); return; // user is not allowed to access this command } const staff_member = interaction_guild_member; - /** @type {GuildMember} */ const member = await interaction.guild.members.fetch({ user: interaction.options.getMember('member', true), @@ -50,7 +24,6 @@ module.exports = { }); const duration = interaction.options.getInteger('duration', true); // in milliseconds const reason = interaction.options.getString('reason', false) || 'no reason was specified'; - /* handle when a staff member specifies themself */ if (staff_member.id === member.id) { await interaction.editReply({ @@ -63,9 +36,8 @@ module.exports = { }).catch(console.warn); return; } - /* handle when a staff member specifies this bot */ - if (member.id === interaction.client.user.id) { + if (member.id === interaction.client.user?.id) { await interaction.editReply({ embeds: [ { @@ -76,7 +48,6 @@ module.exports = { }).catch(console.warn); return; } - /* handle when a staff member specifies the guild owner */ if (member.id === interaction.guild.ownerId) { await interaction.editReply({ @@ -89,7 +60,6 @@ module.exports = { }); return; } - /* handle when a staff member tries to moderate someone with an equal/higher role */ if (staff_member.roles.highest.comparePositionTo(member.roles.highest) <= 0) { await interaction.editReply({ @@ -102,12 +72,11 @@ module.exports = { }).catch(console.warn); return; } - try { await member.timeout(duration, reason); - } catch (error) { + } + catch (error) { console.trace(error); - await interaction.editReply({ embeds: [ { @@ -116,10 +85,8 @@ module.exports = { }, ], }).catch(console.warn); - return; } - const moderation_message_options = { content: [ `${member}`, @@ -129,20 +96,18 @@ module.exports = { '\`\`\`', ].join('\n'), }; - /* dm the member */ try { const dm_channel = await interaction.client.users.createDM(member.id); await dm_channel.send(moderation_message_options); - } catch { + } + catch { // ignore any errors } - /* message the member in the server */ await interaction.editReply(moderation_message_options).catch(console.warn); - /* log to the database */ - await logModerationActionToDatabase({ + await (0, log_moderation_action_handler_js_1.logModerationActionToDatabase)({ discord_user_id: member.id, }, { type: 'TIMEOUT', @@ -152,3 +117,4 @@ module.exports = { }); }, }; +//# sourceMappingURL=timeout.js.map \ No newline at end of file diff --git a/dist/bot/interactions/message_commands/timeout.js.map b/dist/bot/interactions/message_commands/timeout.js.map new file mode 100644 index 00000000..ae80d9e0 --- /dev/null +++ b/dist/bot/interactions/message_commands/timeout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../../../src/bot/interactions/message_commands/timeout.ts"],"names":[],"mappings":";AAAA,wDAAwD;;AAMxD,sGAAgG;AAEhG,gDAA+I;AAE/I,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,SAAS;IACrB,KAAK,CAAC,OAAO,CAAC,WAAiD;QAC3D,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE;YAAE,OAAO;QAErC,MAAM,WAAW,CAAC,UAAU,EAAE,CAAC;QAE/B,MAAM,wBAAwB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE5F,MAAM,qBAAqB,GAAG,IAAA,+BAAsB,EAAC,wBAAwB,CAAC,CAAC;QAE/E,IAAI,qBAAqB,GAAG,kCAAyB,CAAC,UAAU,EAAE;YAC9D,WAAW,CAAC,SAAS,CAAC,8DAAqD,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjG,OAAO,CAAC,6CAA6C;SACxD;QACD,MAAM,YAAY,GAAG,wBAAwB,CAAC;QAE9C,0BAA0B;QAC1B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACjD,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;YACnD,KAAK,EAAE,CAAC;SACX,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC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AE,YAAY,CAAC,EAAE;SACnC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/src/bot/interactions/select_menus/automatic_roles_menu.js b/dist/bot/interactions/select_menus/automatic_roles_menu.js similarity index 75% rename from src/bot/interactions/select_menus/automatic_roles_menu.js rename to dist/bot/interactions/select_menus/automatic_roles_menu.js index ddca9f6d..b585bd27 100644 --- a/src/bot/interactions/select_menus/automatic_roles_menu.js +++ b/dist/bot/interactions/select_menus/automatic_roles_menu.js @@ -1,41 +1,29 @@ +"use strict"; /* Copyright © Inertia Lighting | All Rights Reserved */ - +Object.defineProperty(exports, "__esModule", { value: true }); //---------------------------------------------------------------------------------------------------------------// - -'use strict'; - +const discord_client_js_1 = require("../../discord_client.js"); //---------------------------------------------------------------------------------------------------------------// - -const { Discord } = require('../../discord_client.js'); - -//---------------------------------------------------------------------------------------------------------------// - const allowed_role_ids = [ - '835003401812574228', // Outage Announcements - '835003393734737952', // Product Announcements - '835003400882094090', // Community Announcements - '891339307527335936', // Survey Announcements - '914540830994358294', // Event Announcements + '835003401812574228', + '835003393734737952', + '835003400882094090', + '891339307527335936', + '914540830994358294', '835011400086716426', // Misc Announcements ]; - //---------------------------------------------------------------------------------------------------------------// - module.exports = { identifier: 'automatic_roles_menu', /** @param {Discord.SelectMenuInteraction} interaction */ async execute(interaction) { - if (!interaction.inCachedGuild()) return; - + if (!interaction.inCachedGuild()) + return; await interaction.deferReply({ ephemeral: true }); - const guild_member = await interaction.guild.members.fetch(interaction.user.id); - const supplied_role_ids = interaction.values; - const roles_to_add = allowed_role_ids.filter(role_id => supplied_role_ids.includes(role_id)); const roles_to_remove = allowed_role_ids.filter(role_id => !supplied_role_ids.includes(role_id)); - try { if (roles_to_add.length > 0) { await guild_member.roles.add(roles_to_add); @@ -43,14 +31,14 @@ module.exports = { if (roles_to_remove.length > 0) { await guild_member.roles.remove(roles_to_remove); } - } catch (error) { + } + catch (error) { console.trace(error); return; } - await interaction.editReply({ embeds: [ - new Discord.MessageEmbed({ + new discord_client_js_1.Discord.MessageEmbed({ color: 0x60A0FF, title: 'Automatic Roles', description: [ @@ -62,3 +50,4 @@ module.exports = { }); }, }; +//# sourceMappingURL=automatic_roles_menu.js.map \ No newline at end of file diff --git a/dist/bot/interactions/select_menus/automatic_roles_menu.js.map b/dist/bot/interactions/select_menus/automatic_roles_menu.js.map new file mode 100644 index 00000000..e8fe9f09 --- /dev/null +++ b/dist/bot/interactions/select_menus/automatic_roles_menu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"automatic_roles_menu.js","sourceRoot":"","sources":["../../../../src/bot/interactions/select_menus/automatic_roles_menu.ts"],"names":[],"mappings":";AAAA,wDAAwD;;AAExD,mHAAmH;AAEnH,+DAAkD;AAElD,mHAAmH;AAEnH,MAAM,gBAAgB,GAAa;IAC/B,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB,EAAE,qBAAqB;CAC9C,CAAC;AAEF,mHAAmH;AAEnH,MAAM,CAAC,OAAO,GAAG;IACb,UAAU,EAAE,sBAAsB;IAClC,yDAAyD;IACzD,KAAK,CAAC,OAAO,CAAC,WAA0C;QACpD,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;YAAE,OAAO;QAEzC,MAAM,WAAW,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAElD,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhF,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC;QAE7C,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7F,MAAM,eAAe,GAAG,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAEjG,IAAI;YACA,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzB,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;aAC9C;YACD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,MAAM,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;aACpD;SACJ;QAAC,OAAO,KAAK,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;SACV;QAED,MAAM,WAAW,CAAC,SAAS,CAAC;YACxB,MAAM,EAAE;gBACJ,IAAI,2BAAO,CAAC,YAAY,CAAC;oBACrB,KAAK,EAAE,QAAQ;oBACf,KAAK,EAAE,iBAAiB;oBACxB,WAAW,EAAE;wBACT,mDAAmD;wBACnD,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,OAAO,GAAG,CAAC;qBACrD,CAAC,IAAI,CAAC,IAAI,CAAC;iBACf,CAAC;aACL;SACJ,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"} \ No newline at end of file diff --git a/index.js b/dist/index.js similarity index 79% rename from index.js rename to dist/index.js index 0d815a1c..a63c266e 100644 --- a/index.js +++ b/dist/index.js @@ -1,30 +1,24 @@ +"use strict"; /* Copyright © Inertia Lighting | All Rights Reserved */ - //---------------------------------------------------------------------------------------------------------------// - -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - +// eslint-disable-next-line no-unused-expressions +require('module-alias/register'); +// eslint-disable-next-line no-unused-expressions require('dotenv').config(); - -//---------------------------------------------------------------------------------------------------------------// - -/* start the discord bot */ -require('./src/bot/bot.js'); - //---------------------------------------------------------------------------------------------------------------// - /* prevent the script from crashing for unhandledRejections */ process.on('unhandledRejection', (reason, promise) => { console.error('----------------------------------------------------------------------------------------------------------------'); - console.trace('unhandledRejection at:', reason?.stack ?? reason, promise); + console.trace('unhandledRejection at:', reason, promise); console.error('----------------------------------------------------------------------------------------------------------------'); }); - /* prevent the script from crashing for uncaughtExceptions */ process.on('uncaughtException', (error) => { console.error('----------------------------------------------------------------------------------------------------------------'); console.trace('uncaughtException at:', error); console.error('----------------------------------------------------------------------------------------------------------------'); }); +//---------------------------------------------------------------------------------------------------------------// +// eslint-disable-next-line no-unused-expressions +require('./bot/bot.js'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 00000000..1eba24da --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,iDAAiD;AACjD,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEjC,iDAAiD;AACjD,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;AAE3B,mHAAmH;AAEnH,8DAA8D;AAC9D,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACjD,OAAO,CAAC,KAAK,CAAC,kHAAkH,CAAC,CAAC;IAClI,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,CAAC,KAAK,CAAC,kHAAkH,CAAC,CAAC;AACtI,CAAC,CAAC,CAAC;AAEH,6DAA6D;AAC7D,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACtC,OAAO,CAAC,KAAK,CAAC,kHAAkH,CAAC,CAAC;IAClI,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,CAAC,kHAAkH,CAAC,CAAC;AACtI,CAAC,CAAC,CAAC;AAEH,mHAAmH;AAEnH,iDAAiD;AACjD,OAAO,CAAC,cAAc,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/mongo/mongo.js b/dist/mongo/mongo.js new file mode 100644 index 00000000..5af2a011 --- /dev/null +++ b/dist/mongo/mongo.js @@ -0,0 +1,10 @@ +"use strict"; +/* Copyright © Inertia Lighting | All Rights Reserved */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.go_mongo_db = void 0; +//---------------------------------------------------------------------------------------------------------------// +const go_mongo_db_1 = require("go-mongo-db"); +//---------------------------------------------------------------------------------------------------------------// +const go_mongo_db = new go_mongo_db_1.GoMongoDB(process.env.MONGO_CONNECTION_URL); +exports.go_mongo_db = go_mongo_db; +//# sourceMappingURL=mongo.js.map \ No newline at end of file diff --git a/dist/mongo/mongo.js.map b/dist/mongo/mongo.js.map new file mode 100644 index 00000000..258a7c52 --- /dev/null +++ b/dist/mongo/mongo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/mongo/mongo.ts"],"names":[],"mappings":";AAAA,wDAAwD;;;AAExD,mHAAmH;AAEnH,6CAAwC;AAExC,mHAAmH;AAEnH,MAAM,WAAW,GAAG,IAAI,uBAAS,CAAC,OAAO,CAAC,GAAG,CAAC,oBAA8B,CAAC,CAAC;AAK1E,kCAAW"} \ No newline at end of file diff --git a/dist/utilities.js b/dist/utilities.js new file mode 100644 index 00000000..f91faee4 --- /dev/null +++ b/dist/utilities.js @@ -0,0 +1,103 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ +//---------------------------------------------------------------------------------------------------------------// +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getMarkdownFriendlyTimestamp = exports.math_clamp = exports.array_random = exports.array_chunks = exports.object_sort = exports.string_ellipses = exports.random_range_inclusive = exports.Timer = void 0; +//---------------------------------------------------------------------------------------------------------------// +/** + * Asynchronous setTimeout + */ +function Timer(time_in_milliseconds) { + if (typeof time_in_milliseconds !== 'number') + throw new TypeError('\`time_in_milliseconds\` must be a number'); + return new Promise((resolve, reject) => setTimeout(() => resolve(), time_in_milliseconds)); +} +exports.Timer = Timer; +/** + * Generates a random integer in an inclusive range: min <= return_value <= max + */ +function random_range_inclusive(min, max) { + if (typeof min !== 'number') + throw new TypeError('\`min\` must be a number!'); + if (typeof max !== 'number') + throw new TypeError('\`max\` must be a number!'); + return Math.floor(Math.random() * (max - min + 1)) + min; +} +exports.random_range_inclusive = random_range_inclusive; +/** + * Ellipses a string to a specified length (including the ellipses) + */ +function string_ellipses(string_to_ellipses, output_length_limit = Number.MAX_SAFE_INTEGER, ellipses = '...') { + if (typeof string_to_ellipses !== 'string') + throw new TypeError('\`string_to_ellipses\` must be a string'); + if (typeof output_length_limit !== 'number') + throw new TypeError('\`output_length_limit\` must be a number'); + if (typeof string_to_ellipses !== 'string') + throw new TypeError('\`string_to_ellipses\` must be a string'); + const shortened_string = string_to_ellipses.slice(0, output_length_limit - ellipses.length); + const shortened_string_with_ellipses = `${shortened_string}${shortened_string.length < string_to_ellipses.length ? ellipses : ''}`; + return shortened_string_with_ellipses; +} +exports.string_ellipses = string_ellipses; +/** + * Sorts an object based on it's keys (using Array.sort()) and returns the new sorted object + */ +function object_sort(object_of_things) { + if (typeof object_of_things !== 'object' || !object_of_things) + throw new TypeError('\`object_of_things\` must be an object'); + const sorted_object_keys = Object.keys(object_of_things).sort(); + const sorted_object = {}; + for (const sorted_object_key of sorted_object_keys) { + sorted_object[sorted_object_key] = object_of_things[sorted_object_key]; + } + return sorted_object; +} +exports.object_sort = object_sort; +/** + * Splits an array into a new chunked array + */ +function array_chunks(array_of_things, chunk_size) { + if (!Array.isArray(array_of_things)) + throw new TypeError('\`array_of_things\` must be an array'); + if (typeof chunk_size !== 'number' || chunk_size !== Math.floor(chunk_size)) + throw new TypeError('\`chunk_size\` must be a (whole) number'); + const array_of_things_clone = [...array_of_things]; // prevent mutation of the original array + const chunks = []; + while (array_of_things_clone.length) { + chunks.push(array_of_things_clone.splice(0, chunk_size)); + } + return chunks; +} +exports.array_chunks = array_chunks; +/** + * Fetches a random item from the specified array + */ +function array_random(array_of_things) { + if (!Array.isArray(array_of_things)) + throw new TypeError('\`array_of_things\` must be an array!'); + return array_of_things[random_range_inclusive(0, array_of_things.length - 1)]; +} +exports.array_random = array_random; +/** + * Clamps a number between a minimum and maximum value + */ +function math_clamp(value, min, max) { + if (typeof value !== 'number') + throw new TypeError('\`value\` must be a number'); + if (typeof min !== 'number') + throw new TypeError('\`min\` must be a number'); + if (typeof max !== 'number') + throw new TypeError('\`max\` must be a number'); + return Math.min(Math.max(value, min), max); +} +exports.math_clamp = math_clamp; +/** + * Returns a valid discord timestamp from a unix timestamp + */ +function getMarkdownFriendlyTimestamp(timestamp) { + if (typeof timestamp !== 'number') + throw new TypeError('getMarkdownFriendlyTimestamp(): timestamp is not a number'); + return Math.floor(timestamp / 1000).toString(10); +} +exports.getMarkdownFriendlyTimestamp = getMarkdownFriendlyTimestamp; +//# sourceMappingURL=utilities.js.map \ No newline at end of file diff --git a/dist/utilities.js.map b/dist/utilities.js.map new file mode 100644 index 00000000..30b3cbc1 --- /dev/null +++ b/dist/utilities.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,mHAAmH;AAEnH,YAAY,CAAC;;;AAQb,mHAAmH;AAEnH;;GAEG;AACH,SAAgB,KAAK,CAAC,oBAA4B;IAC9C,IAAI,OAAO,oBAAoB,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;IAE/G,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAC/F,CAAC;AAJD,sBAIC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,GA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AK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACjF,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAC7E,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAE7E,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC;AAVD,gCAUC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAAC,SAAiB;IAC1D,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAC;IAEpH,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAJD,oEAIC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bbec3ae3..0b5b9ebc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "dotenv": "16.0.1", "erlpack": "0.1.4", "go-mongo-db": "github:Inertia-Lighting/go-mongo-db#v1.2.0-stable", + "module-alias": "2.2.2", "moment-timezone": "0.5.34", "node-gyp": "8.4.1", "recursive-read-directory": "github:MidSpike/recursive-read-directory#v0.0.1-beta", @@ -24,10 +25,14 @@ "zlib-sync": "0.1.7" }, "devDependencies": { + "@types/string-similarity": "^4.0.0", + "@typescript-eslint/eslint-plugin": "5.33.0", + "@typescript-eslint/parser": "5.33.0", "eslint": "8.21.0", "husky": "8.0.1", "is-ci": "3.0.1", - "run-script-os": "1.1.6" + "run-script-os": "1.1.6", + "typescript": "^4.7.4" }, "engines": { "node": ">=16.0.0", @@ -38,6 +43,7 @@ "version": "0.14.0", "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.14.0.tgz", "integrity": "sha512-+fqLIqa9wN3R+kvlld8sgG0nt04BAZxdCDP4t2qZ9TJsquLWA+xMtT8Waibb3d4li4AQS+IOfjiHAznv/dhHgQ==", + "deprecated": "no longer supported", "dependencies": { "@sapphire/shapeshift": "^3.1.0", "@sindresorhus/is": "^4.6.0", @@ -54,6 +60,7 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0.tgz", "integrity": "sha512-R5i8Wb8kIcBAFEPLLf7LVBQKBDYUL+ekb23sOgpkpyGT+V4P7V83wTxcsqmX+PbqHt4cEHn053uMWfRqh/Z/nA==", + "deprecated": "no longer supported", "engines": { "node": ">=16.9.0" } @@ -157,20 +164,6 @@ "semver": "^7.3.5" } }, - "node_modules/@npmcli/fs/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@npmcli/move-file": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@npmcli/move-file/-/move-file-1.1.2.tgz", @@ -184,20 +177,24 @@ } }, "node_modules/@sapphire/async-queue": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.1.tgz", - "integrity": "sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.4.0.tgz", + "integrity": "sha512-1npoLO1YPPXCsWCfuonsSdtHbPUo6dvjWUJtmUHiK8yDTmy00LbkpRkdV/UycA1fh+QsxwOPhgx2zu64Z+19ww==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" } }, "node_modules/@sapphire/shapeshift": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.1.0.tgz", - "integrity": "sha512-PkxFXd3QJ1qAPS05Dy2UkVGYPm/asF1Ugt2Xyzmv4DHzO3+G7l+873C4XFFcJ9M5Je+eCMC7SSifgPTSur5QuA==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.5.1.tgz", + "integrity": "sha512-7JFsW5IglyOIUQI1eE0g6h06D/Far6HqpcowRScgCiLSqTf3hhkPWCWotVTtVycnDCMYIwPeaw6IEPBomKC8pA==", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "lodash.uniqwith": "^4.5.0" + }, "engines": { - "node": ">=v15.0.0", + "node": ">=v14.0.0", "npm": ">=7.0.0" } }, @@ -220,15 +217,21 @@ "node": ">= 6" } }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "node_modules/@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==" + "version": "18.6.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz", + "integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==" }, "node_modules/@types/node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", + "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", "dependencies": { "@types/node": "*", "form-data": "^3.0.0" @@ -247,15 +250,21 @@ "node": ">= 6" } }, + "node_modules/@types/string-similarity": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/string-similarity/-/string-similarity-4.0.0.tgz", + "integrity": "sha512-dMS4S07fbtY1AILG/RhuwmptmzK1Ql8scmAebOTJ/8iBtK/KI17NwGwKzu1uipjj8Kk+3mfPxum56kKZE93mzQ==", + "dev": true + }, "node_modules/@types/webidl-conversions": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz", "integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q==" }, "node_modules/@types/whatwg-url": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz", - "integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==", + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", + "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", "dependencies": { "@types/node": "*", "@types/webidl-conversions": "*" @@ -269,6 +278,190 @@ "@types/node": "*" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.33.0.tgz", + "integrity": "sha512-jHvZNSW2WZ31OPJ3enhLrEKvAZNyAFWZ6rx9tUwaessTc4sx9KmgMNhVcqVAl1ETnT5rU5fpXTLmY9YvC1DCNg==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/type-utils": "5.33.0", + "@typescript-eslint/utils": "5.33.0", + "debug": "^4.3.4", + "functional-red-black-tree": "^1.0.1", + "ignore": "^5.2.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.33.0.tgz", + "integrity": "sha512-cgM5cJrWmrDV2KpvlcSkelTBASAs1mgqq+IUGKJvFxWrapHpaRy5EXPQz9YaKF3nZ8KY18ILTiVpUtbIac86/w==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/typescript-estree": "5.33.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.33.0.tgz", + "integrity": "sha512-/Jta8yMNpXYpRDl8EwF/M8It2A9sFJTubDo0ATZefGXmOqlaBffEw0ZbkbQ7TNDK6q55NPHFshGBPAZvZkE8Pw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/visitor-keys": "5.33.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.33.0.tgz", + "integrity": "sha512-2zB8uEn7hEH2pBeyk3NpzX1p3lF9dKrEbnXq1F7YkpZ6hlyqb2yZujqgRGqXgRBTHWIUG3NGx/WeZk224UKlIA==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "5.33.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.33.0.tgz", + "integrity": "sha512-nIMt96JngB4MYFYXpZ/3ZNU4GWPNdBbcB5w2rDOCpXOVUkhtNlG2mmm8uXhubhidRZdwMaMBap7Uk8SZMU/ppw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.0.tgz", + "integrity": "sha512-tqq3MRLlggkJKJUrzM6wltk8NckKyyorCSGMq4eVkyL5sDYzJJcMgZATqmF8fLdsWrW7OjjIZ1m9v81vKcaqwQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/visitor-keys": "5.33.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.33.0.tgz", + "integrity": "sha512-JxOAnXt9oZjXLIiXb5ZIcZXiwVHCkqZgof0O8KPgz7C7y0HS42gi75PdPlqh1Tf109M0fyUw45Ao6JLo7S5AHw==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/typescript-estree": "5.33.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.0.tgz", + "integrity": "sha512-/XsqCzD4t+Y9p5wd9HZiptuGKBlaZO5showwqODii5C0nZawxWLF+Q6k5wYHBrQv96h6GYKyqqMHCSTqta8Kiw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.33.0", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -355,21 +548,36 @@ "node": ">=8" } }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" }, "node_modules/are-we-there-yet": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz", - "integrity": "sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", + "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", "dependencies": { "delegates": "^1.0.0", "readable-stream": "^3.6.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/argparse": { @@ -390,7 +598,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { "version": "0.27.2", @@ -455,9 +663,9 @@ } }, "node_modules/bson": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.1.tgz", - "integrity": "sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==", + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.5.tgz", + "integrity": "sha512-uqrgcjyOaZsHfz7ea8zLRCLe1u+QGUSzMZmvXqO24CDW7DWoW1qiN9folSwa7hSneTSgM2ykDIzF5kcQQ8cwNw==", "dependencies": { "buffer": "^5.6.0" }, @@ -537,6 +745,22 @@ "node": ">=6" } }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -546,9 +770,9 @@ } }, "node_modules/ci-info": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz", - "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", + "integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==", "dev": true }, "node_modules/clean-stack": { @@ -559,6 +783,24 @@ "node": ">=6" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", @@ -581,12 +823,12 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" }, "node_modules/cross-spawn": { "version": "7.0.3", @@ -603,9 +845,9 @@ } }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { "ms": "2.1.2" }, @@ -627,7 +869,7 @@ "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "engines": { "node": ">=0.4.0" } @@ -635,12 +877,12 @@ "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" }, "node_modules/denque": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz", - "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", "engines": { "node": ">=0.10" } @@ -648,7 +890,7 @@ "node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", "engines": { "node": ">= 0.6" } @@ -666,14 +908,15 @@ } }, "node_modules/discord-api-types": { - "version": "0.33.3", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.3.tgz", - "integrity": "sha512-P3A1RJXKEDmGPHrFTN5+gYLsBPGUVGj+D3+fa3m0K/umc+LMfqGuEad+p7cNq7ry/icReVhS3bz9jvBvne/BRA==" + "version": "0.33.5", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.5.tgz", + "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==" }, "node_modules/discord.js": { "version": "13.8.1", "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.8.1.tgz", "integrity": "sha512-jOsD+4tEZWWx0RHVyH+FBcqoTrsL+d5Mm5p+ULQOdU0qSaxhLNkWYig+yDHNZoND7nlkXX3qi+BW+gO5erWylg==", + "deprecated": "no longer supported", "dependencies": { "@discordjs/builders": "^0.14.0", "@discordjs/collection": "^0.7.0", @@ -724,18 +967,6 @@ "iconv-lite": "^0.6.2" } }, - "node_modules/encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "optional": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/env-paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", @@ -759,6 +990,18 @@ "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint": { "version": "8.21.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.21.0.tgz", @@ -815,6 +1058,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/eslint-utils": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", @@ -833,7 +1089,7 @@ "eslint": ">=5" } }, - "node_modules/eslint-visitor-keys": { + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", @@ -842,65 +1098,13 @@ "node": ">=10" } }, - "node_modules/eslint/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/eslint/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/eslint/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/eslint/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/eslint/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "node_modules/eslint-visitor-keys": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/eslint/node_modules/eslint-scope": { @@ -916,15 +1120,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/eslint/node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", @@ -934,27 +1129,6 @@ "node": ">=4.0" } }, - "node_modules/eslint/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/eslint/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/espree": { "version": "9.3.3", "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.3.tgz", @@ -972,15 +1146,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", @@ -1023,6 +1188,15 @@ "node": ">=4.0" } }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1074,7 +1248,7 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/fastq": { @@ -1145,15 +1319,15 @@ } }, "node_modules/flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.6.tgz", + "integrity": "sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==", "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==", "funding": [ { "type": "individual", @@ -1185,7 +1359,7 @@ "node_modules/fs": { "version": "0.0.1-security", "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", - "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" }, "node_modules/fs-minipass": { "version": "2.1.0", @@ -1201,18 +1375,18 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "node_modules/gauge": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.3.tgz", - "integrity": "sha512-ICw1DhAwMtb22rYFwEHgJcx1JCwJGv3x6G0OQUq56Nge+H4Q8JEwr8iveS0XFlsUNSI67F5ffMGK25bK4Pmskw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", + "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", "dependencies": { "aproba": "^1.0.3 || ^2.0.0", "color-support": "^1.1.3", @@ -1224,18 +1398,18 @@ "wide-align": "^1.1.5" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -1259,9 +1433,9 @@ } }, "node_modules/globals": { - "version": "13.15.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz", - "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1306,9 +1480,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, "node_modules/grapheme-splitter": { "version": "1.0.4", @@ -1316,10 +1490,19 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" }, "node_modules/http-cache-semantics": { "version": "4.1.0", @@ -1340,9 +1523,9 @@ } }, "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dependencies": { "agent-base": "6", "debug": "4" @@ -1354,7 +1537,7 @@ "node_modules/humanize-ms": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", "dependencies": { "ms": "^2.0.0" } @@ -1374,6 +1557,18 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -1421,7 +1616,7 @@ "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "engines": { "node": ">=0.8.19" } @@ -1442,7 +1637,7 @@ "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -1454,9 +1649,9 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" }, "node_modules/is-ci": { "version": "3.0.1", @@ -1473,7 +1668,7 @@ "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -1502,7 +1697,7 @@ "node_modules/is-lambda": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", - "integrity": "sha1-PZh3iZ5qU+/AFgUEzeFfgubwYdU=" + "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==" }, "node_modules/is-number": { "version": "7.0.0", @@ -1516,7 +1711,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -1539,7 +1734,7 @@ "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/levn": { @@ -1576,6 +1771,11 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.uniqwith": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniqwith/-/lodash.uniqwith-4.5.0.tgz", + "integrity": "sha512-7lYL8bLopMoy4CTICbxygAUq6CdRJ36vFc80DucPueUee+d5NBRxz3FdT9Pes/HEx5mPoT9jwnsEJWz1N7uq7Q==" + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1672,9 +1872,9 @@ } }, "node_modules/minipass": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", - "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", + "integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==", "dependencies": { "yallist": "^4.0.0" }, @@ -1765,6 +1965,11 @@ "node": ">=10" } }, + "node_modules/module-alias": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + }, "node_modules/moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -1785,11 +1990,11 @@ } }, "node_modules/mongodb": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.4.1.tgz", - "integrity": "sha512-IAD3nFtCR4s22vi5qjqkCBnuyDDrOW8WVSSmgHquOvGaP1iTD+XpC5tr8wAUbZ2EeZkaswwBKQFHDvl4qYcKqQ==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.8.1.tgz", + "integrity": "sha512-/NyiM3Ox9AwP5zrfT9TXjRKDJbXlLaUDQ9Rg//2lbg8D2A8GXV0VidYYnA/gfdK6uwbnL4FnAflH7FbGw3TS7w==", "dependencies": { - "bson": "^4.6.1", + "bson": "^4.6.5", "denque": "^2.0.1", "mongodb-connection-string-url": "^2.5.2", "socks": "^2.6.2" @@ -1802,9 +2007,9 @@ } }, "node_modules/mongodb-connection-string-url": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz", - "integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.3.tgz", + "integrity": "sha512-f+/WsED+xF4B74l3k9V/XkTVj5/fxFH2o5ToKXd8Iyi5UhM+sO9u0Ape17Mvl/GkZaFtM0HQnzAG5OTmhKw+tQ==", "dependencies": { "@types/whatwg-url": "^8.2.1", "whatwg-url": "^11.0.0" @@ -1816,14 +2021,14 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz", + "integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==" }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/negotiator": { @@ -1856,17 +2061,17 @@ "node_modules/node-fetch/node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/node-fetch/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/node-fetch/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -1896,29 +2101,15 @@ } }, "node_modules/node-gyp-build": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.3.0.tgz", - "integrity": "sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", + "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==", "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", "node-gyp-build-test": "build-test.js" } }, - "node_modules/node-gyp/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/nopt": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", @@ -1934,23 +2125,23 @@ } }, "node_modules/npmlog": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.1.tgz", - "integrity": "sha512-BTHDvY6nrRHuRfyjt1MAufLxYdVXZfd099H4+i1f0lPywNQyI4foeNXJRObB/uy+TYqUW0vAD9gbdSOXPst7Eg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", + "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", "dependencies": { "are-we-there-yet": "^3.0.0", "console-control-strings": "^1.1.0", - "gauge": "^4.0.0", + "gauge": "^4.0.3", "set-blocking": "^2.0.0" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dependencies": { "wrappy": "1" } @@ -2031,7 +2222,7 @@ "node_modules/path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", - "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", "dependencies": { "process": "^0.11.1", "util": "^0.10.3" @@ -2049,7 +2240,7 @@ "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "engines": { "node": ">=0.10.0" } @@ -2096,7 +2287,7 @@ "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", "engines": { "node": ">= 0.6.0" } @@ -2104,7 +2295,7 @@ "node_modules/promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" + "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==" }, "node_modules/promise-retry": { "version": "2.0.1", @@ -2192,7 +2383,7 @@ "node_modules/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", "engines": { "node": ">= 4" } @@ -2254,6 +2445,25 @@ "run-script-os": "index.js" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -2272,10 +2482,24 @@ "node": ">=6" } }, + "node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "node_modules/shebang-command": { "version": "2.0.0", @@ -2322,11 +2546,11 @@ } }, "node_modules/socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", + "integrity": "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA==", "dependencies": { - "ip": "^1.1.5", + "ip": "^2.0.0", "smart-buffer": "^4.2.0" }, "engines": { @@ -2335,13 +2559,13 @@ } }, "node_modules/socks-proxy-agent": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", - "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz", + "integrity": "sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ==", "dependencies": { "agent-base": "^6.0.2", - "debug": "^4.3.1", - "socks": "^2.6.1" + "debug": "^4.3.3", + "socks": "^2.6.2" }, "engines": { "node": ">= 10" @@ -2350,7 +2574,7 @@ "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", - "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", "optional": true, "dependencies": { "memory-pager": "^1.0.2" @@ -2375,25 +2599,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/string_decoder/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/string-similarity": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz", @@ -2435,6 +2640,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/tar": { "version": "6.1.11", "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", @@ -2454,7 +2671,7 @@ "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/to-regex-range": { @@ -2490,6 +2707,27 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "dependencies": { + "tslib": "^1.8.1" + }, + "engines": { + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + } + }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -2514,6 +2752,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/unique-filename": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", @@ -2562,12 +2813,12 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/util/node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" }, "node_modules/uuid": { "version": "8.3.2", @@ -2637,12 +2888,12 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/ws": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz", - "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz", + "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==", "engines": { "node": ">=10.0.0" }, @@ -2783,16 +3034,6 @@ "requires": { "@gar/promisify": "^1.0.1", "semver": "^7.3.5" - }, - "dependencies": { - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "@npmcli/move-file": { @@ -2805,14 +3046,18 @@ } }, "@sapphire/async-queue": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.1.tgz", - "integrity": "sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.4.0.tgz", + "integrity": "sha512-1npoLO1YPPXCsWCfuonsSdtHbPUo6dvjWUJtmUHiK8yDTmy00LbkpRkdV/UycA1fh+QsxwOPhgx2zu64Z+19ww==" }, "@sapphire/shapeshift": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.1.0.tgz", - "integrity": "sha512-PkxFXd3QJ1qAPS05Dy2UkVGYPm/asF1Ugt2Xyzmv4DHzO3+G7l+873C4XFFcJ9M5Je+eCMC7SSifgPTSur5QuA==" + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.5.1.tgz", + "integrity": "sha512-7JFsW5IglyOIUQI1eE0g6h06D/Far6HqpcowRScgCiLSqTf3hhkPWCWotVTtVycnDCMYIwPeaw6IEPBomKC8pA==", + "requires": { + "fast-deep-equal": "^3.1.3", + "lodash.uniqwith": "^4.5.0" + } }, "@sindresorhus/is": { "version": "4.6.0", @@ -2824,15 +3069,21 @@ "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==" + "version": "18.6.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz", + "integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==" }, "@types/node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", + "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", "requires": { "@types/node": "*", "form-data": "^3.0.0" @@ -2850,15 +3101,21 @@ } } }, + "@types/string-similarity": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/string-similarity/-/string-similarity-4.0.0.tgz", + "integrity": "sha512-dMS4S07fbtY1AILG/RhuwmptmzK1Ql8scmAebOTJ/8iBtK/KI17NwGwKzu1uipjj8Kk+3mfPxum56kKZE93mzQ==", + "dev": true + }, "@types/webidl-conversions": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-6.1.1.tgz", "integrity": "sha512-XAahCdThVuCFDQLT7R7Pk/vqeObFNL3YqRyFZg+AqAP/W1/w3xHaIxuW7WszQqTbIBOPRcItYJIou3i/mppu3Q==" }, "@types/whatwg-url": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.1.tgz", - "integrity": "sha512-2YubE1sjj5ifxievI5Ge1sckb9k/Er66HyR2c+3+I6VDUUg1TLPdYYTEbQ+DjRkS4nTxMJhgWfSfMRD2sl2EYQ==", + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", + "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", "requires": { "@types/node": "*", "@types/webidl-conversions": "*" @@ -2872,6 +3129,101 @@ "@types/node": "*" } }, + "@typescript-eslint/eslint-plugin": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.33.0.tgz", + "integrity": "sha512-jHvZNSW2WZ31OPJ3enhLrEKvAZNyAFWZ6rx9tUwaessTc4sx9KmgMNhVcqVAl1ETnT5rU5fpXTLmY9YvC1DCNg==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/type-utils": "5.33.0", + "@typescript-eslint/utils": "5.33.0", + "debug": "^4.3.4", + "functional-red-black-tree": "^1.0.1", + "ignore": "^5.2.0", + "regexpp": "^3.2.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/parser": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.33.0.tgz", + "integrity": "sha512-cgM5cJrWmrDV2KpvlcSkelTBASAs1mgqq+IUGKJvFxWrapHpaRy5EXPQz9YaKF3nZ8KY18ILTiVpUtbIac86/w==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/typescript-estree": "5.33.0", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.33.0.tgz", + "integrity": "sha512-/Jta8yMNpXYpRDl8EwF/M8It2A9sFJTubDo0ATZefGXmOqlaBffEw0ZbkbQ7TNDK6q55NPHFshGBPAZvZkE8Pw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/visitor-keys": "5.33.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.33.0.tgz", + "integrity": "sha512-2zB8uEn7hEH2pBeyk3NpzX1p3lF9dKrEbnXq1F7YkpZ6hlyqb2yZujqgRGqXgRBTHWIUG3NGx/WeZk224UKlIA==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "5.33.0", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/types": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.33.0.tgz", + "integrity": "sha512-nIMt96JngB4MYFYXpZ/3ZNU4GWPNdBbcB5w2rDOCpXOVUkhtNlG2mmm8uXhubhidRZdwMaMBap7Uk8SZMU/ppw==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.0.tgz", + "integrity": "sha512-tqq3MRLlggkJKJUrzM6wltk8NckKyyorCSGMq4eVkyL5sDYzJJcMgZATqmF8fLdsWrW7OjjIZ1m9v81vKcaqwQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/visitor-keys": "5.33.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + } + }, + "@typescript-eslint/utils": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.33.0.tgz", + "integrity": "sha512-JxOAnXt9oZjXLIiXb5ZIcZXiwVHCkqZgof0O8KPgz7C7y0HS42gi75PdPlqh1Tf109M0fyUw45Ao6JLo7S5AHw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.33.0", + "@typescript-eslint/types": "5.33.0", + "@typescript-eslint/typescript-estree": "5.33.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "5.33.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.0.tgz", + "integrity": "sha512-/XsqCzD4t+Y9p5wd9HZiptuGKBlaZO5showwqODii5C0nZawxWLF+Q6k5wYHBrQv96h6GYKyqqMHCSTqta8Kiw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.33.0", + "eslint-visitor-keys": "^3.3.0" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -2934,15 +3286,24 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" }, "are-we-there-yet": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz", - "integrity": "sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", + "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", "requires": { "delegates": "^1.0.0", "readable-stream": "^3.6.0" @@ -2963,7 +3324,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "axios": { "version": "0.27.2", @@ -3011,9 +3372,9 @@ } }, "bson": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.1.tgz", - "integrity": "sha512-I1LQ7Hz5zgwR4QquilLNZwbhPw0Apx7i7X9kGMBTsqPdml/03Q9NBtD9nt/19ahjlphktQImrnderxqpzeVDjw==", + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/bson/-/bson-4.6.5.tgz", + "integrity": "sha512-uqrgcjyOaZsHfz7ea8zLRCLe1u+QGUSzMZmvXqO24CDW7DWoW1qiN9folSwa7hSneTSgM2ykDIzF5kcQQ8cwNw==", "requires": { "buffer": "^5.6.0" } @@ -3066,15 +3427,25 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, "chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" }, "ci-info": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.0.tgz", - "integrity": "sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", + "integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==", "dev": true }, "clean-stack": { @@ -3082,6 +3453,21 @@ "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==" }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "color-support": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", @@ -3098,12 +3484,12 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" }, "cross-spawn": { "version": "7.0.3", @@ -3117,9 +3503,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { "ms": "2.1.2" } @@ -3133,22 +3519,22 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" }, "denque": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-2.0.1.tgz", - "integrity": "sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", + "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==" }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==" }, "dir-glob": { "version": "3.0.1", @@ -3160,9 +3546,9 @@ } }, "discord-api-types": { - "version": "0.33.3", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.3.tgz", - "integrity": "sha512-P3A1RJXKEDmGPHrFTN5+gYLsBPGUVGj+D3+fa3m0K/umc+LMfqGuEad+p7cNq7ry/icReVhS3bz9jvBvne/BRA==" + "version": "0.33.5", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.5.tgz", + "integrity": "sha512-dvO5M52v7m7Dy96+XUnzXNsQ/0npsYpU6dL205kAtEDueswoz3aU3bh1UMoK4cQmcGtB1YRyLKqp+DXi05lzFg==" }, "discord.js": { "version": "13.8.1", @@ -3206,17 +3592,6 @@ "optional": true, "requires": { "iconv-lite": "^0.6.2" - }, - "dependencies": { - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - } } }, "env-paths": { @@ -3238,6 +3613,12 @@ "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==" }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, "eslint": { "version": "8.21.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.21.0.tgz", @@ -3285,46 +3666,6 @@ "v8-compile-cache": "^2.0.3" }, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, "eslint-scope": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", @@ -3335,35 +3676,24 @@ "estraverse": "^5.2.0" } }, - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - }, "estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } } } }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, "eslint-utils": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", @@ -3371,12 +3701,20 @@ "dev": true, "requires": { "eslint-visitor-keys": "^2.0.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } } }, "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, "espree": { @@ -3388,14 +3726,6 @@ "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", - "dev": true - } } }, "esquery": { @@ -3432,6 +3762,12 @@ } } }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -3476,7 +3812,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "fastq": { @@ -3532,15 +3868,15 @@ } }, "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.6.tgz", + "integrity": "sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==", "dev": true }, "follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==" }, "form-data": { "version": "4.0.0", @@ -3555,7 +3891,7 @@ "fs": { "version": "0.0.1-security", "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", - "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" }, "fs-minipass": { "version": "2.1.0", @@ -3568,18 +3904,18 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "gauge": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.3.tgz", - "integrity": "sha512-ICw1DhAwMtb22rYFwEHgJcx1JCwJGv3x6G0OQUq56Nge+H4Q8JEwr8iveS0XFlsUNSI67F5ffMGK25bK4Pmskw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", + "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", "requires": { "aproba": "^1.0.3 || ^2.0.0", "color-support": "^1.1.3", @@ -3592,14 +3928,14 @@ } }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -3614,9 +3950,9 @@ } }, "globals": { - "version": "13.15.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.15.0.tgz", - "integrity": "sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -3644,9 +3980,9 @@ } }, "graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, "grapheme-splitter": { "version": "1.0.4", @@ -3654,10 +3990,16 @@ "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" }, "http-cache-semantics": { "version": "4.1.0", @@ -3675,9 +4017,9 @@ } }, "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "requires": { "agent-base": "6", "debug": "4" @@ -3686,7 +4028,7 @@ "humanize-ms": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", "requires": { "ms": "^2.0.0" } @@ -3697,6 +4039,15 @@ "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -3721,7 +4072,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==" }, "indent-string": { "version": "4.0.0", @@ -3736,7 +4087,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "requires": { "once": "^1.3.0", "wrappy": "1" @@ -3748,9 +4099,9 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" }, "is-ci": { "version": "3.0.1", @@ -3764,7 +4115,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -3784,7 +4135,7 @@ "is-lambda": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", - "integrity": "sha1-PZh3iZ5qU+/AFgUEzeFfgubwYdU=" + "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==" }, "is-number": { "version": "7.0.0", @@ -3795,7 +4146,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "js-yaml": { "version": "4.1.0", @@ -3815,7 +4166,7 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "levn": { @@ -3843,6 +4194,11 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "lodash.uniqwith": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniqwith/-/lodash.uniqwith-4.5.0.tgz", + "integrity": "sha512-7lYL8bLopMoy4CTICbxygAUq6CdRJ36vFc80DucPueUee+d5NBRxz3FdT9Pes/HEx5mPoT9jwnsEJWz1N7uq7Q==" + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -3918,9 +4274,9 @@ } }, "minipass": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.6.tgz", - "integrity": "sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz", + "integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==", "requires": { "yallist": "^4.0.0" } @@ -3982,6 +4338,11 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, + "module-alias": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + }, "moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -3996,11 +4357,11 @@ } }, "mongodb": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.4.1.tgz", - "integrity": "sha512-IAD3nFtCR4s22vi5qjqkCBnuyDDrOW8WVSSmgHquOvGaP1iTD+XpC5tr8wAUbZ2EeZkaswwBKQFHDvl4qYcKqQ==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.8.1.tgz", + "integrity": "sha512-/NyiM3Ox9AwP5zrfT9TXjRKDJbXlLaUDQ9Rg//2lbg8D2A8GXV0VidYYnA/gfdK6uwbnL4FnAflH7FbGw3TS7w==", "requires": { - "bson": "^4.6.1", + "bson": "^4.6.5", "denque": "^2.0.1", "mongodb-connection-string-url": "^2.5.2", "saslprep": "^1.0.3", @@ -4008,9 +4369,9 @@ } }, "mongodb-connection-string-url": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.2.tgz", - "integrity": "sha512-tWDyIG8cQlI5k3skB6ywaEA5F9f5OntrKKsT/Lteub2zgwSUlhqEN2inGgBTm8bpYJf8QYBdA/5naz65XDpczA==", + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.5.3.tgz", + "integrity": "sha512-f+/WsED+xF4B74l3k9V/XkTVj5/fxFH2o5ToKXd8Iyi5UhM+sO9u0Ape17Mvl/GkZaFtM0HQnzAG5OTmhKw+tQ==", "requires": { "@types/whatwg-url": "^8.2.1", "whatwg-url": "^11.0.0" @@ -4022,14 +4383,14 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz", + "integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==" }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "negotiator": { @@ -4048,17 +4409,17 @@ "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "requires": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -4081,22 +4442,12 @@ "semver": "^7.3.5", "tar": "^6.1.2", "which": "^2.0.2" - }, - "dependencies": { - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "requires": { - "lru-cache": "^6.0.0" - } - } } }, "node-gyp-build": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.3.0.tgz", - "integrity": "sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==" + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", + "integrity": "sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==" }, "nopt": { "version": "5.0.0", @@ -4107,20 +4458,20 @@ } }, "npmlog": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.1.tgz", - "integrity": "sha512-BTHDvY6nrRHuRfyjt1MAufLxYdVXZfd099H4+i1f0lPywNQyI4foeNXJRObB/uy+TYqUW0vAD9gbdSOXPst7Eg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", + "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", "requires": { "are-we-there-yet": "^3.0.0", "console-control-strings": "^1.1.0", - "gauge": "^4.0.0", + "gauge": "^4.0.3", "set-blocking": "^2.0.0" } }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "requires": { "wrappy": "1" } @@ -4177,7 +4528,7 @@ "path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", - "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", "requires": { "process": "^0.11.1", "util": "^0.10.3" @@ -4192,7 +4543,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" }, "path-key": { "version": "3.1.1", @@ -4221,12 +4572,12 @@ "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" }, "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" + "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==" }, "promise-retry": { "version": "2.0.1", @@ -4281,7 +4632,7 @@ "retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==" }, "reusify": { "version": "1.0.4", @@ -4312,6 +4663,11 @@ "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", "dev": true }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -4327,10 +4683,18 @@ "sparse-bitfield": "^3.0.3" } }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "requires": { + "lru-cache": "^6.0.0" + } + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "shebang-command": { "version": "2.0.0", @@ -4364,28 +4728,28 @@ "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==" }, "socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", + "integrity": "sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA==", "requires": { - "ip": "^1.1.5", + "ip": "^2.0.0", "smart-buffer": "^4.2.0" } }, "socks-proxy-agent": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz", - "integrity": "sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz", + "integrity": "sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ==", "requires": { "agent-base": "^6.0.2", - "debug": "^4.3.1", - "socks": "^2.6.1" + "debug": "^4.3.3", + "socks": "^2.6.2" } }, "sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", - "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", "optional": true, "requires": { "memory-pager": "^1.0.2" @@ -4405,13 +4769,6 @@ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "requires": { "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - } } }, "string-similarity": { @@ -4443,6 +4800,15 @@ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, "tar": { "version": "6.1.11", "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", @@ -4459,7 +4825,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "to-regex-range": { @@ -4489,6 +4855,23 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + } + } + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -4504,6 +4887,12 @@ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, + "typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true + }, "unique-filename": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", @@ -4548,14 +4937,14 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" } } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "uuid": { "version": "8.3.2", @@ -4607,12 +4996,12 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "ws": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz", - "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz", + "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==", "requires": {} }, "yallist": { diff --git a/package.json b/package.json index ef3a2c98..e10370e5 100644 --- a/package.json +++ b/package.json @@ -2,27 +2,31 @@ "name": "discord-bot", "version": "3.0.0", "description": "", - "main": "index.js", + "keywords": [], + "author": "Inertia Lighting", + "license": "UNLICENSED", + "main": "./dist/index.js", + "_moduleAliases": { + "@root": "./dist" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, "scripts": { - "test": "npm run lint", + "husky": "is-ci || husky install", "lint": "npx eslint .", - "prepare": "is-ci || husky install", + "clean": "run-script-os", + "clean:windows": "if exist \".\\dist\" rmdir /s /q \".\\dist\"", + "clean:linux": "rm -rf ./dist", + "build": "npm run clean && tsc --build", + "prepare": "npm run husky && npm run lint && npm run build", + "test": "npm run prepare", "title": "run-script-os", "title:windows": "title Inertia Lighting Discord Bot", "title:default": "", - "start": "npm run title && node --trace-warnings index.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Inertia-Lighting/discord-bot.git" + "start": "npm run prepare && npm run title && node --trace-warnings --enable-source-maps --require dotenv/config ." }, - "keywords": [], - "author": "Inertia Lighting", - "license": "UNLICENSED", - "bugs": { - "url": "https://github.com/Inertia-Lighting/discord-bot/issues" - }, - "homepage": "https://github.com/Inertia-Lighting/discord-bot#readme", "dependencies": { "axios": "0.27.2", "bufferutil": "4.0.6", @@ -30,6 +34,7 @@ "dotenv": "16.0.1", "erlpack": "0.1.4", "go-mongo-db": "github:Inertia-Lighting/go-mongo-db#v1.2.0-stable", + "module-alias": "2.2.2", "moment-timezone": "0.5.34", "node-gyp": "8.4.1", "recursive-read-directory": "github:MidSpike/recursive-read-directory#v0.0.1-beta", @@ -39,13 +44,13 @@ "zlib-sync": "0.1.7" }, "devDependencies": { + "@types/string-similarity": "^4.0.0", + "@typescript-eslint/eslint-plugin": "5.33.0", + "@typescript-eslint/parser": "5.33.0", "eslint": "8.21.0", "husky": "8.0.1", "is-ci": "3.0.1", - "run-script-os": "1.1.6" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=8.0.0" + "run-script-os": "1.1.6", + "typescript": "^4.7.4" } } diff --git a/src/bot/bot.js b/src/bot/bot.js deleted file mode 100644 index d9906d41..00000000 --- a/src/bot/bot.js +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright © Inertia Lighting | All Rights Reserved */ - -//---------------------------------------------------------------------------------------------------------------// - -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - -const fs = require('node:fs'); -const path = require('node:path'); - -//---------------------------------------------------------------------------------------------------------------// - -const { client } = require('./discord_client.js'); - -//---------------------------------------------------------------------------------------------------------------// - -const event_files_path = path.join(process.cwd(), './src/bot/events/'); -const event_files = fs.readdirSync(event_files_path).filter(file => file.endsWith('.js')); - -/* register events */ -for (const event_file of event_files) { - const bot_event = require(path.join(event_files_path, event_file)); - client.on(bot_event.name, bot_event.handler); -} diff --git a/src/bot/bot.ts b/src/bot/bot.ts new file mode 100644 index 00000000..45c9618a --- /dev/null +++ b/src/bot/bot.ts @@ -0,0 +1,24 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ + +//---------------------------------------------------------------------------------------------------------------// + +import fs from 'node:fs'; + +import path from 'node:path'; + +import { client } from './discord_client.js'; + +//---------------------------------------------------------------------------------------------------------------// + +async function main() { + const event_files_path = path.join(process.cwd(), './src/bot/events/'); + const event_files = fs.readdirSync(event_files_path).filter(file => file.endsWith('.js')); + + /* register events */ + for (const event_file of event_files) { + const { default: bot_event } = await import(path.join(event_files_path, event_file)); + client.on(bot_event.name, bot_event.handler); + } +} + +main(); diff --git a/src/bot/common/bot.js b/src/bot/common/bot.ts similarity index 84% rename from src/bot/common/bot.js rename to src/bot/common/bot.ts index adcbabdb..ed207b19 100644 --- a/src/bot/common/bot.js +++ b/src/bot/common/bot.ts @@ -2,20 +2,16 @@ //---------------------------------------------------------------------------------------------------------------// -'use strict'; +import * as Discord from 'discord.js'; //---------------------------------------------------------------------------------------------------------------// -const Discord = require('discord.js'); - -//---------------------------------------------------------------------------------------------------------------// - -const guild_staff_role_id = process.env.BOT_STAFF_ROLE_ID; -const guild_moderator_role_id = process.env.BOT_MODERATOR_ROLE_ID; -const guild_admin_role_id = process.env.BOT_ADMIN_ROLE_ID; -const guild_team_leaders_role_id = process.env.BOT_TEAM_LEADERS_ROLE_ID; -const guild_directors_role_id = process.env.BOT_DIRECTORS_ROLE_ID; -const guild_founders_role_id = process.env.BOT_FOUNDERS_ROLE_ID; +const guild_staff_role_id = process.env.BOT_STAFF_ROLE_ID as string; +const guild_moderator_role_id = process.env.BOT_MODERATOR_ROLE_ID as string; +const guild_admin_role_id = process.env.BOT_ADMIN_ROLE_ID as string; +const guild_team_leaders_role_id = process.env.BOT_TEAM_LEADERS_ROLE_ID as string; +const guild_directors_role_id = process.env.BOT_DIRECTORS_ROLE_ID as string; +const guild_founders_role_id = process.env.BOT_FOUNDERS_ROLE_ID as string; //---------------------------------------------------------------------------------------------------------------// @@ -43,7 +39,9 @@ const command_permission_levels = { //---------------------------------------------------------------------------------------------------------------// -function getUserPermissionLevel(guild_member) { +function getUserPermissionLevel( + guild_member: Discord.GuildMember +) { let user_permission_level = command_permission_levels.PUBLIC; if (guild_member.roles.cache.has(guild_staff_role_id)) { @@ -75,7 +73,7 @@ function getUserPermissionLevel(guild_member) { //---------------------------------------------------------------------------------------------------------------// -module.exports = { +export { user_is_not_allowed_access_to_command_message_options, command_permission_levels, getUserPermissionLevel, diff --git a/src/bot/common/message.js b/src/bot/common/message.ts similarity index 75% rename from src/bot/common/message.js rename to src/bot/common/message.ts index 7536500d..b813cbe2 100644 --- a/src/bot/common/message.js +++ b/src/bot/common/message.ts @@ -2,20 +2,14 @@ //---------------------------------------------------------------------------------------------------------------// -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - -const { Discord } = require('../discord_client.js'); +import { Discord } from '../discord_client.js'; //---------------------------------------------------------------------------------------------------------------// /** * Disables all message components on a message. - * @param {Discord.Message} message - * @returns {Promise} */ - function disableMessageComponents(message) { +function disableMessageComponents(message: Discord.Message): Promise { if (!(message instanceof Discord.Message)) throw new TypeError('message must be an instance of Discord.Message'); return message.fetch(true).then(message => message.edit({ @@ -26,7 +20,7 @@ const { Discord } = require('../discord_client.js'); ...component.toJSON(), disabled: true, })), - })), + })) as unknown as Discord.MessageActionRow[], })); } diff --git a/src/bot/discord_client.js b/src/bot/discord_client.ts similarity index 89% rename from src/bot/discord_client.js rename to src/bot/discord_client.ts index 6dd6a091..4066ea06 100644 --- a/src/bot/discord_client.js +++ b/src/bot/discord_client.ts @@ -2,11 +2,7 @@ //---------------------------------------------------------------------------------------------------------------// -'use strict'; - -//---------------------------------------------------------------------------------------------------------------// - -const Discord = require('discord.js'); +import * as Discord from 'discord.js'; //---------------------------------------------------------------------------------------------------------------// @@ -42,7 +38,11 @@ const client = new Discord.Client({ }, ], }, -}); +}) as Discord.Client & { + $: { + [key: string]: unknown; + }, +}; client.$ = { commands: new Discord.Collection(), @@ -56,7 +56,7 @@ client.login(process.env.BOT_TOKEN); //---------------------------------------------------------------------------------------------------------------// -module.exports = { +export { Discord, client, }; diff --git a/src/bot/interactions/buttons/display_support_ticket_database_documents.js b/src/bot/interactions/buttons/display_support_ticket_database_documents.ts similarity index 81% rename from src/bot/interactions/buttons/display_support_ticket_database_documents.js rename to src/bot/interactions/buttons/display_support_ticket_database_documents.ts index 971f4b4f..a87b98b8 100644 --- a/src/bot/interactions/buttons/display_support_ticket_database_documents.js +++ b/src/bot/interactions/buttons/display_support_ticket_database_documents.ts @@ -6,29 +6,29 @@ //---------------------------------------------------------------------------------------------------------------// -const Discord = require('discord.js'); +import * as Discord from 'discord.js'; //---------------------------------------------------------------------------------------------------------------// -const { go_mongo_db } = require('../../../mongo/mongo.js'); +import { go_mongo_db } from '../../../mongo/mongo.js'; //---------------------------------------------------------------------------------------------------------------// module.exports = { identifier: 'display_support_ticket_database_documents', - /** @param {Discord.ButtonInteraction} interaction */ - async execute(interaction) { + async execute( + interaction: Discord.ButtonInteraction + ) { if (!interaction.inCachedGuild()) return; await interaction.deferReply({ ephemeral: true }); - /** @type {Discord.TextChannel} */ - const channel = interaction.channel; + const channel = interaction.channel! as Discord.TextChannel; const support_ticket_owner_id = channel.name.match(/(?!.*\-)?([0-9])+/i)?.[0]; /* check if the user is blacklisted */ - const [ db_blacklisted_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME, { + const [ db_blacklisted_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_BLACKLISTED_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': support_ticket_owner_id, }, { projection: { @@ -41,7 +41,7 @@ module.exports = { new Discord.MessageEmbed({ color: 0xFF0000, author: { - iconURL: `${interaction.client.user.displayAvatarURL({ dynamic: true })}`, + iconURL: `${interaction.client.user!.displayAvatarURL({ dynamic: true })}`, name: 'Inertia Lighting | Blacklist System', }, description: [ @@ -60,7 +60,7 @@ module.exports = { } /* send the user document */ - const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': support_ticket_owner_id, }, { projection: { @@ -72,7 +72,7 @@ module.exports = { new Discord.MessageEmbed({ color: 0x60A0FF, author: { - iconURL: `${interaction.client.user.displayAvatarURL({ dynamic: true })}`, + iconURL: `${interaction.client.user!.displayAvatarURL({ dynamic: true })}`, name: 'Inertia Lighting | User Document', }, title: 'This embed is for our support staff.', diff --git a/src/bot/interactions/buttons/welcome_message_captcha_button.ts b/src/bot/interactions/buttons/welcome_message_captcha_button.ts new file mode 100644 index 00000000..70090ae8 --- /dev/null +++ b/src/bot/interactions/buttons/welcome_message_captcha_button.ts @@ -0,0 +1,119 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ + +//---------------------------------------------------------------------------------------------------------------// + +'use strict'; + +//---------------------------------------------------------------------------------------------------------------// + +import { Timer } from '../../../utilities'; + +import { Discord, client } from '../../discord_client.js'; + +//---------------------------------------------------------------------------------------------------------------// + +const bot_guild_id = process.env.BOT_GUILD_ID as string; +const new_server_member_role_ids = (process.env.BOT_SERVER_MEMBER_AUTO_ROLE_IDS as string).split(','); +const new_to_the_server_role_ids = (process.env.BOT_NEW_TO_THE_SERVER_AUTO_ROLE_IDS as string).split(','); + +//---------------------------------------------------------------------------------------------------------------// + +module.exports = { + identifier: 'welcome_message_captcha_button', + async execute(interaction: Discord.ButtonInteraction) { + interaction.deferUpdate(); + + const guild = client.guilds.cache.get(bot_guild_id)!; + const member = await guild.members.fetch(interaction.user.id).catch(() => null); + + if (!(member instanceof Discord.GuildMember)) { + console.warn(`Unable to fetch member from user: ${interaction.user.id}; skipping...`); + return; + } + + const welcome_message = await interaction.channel!.messages.fetch(interaction.message.id); + const user_from_welcome_message = welcome_message.mentions.users.first(); + + if (!(user_from_welcome_message instanceof Discord.User)) { + console.warn(`Unable to fetch member from welcome message: ${interaction.message.id}; skipping...`); + return; + } + + if (user_from_welcome_message.id !== member.id) { + await interaction.followUp({ + ephemeral: true, + content: 'You are not the member mentioned in the welcome message.', + }).catch(console.warn); + return; + } + + /* give new-server-member roles to the user */ + try { + await member.roles.add(new_server_member_role_ids); + } catch (error) { + console.trace('Failed to give new-server-member roles to the member:', error); + } + + /* wait 1 second to avoid any potential race conditions */ + await Timer(1_000); + + /* remove the new-to-the-server roles from the user */ + try { + await member.roles.remove(new_to_the_server_role_ids); + } catch (error) { + console.trace('Failed to remove new-to-the-server roles from the member:', error); + } + + /* welcome the user to the server */ + await interaction.editReply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'Welcome to Inertia Lighting!', + description: [ + 'Thank you for joining our server, and welcome to what\'s possible!', + '', + 'Check out our product hub to purchase our products using Robux!', + 'Alternatively, you can make a purchase using PayPal on our website!', + '', + 'If you\'re here to verify your roblox account using a code', + 'from our product hub, please continue in <#601972296185282571>.', + ].join('\n'), + }), + ], + components: [ + { + type: 1, + components: [ + { + type: 2, + style: 5, + label: 'Our Products', + url: 'https://inertia.lighting/products', + }, { + type: 2, + style: 5, + label: 'Product Hub', + url: 'https://product-hub.inertia.lighting/', + }, { + type: 2, + style: 5, + label: 'F.A.Q.', + url: 'https://inertia.lighting/faq', + }, { + type: 2, + style: 5, + label: 'Privacy Policy', + url: 'https://inertia.lighting/privacy', + }, { + type: 2, + style: 5, + label: 'Terms of Service', + url: 'https://discord.com/channels/601889649601806336/941368100933234700', + }, + ], + }, + ], + }); + }, +}; diff --git a/src/bot/interactions/context_menus/user_profile.js b/src/bot/interactions/context_menus/user_profile.ts similarity index 77% rename from src/bot/interactions/context_menus/user_profile.js rename to src/bot/interactions/context_menus/user_profile.ts index 7a17bcaf..d82b9e01 100644 --- a/src/bot/interactions/context_menus/user_profile.js +++ b/src/bot/interactions/context_menus/user_profile.ts @@ -6,23 +6,22 @@ //---------------------------------------------------------------------------------------------------------------// -const { - Discord, -} = require('../../discord_client.js'); +import { Discord } from '../../discord_client.js'; -const { userProfileHandler } = require('../../handlers/user_profile_handler.js'); +import { userProfileHandler } from '../../handlers/user_profile_handler.js'; //---------------------------------------------------------------------------------------------------------------// module.exports = { identifier: 'User Profile', - /** @param {Discord.ContextMenuInteraction} interaction */ - async execute(interaction) { + async execute( + interaction: Discord.ContextMenuInteraction + ) { if (!interaction.inCachedGuild()) return; await interaction.deferReply({ ephemeral: true }); - const user = interaction.options.resolved.users.first(); + const user = interaction.options.resolved.users!.first(); if (!user) { return interaction.editReply({ diff --git a/src/bot/interactions/message_commands/manage_karma.js b/src/bot/interactions/message_commands/manage_karma.ts similarity index 90% rename from src/bot/interactions/message_commands/manage_karma.js rename to src/bot/interactions/message_commands/manage_karma.ts index d1133bbe..06fab76c 100644 --- a/src/bot/interactions/message_commands/manage_karma.js +++ b/src/bot/interactions/message_commands/manage_karma.ts @@ -6,22 +6,19 @@ //---------------------------------------------------------------------------------------------------------------// -const { Discord, client } = require('../../discord_client.js'); +import { Discord, client } from '../../discord_client.js'; -const { go_mongo_db } = require('../../../mongo/mongo.js'); +import { go_mongo_db } from '../../../mongo/mongo.js'; -const { - command_permission_levels, - getUserPermissionLevel, - user_is_not_allowed_access_to_command_message_options, -} = require('../../common/bot.js'); +import { command_permission_levels, getUserPermissionLevel, user_is_not_allowed_access_to_command_message_options } from '../../common/bot.js'; //---------------------------------------------------------------------------------------------------------------// module.exports = { identifier: 'manage_karma', - /** @param {Discord.AutocompleteInteraction|Discord.CommandInteraction} interaction */ - async execute(interaction) { + async execute( + interaction: Discord.AutocompleteInteraction | Discord.CommandInteraction<'cached'> + ) { if (!interaction.isCommand()) return; await interaction.deferReply(); @@ -41,7 +38,7 @@ module.exports = { const reason = interaction.options.getString('reason', true) || 'No reason was specified.'; /* find the user in the database */ - const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': user_to_modify.id, }, { projection: { @@ -139,7 +136,7 @@ module.exports = { } try { - await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': db_user_data.identity.discord_user_id, 'identity.roblox_user_id': db_user_data.identity.roblox_user_id, }, { @@ -155,7 +152,7 @@ module.exports = { new Discord.MessageEmbed({ color: 0xFF0000, author: { - iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + iconURL: `${client.user!.displayAvatarURL({ dynamic: true })}`, name: 'Inertia Lighting | Karma System', }, description: 'An error occurred while modifying the user\'s karma!', @@ -177,7 +174,7 @@ module.exports = { 0x60A0FF ), author: { - iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + iconURL: `${client.user!.displayAvatarURL({ dynamic: true })}`, name: 'Inertia Lighting | Karma System', }, description: [ diff --git a/src/bot/interactions/message_commands/manage_products.js b/src/bot/interactions/message_commands/manage_products.ts similarity index 86% rename from src/bot/interactions/message_commands/manage_products.js rename to src/bot/interactions/message_commands/manage_products.ts index 9fcf8958..1f0ddfc4 100644 --- a/src/bot/interactions/message_commands/manage_products.js +++ b/src/bot/interactions/message_commands/manage_products.ts @@ -2,29 +2,26 @@ //---------------------------------------------------------------------------------------------------------------// -'use strict'; +import { DbProductData, DbUserData } from '@root/types/types.js'; -//---------------------------------------------------------------------------------------------------------------// - -const stringSimilarity = require('string-similarity'); +import { compareTwoStrings } from 'string-similarity'; -const { go_mongo_db } = require('../../../mongo/mongo.js'); +import { go_mongo_db } from '../../../mongo/mongo.js'; -const { - Discord, -} = require('../../discord_client.js'); +import { Discord } from '../../discord_client.js'; //---------------------------------------------------------------------------------------------------------------// -const database_support_staff_role_id = process.env.BOT_SUPPORT_STAFF_DATABASE_ROLE_ID; +const database_support_staff_role_id = process.env.BOT_SUPPORT_STAFF_DATABASE_ROLE_ID as string; //---------------------------------------------------------------------------------------------------------------// module.exports = { identifier: 'manage_products', - /** @param {Discord.AutocompleteInteraction|Discord.CommandInteraction} interaction */ - async execute(interaction) { - const db_roblox_products = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_PRODUCTS_COLLECTION_NAME, {}); + async execute( + interaction: Discord.AutocompleteInteraction | Discord.CommandInteraction + ) { + const db_roblox_products = (await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_PRODUCTS_COLLECTION_NAME as string, {})) as unknown[] as DbProductData[]; if (interaction.isAutocomplete()) { const user_id_to_modify = interaction.options.get('for')?.value; @@ -35,13 +32,13 @@ module.exports = { const search_query = focused_option.toUpperCase(); /* find the user in the database */ - const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + const [ db_user_data ] = (await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': user_id_to_modify, }, { projection: { '_id': false, }, - }); + })) as unknown[] as DbUserData[]; if (!db_user_data) { return interaction.respond([]); @@ -59,7 +56,7 @@ module.exports = { for (const db_roblox_product of filtered_db_roblox_products) { mapped_db_roblox_products.push({ ...db_roblox_product, - similarity_score: stringSimilarity.compareTwoStrings(search_query, db_roblox_product.code), + similarity_score: compareTwoStrings(search_query, db_roblox_product.code), }); } @@ -67,7 +64,7 @@ module.exports = { (a, b) => b.similarity_score - a.similarity_score ).sort( (a, b) => { - const first_char_of_query = search_query.at(0); + const first_char_of_query: string = search_query.at(0)!; if (a.code.startsWith(first_char_of_query) === b.code.startsWith(first_char_of_query)) return a.code.localeCompare(b.code); if (a.code.startsWith(first_char_of_query)) return -1; @@ -94,7 +91,7 @@ module.exports = { } else if (interaction.isCommand()) { await interaction.deferReply(); - const interaction_guild_member = await interaction.guild.members.fetch(interaction.user.id); + const interaction_guild_member = await interaction.guild!.members.fetch(interaction.user.id); /* check if the user is allowed to use this command */ if (!interaction_guild_member.roles.cache.has(database_support_staff_role_id)) { @@ -117,7 +114,7 @@ module.exports = { const reason = interaction.options.getString('reason', true) || 'No reason was specified.'; /* find the user in the database */ - const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + const [ db_user_data ] = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': user_to_modify.id, }, { projection: { @@ -157,7 +154,7 @@ module.exports = { } try { - await go_mongo_db.update(process.env.MONGO_DATABASE_NAME, process.env.MONGO_USERS_COLLECTION_NAME, { + await go_mongo_db.update(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_USERS_COLLECTION_NAME as string, { 'identity.discord_user_id': db_user_data.identity.discord_user_id, 'identity.roblox_user_id': db_user_data.identity.roblox_user_id, }, { @@ -181,7 +178,7 @@ module.exports = { return; } - const logging_channel = await interaction.guild.channels.fetch(process.env.BOT_LOGGING_PRODUCTS_MANAGER_CHANNEL_ID); + const logging_channel = (await interaction.guild!.channels.fetch(process.env.BOT_LOGGING_PRODUCTS_MANAGER_CHANNEL_ID as string)) as Discord.TextBasedChannel; logging_channel.send({ embeds: [ new Discord.MessageEmbed({ diff --git a/src/bot/interactions/message_commands/quick_support.js b/src/bot/interactions/message_commands/quick_support.ts similarity index 70% rename from src/bot/interactions/message_commands/quick_support.js rename to src/bot/interactions/message_commands/quick_support.ts index 1931fa60..f69d8b26 100644 --- a/src/bot/interactions/message_commands/quick_support.js +++ b/src/bot/interactions/message_commands/quick_support.ts @@ -6,45 +6,45 @@ //---------------------------------------------------------------------------------------------------------------// -const stringSimilarity = require('string-similarity'); +import { compareTwoStrings } from 'string-similarity'; -const { array_random } = require('../../../utilities.js'); -const { go_mongo_db } = require('../../../mongo/mongo.js'); +import { array_random } from '../../../utilities.js'; +import { go_mongo_db } from '../../../mongo/mongo.js'; -const { Discord, client } = require('../../discord_client.js'); +import { Discord, client } from '../../discord_client.js'; //---------------------------------------------------------------------------------------------------------------// -/** - * @typedef {{ - * id: string, - * title: string, - * searchable_queries: string[], - * support_contents: string, - * }} QuickSupportTopic - * @typedef {QuickSupportTopic[]} QuickSupportTopics - */ +type QuickSupportTopic = { + id: string, + title: string, + searchable_queries: string[], + support_contents: string, +}; + +type QuickSupportTopics = QuickSupportTopic[]; //---------------------------------------------------------------------------------------------------------------// module.exports = { identifier: 'quick_support', /** @param {Discord.AutocompleteInteraction|Discord.CommandInteraction} interaction */ - async execute(interaction) { + async execute( + interaction: Discord.AutocompleteInteraction | Discord.CommandInteraction, + ) { if (interaction.isAutocomplete()) { const search_query = interaction.options.getFocused(); - /** @type {QuickSupportTopics} */ - const qs_topics = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME, {}); + const qs_topics = (await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME as string, {})) as unknown as QuickSupportTopics; const mapped_qs_topics = []; for (const qs_topic of qs_topics) { let similarity_score_total = 0; for (const searchable_query of qs_topic.searchable_queries) { - similarity_score_total += stringSimilarity.compareTwoStrings(search_query, searchable_query); + similarity_score_total += compareTwoStrings(search_query, searchable_query); } - similarity_score_total += stringSimilarity.compareTwoStrings(search_query, qs_topic.title) * 1.20; // multiplied for weighted value + similarity_score_total += compareTwoStrings(search_query, qs_topic.title) * 1.20; // multiplied for weighted value const similarity_score_average = similarity_score_total / qs_topic.searchable_queries.length; @@ -61,7 +61,7 @@ module.exports = { }); // eslint-disable-next-line no-inner-declarations - function generateRandomQuickSupportTopic() { + function generateRandomQuickSupportTopic(): QuickSupportTopic { const random_qs_topic = array_random(qs_topics); const already_matched_qs_topic = matching_qs_topics.find(matching_qs_topic => matching_qs_topic.id === random_qs_topic?.id); @@ -87,10 +87,9 @@ module.exports = { const quick_support_topic_id = interaction.options.get('topic', true)?.value; - /** @type {QuickSupportTopics} */ - const qs_topics = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME, {}); + const qs_topics: QuickSupportTopics = await go_mongo_db.find(process.env.MONGO_DATABASE_NAME as string, process.env.MONGO_QUICK_SUPPORT_TOPICS_COLLECTION_NAME as string, {}) as unknown as QuickSupportTopics; - const quick_support_topic = qs_topics.find(qs_topic => qs_topic.id === quick_support_topic_id); + const quick_support_topic = qs_topics.find((qs_topic) => qs_topic.id === quick_support_topic_id); if (!quick_support_topic) { interaction.followUp({ @@ -109,7 +108,7 @@ module.exports = { new Discord.MessageEmbed({ color: 0x60A0FF, author: { - iconURL: `${client.user.displayAvatarURL({ dynamic: true })}`, + iconURL: `${client.user!.displayAvatarURL({ dynamic: true })}`, name: 'Inertia Lighting | Quick Support System', }, title: `${quick_support_topic.title}`, diff --git a/src/bot/interactions/message_commands/timeout.ts b/src/bot/interactions/message_commands/timeout.ts new file mode 100644 index 00000000..166390f6 --- /dev/null +++ b/src/bot/interactions/message_commands/timeout.ts @@ -0,0 +1,138 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ + +//---------------------------------------------------------------------------------------------------------------// + +import * as Discord from 'discord.js'; + +import { logModerationActionToDatabase } from '../../handlers/log_moderation_action_handler.js'; + +import { command_permission_levels, getUserPermissionLevel, user_is_not_allowed_access_to_command_message_options } from '../../common/bot.js'; + +//---------------------------------------------------------------------------------------------------------------// + +module.exports = { + identifier: 'timeout', + async execute(interaction: Discord.CommandInteraction<'cached'>) { + if (!interaction.isCommand()) return; + + await interaction.deferReply(); + + const interaction_guild_member = await interaction.guild.members.fetch(interaction.user.id); + + const user_permission_level = getUserPermissionLevel(interaction_guild_member); + + if (user_permission_level < command_permission_levels.MODERATORS) { + interaction.editReply(user_is_not_allowed_access_to_command_message_options).catch(console.warn); + return; // user is not allowed to access this command + } + const staff_member = interaction_guild_member; + + /** @type {GuildMember} */ + const member = await interaction.guild.members.fetch({ + user: interaction.options.getMember('member', true), + limit: 1, + }); + const duration = interaction.options.getInteger('duration', true); // in milliseconds + const reason = interaction.options.getString('reason', false) || 'no reason was specified'; + + /* handle when a staff member specifies themself */ + if (staff_member.id === member.id) { + await interaction.editReply({ + embeds: [ + { + color: 0xFFFF00, + description: 'You aren\'t allowed to timeout yourself!', + }, + ], + }).catch(console.warn); + return; + } + + /* handle when a staff member specifies this bot */ + if (member.id === interaction.client.user?.id) { + await interaction.editReply({ + embeds: [ + { + color: 0xFFFF00, + description: 'You aren\'t allowed to timeout me!', + }, + ], + }).catch(console.warn); + return; + } + + /* handle when a staff member specifies the guild owner */ + if (member.id === interaction.guild.ownerId) { + await interaction.editReply({ + embeds: [ + { + color: 0xFFFF00, + description: 'You aren\'t allowed to timeout the owner of this server!', + }, + ], + }); + return; + } + + /* handle when a staff member tries to moderate someone with an equal/higher role */ + if (staff_member.roles.highest.comparePositionTo(member.roles.highest) <= 0) { + await interaction.editReply({ + embeds: [ + { + color: 0xFFFF00, + description: 'You aren\'t allowed to timeout someone with an equal/higher role!', + }, + ], + }).catch(console.warn); + return; + } + + try { + await member.timeout(duration, reason); + } catch (error) { + console.trace(error); + + await interaction.editReply({ + embeds: [ + { + color: 0xFF0000, + description: 'An error occurred while trying to timeout this user!', + }, + ], + }).catch(console.warn); + + return; + } + + const moderation_message_options = { + content: [ + `${member}`, + `You were put in timeout by ${staff_member} for ${duration / 60_000} minutes for:`, + '\`\`\`', + `${reason}`, + '\`\`\`', + ].join('\n'), + }; + + /* dm the member */ + try { + const dm_channel = await interaction.client.users.createDM(member.id); + await dm_channel.send(moderation_message_options); + } catch { + // ignore any errors + } + + /* message the member in the server */ + await interaction.editReply(moderation_message_options).catch(console.warn); + + /* log to the database */ + await logModerationActionToDatabase({ + discord_user_id: member.id, + }, { + type: 'TIMEOUT', + epoch: Date.now(), + reason: `${reason} (duration: ${duration / 60_000} minutes)`, + staff_member_id: staff_member.id, + }); + }, +}; diff --git a/src/bot/interactions/select_menus/automatic_roles_menu.ts b/src/bot/interactions/select_menus/automatic_roles_menu.ts new file mode 100644 index 00000000..e7cbfd16 --- /dev/null +++ b/src/bot/interactions/select_menus/automatic_roles_menu.ts @@ -0,0 +1,60 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ + +//---------------------------------------------------------------------------------------------------------------// + +import { Discord } from '../../discord_client.js'; + +//---------------------------------------------------------------------------------------------------------------// + +const allowed_role_ids: string[] = [ + '835003401812574228', // Outage Announcements + '835003393734737952', // Product Announcements + '835003400882094090', // Community Announcements + '891339307527335936', // Survey Announcements + '914540830994358294', // Event Announcements + '835011400086716426', // Misc Announcements +]; + +//---------------------------------------------------------------------------------------------------------------// + +module.exports = { + identifier: 'automatic_roles_menu', + /** @param {Discord.SelectMenuInteraction} interaction */ + async execute(interaction: Discord.SelectMenuInteraction) { + if (!interaction.inCachedGuild()) return; + + await interaction.deferReply({ ephemeral: true }); + + const guild_member = await interaction.guild.members.fetch(interaction.user.id); + + const supplied_role_ids = interaction.values; + + const roles_to_add = allowed_role_ids.filter(role_id => supplied_role_ids.includes(role_id)); + const roles_to_remove = allowed_role_ids.filter(role_id => !supplied_role_ids.includes(role_id)); + + try { + if (roles_to_add.length > 0) { + await guild_member.roles.add(roles_to_add); + } + if (roles_to_remove.length > 0) { + await guild_member.roles.remove(roles_to_remove); + } + } catch (error) { + console.trace(error); + return; + } + + await interaction.editReply({ + embeds: [ + new Discord.MessageEmbed({ + color: 0x60A0FF, + title: 'Automatic Roles', + description: [ + 'Your roles have been updated to be the following:', + ...roles_to_add.map(role_id => `- <@&${role_id}>`), + ].join('\n'), + }), + ], + }); + }, +}; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..0df55298 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,30 @@ +/* Copyright © Inertia Lighting | All Rights Reserved */ + +//---------------------------------------------------------------------------------------------------------------// + +// eslint-disable-next-line no-unused-expressions +require('module-alias/register'); + +// eslint-disable-next-line no-unused-expressions +require('dotenv').config(); + +//---------------------------------------------------------------------------------------------------------------// + +/* prevent the script from crashing for unhandledRejections */ +process.on('unhandledRejection', (reason, promise) => { + console.error('----------------------------------------------------------------------------------------------------------------'); + console.trace('unhandledRejection at:', reason, promise); + console.error('----------------------------------------------------------------------------------------------------------------'); +}); + +/* prevent the script from crashing for uncaughtExceptions */ +process.on('uncaughtException', (error) => { + console.error('----------------------------------------------------------------------------------------------------------------'); + console.trace('uncaughtException at:', error); + console.error('----------------------------------------------------------------------------------------------------------------'); +}); + +//---------------------------------------------------------------------------------------------------------------// + +// eslint-disable-next-line no-unused-expressions +require('./bot/bot.js'); diff --git a/src/mongo/mongo.js b/src/mongo/mongo.ts similarity index 71% rename from src/mongo/mongo.js rename to src/mongo/mongo.ts index 8a9e8176..49e365fe 100644 --- a/src/mongo/mongo.js +++ b/src/mongo/mongo.ts @@ -2,18 +2,14 @@ //---------------------------------------------------------------------------------------------------------------// -'use strict'; +import { GoMongoDB } from 'go-mongo-db'; //---------------------------------------------------------------------------------------------------------------// -const { GoMongoDB } = require('go-mongo-db'); +const go_mongo_db = new GoMongoDB(process.env.MONGO_CONNECTION_URL as string); //---------------------------------------------------------------------------------------------------------------// -const go_mongo_db = new GoMongoDB(process.env.MONGO_CONNECTION_URL); - -//---------------------------------------------------------------------------------------------------------------// - -module.exports = { +export { go_mongo_db, }; diff --git a/src/types/types.d.ts b/src/types/types.d.ts new file mode 100644 index 00000000..51b9b2d8 --- /dev/null +++ b/src/types/types.d.ts @@ -0,0 +1,84 @@ +//------------------------------------------------------------// +// Copyright (c) Inertia Lighting, Some Rights Reserved // +//------------------------------------------------------------// + +import type MongoDB from 'mongodb'; + +//------------------------------------------------------------// +// Database Schemas // +//------------------------------------------------------------// + +export interface DbProductData { + _id: MongoDB.ObjectId; + roblox_product_id: string; + public: boolean; + /** @deprecated */ + old_code: string; + code: string; + name: string; + description: string; + price_in_usd: string; + price_in_robux: number; + roblox_assets: { + product_preview_image?: string; + }; + sorting_priority: number; + tags: string[]; + supporter_perk: boolean; +} + +//------------------------------------------------------------// + +export interface DbUserIdentity { + discord_user_id: string; + roblox_user_id: string; +} + +export interface DbUserProducts { + [product_code: string]: boolean; +} + +export interface DbUserData { + _id: MongoDB.ObjectId; + identity: DbUserIdentity; + karma: number; + products: DbUserProducts; +} + +//------------------------------------------------------------// + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DbBlacklistedUserIdentity extends DbUserIdentity {} + +export interface DbBlacklistedUserRecord { + _id: MongoDB.ObjectId; + identity: DbBlacklistedUserIdentity; + reason: string; + epoch: number; + staff_member_id: string; +} + +//------------------------------------------------------------// + +export interface DbPendingVerificationData { + _id: MongoDB.ObjectId; + identity: Partial; + code: string; + creation_epoch: number; +} + +//------------------------------------------------------------// + +export interface DbRobloxPurchaseRecord { + _id: MongoDB.ObjectId; + roblox_user_id: string; + roblox_purchase_id: string; + product_codes: string[]; +} + +export interface DbPayPalPurchaseRecord { + _id: MongoDB.ObjectId; + paypal_order_id: string; + discord_user_id: string; + product_codes: string[]; +} diff --git a/src/utilities.js b/src/utilities.ts similarity index 68% rename from src/utilities.js rename to src/utilities.ts index 73968d30..63800bd8 100644 --- a/src/utilities.js +++ b/src/utilities.ts @@ -6,12 +6,16 @@ //---------------------------------------------------------------------------------------------------------------// +type ObjectWithKeys = { + [key: string]: unknown; +}; + +//---------------------------------------------------------------------------------------------------------------// + /** * Asynchronous setTimeout - * @param {Number} time_in_milliseconds - * @returns {Promise} */ -function Timer(time_in_milliseconds) { +export function Timer(time_in_milliseconds: number): Promise { if (typeof time_in_milliseconds !== 'number') throw new TypeError('\`time_in_milliseconds\` must be a number'); return new Promise((resolve, reject) => setTimeout(() => resolve(), time_in_milliseconds)); @@ -19,11 +23,8 @@ function Timer(time_in_milliseconds) { /** * Generates a random integer in an inclusive range: min <= return_value <= max - * @param {Number} min - * @param {Number} max - * @returns {Number} */ -function random_range_inclusive(min, max) { +export function random_range_inclusive(min: number, max: number): number { if (typeof min !== 'number') throw new TypeError('\`min\` must be a number!'); if (typeof max !== 'number') throw new TypeError('\`max\` must be a number!'); @@ -32,12 +33,12 @@ function random_range_inclusive(min, max) { /** * Ellipses a string to a specified length (including the ellipses) - * @param {String} string_to_ellipses - * @param {Number} output_length_limit by default `Number.MAX_SAFE_INTEGER` - * @param {String} ellipses by default `'...'` - * @returns {String} */ -function string_ellipses(string_to_ellipses, output_length_limit=Number.MAX_SAFE_INTEGER, ellipses='...') { +export function string_ellipses( + string_to_ellipses: string, + output_length_limit: number = Number.MAX_SAFE_INTEGER, + ellipses: string = '...' +): string { if (typeof string_to_ellipses !== 'string') throw new TypeError('\`string_to_ellipses\` must be a string'); if (typeof output_length_limit !== 'number') throw new TypeError('\`output_length_limit\` must be a number'); if (typeof string_to_ellipses !== 'string') throw new TypeError('\`string_to_ellipses\` must be a string'); @@ -50,15 +51,13 @@ function string_ellipses(string_to_ellipses, output_length_limit=Number.MAX_SAFE /** * Sorts an object based on it's keys (using Array.sort()) and returns the new sorted object - * @param {Object} object_of_things - * @returns {Object} the object sorted by its keys */ -function object_sort(object_of_things) { +export function object_sort(object_of_things: ObjectWithKeys): ObjectWithKeys { if (typeof object_of_things !== 'object' || !object_of_things) throw new TypeError('\`object_of_things\` must be an object'); const sorted_object_keys = Object.keys(object_of_things).sort(); - const sorted_object = {}; + const sorted_object: ObjectWithKeys = {}; for (const sorted_object_key of sorted_object_keys) { sorted_object[sorted_object_key] = object_of_things[sorted_object_key]; } @@ -68,13 +67,13 @@ function object_sort(object_of_things) { /** * Splits an array into a new chunked array - * @param {Array<*>} array_of_things - * @param {Number} chunk_size - * @returns {any[][]} */ -function array_chunks(array_of_things, chunk_size) { +export function array_chunks( + array_of_things: T[], + chunk_size: number +): T[][] { if (!Array.isArray(array_of_things)) throw new TypeError('\`array_of_things\` must be an array'); - if (typeof chunk_size !== 'number' || chunk_size !== Number.parseInt(chunk_size)) throw new TypeError('\`chunk_size\` must be a (whole) number'); + if (typeof chunk_size !== 'number' || chunk_size !== Math.floor(chunk_size)) throw new TypeError('\`chunk_size\` must be a (whole) number'); const array_of_things_clone = [ ...array_of_things ]; // prevent mutation of the original array @@ -88,10 +87,10 @@ function array_chunks(array_of_things, chunk_size) { /** * Fetches a random item from the specified array - * @param {Array<*>} array_of_things - * @returns {*} */ -function array_random(array_of_things) { +export function array_random( + array_of_things: T[] +): T { if (!Array.isArray(array_of_things)) throw new TypeError('\`array_of_things\` must be an array!'); return array_of_things[random_range_inclusive(0, array_of_things.length - 1)]; @@ -99,12 +98,12 @@ function array_random(array_of_things) { /** * Clamps a number between a minimum and maximum value - * @param {number} value - * @param {number} min - * @param {number} max - * @returns {number} the clamped value */ -function math_clamp(value, min, max) { +export function math_clamp( + value: number, + min: number, + max: number +): number { if (typeof value !== 'number') throw new TypeError('\`value\` must be a number'); if (typeof min !== 'number') throw new TypeError('\`min\` must be a number'); if (typeof max !== 'number') throw new TypeError('\`max\` must be a number'); @@ -113,24 +112,10 @@ function math_clamp(value, min, max) { } /** - * @param {number} timestamp timestamp in milliseconds - * @returns {string} base 10 timestamp in seconds + * Returns a valid discord timestamp from a unix timestamp */ -function getMarkdownFriendlyTimestamp(timestamp) { +export function getMarkdownFriendlyTimestamp(timestamp: number): string { if (typeof timestamp !== 'number') throw new TypeError('getMarkdownFriendlyTimestamp(): timestamp is not a number'); return Math.floor(timestamp / 1000).toString(10); } - -//---------------------------------------------------------------------------------------------------------------// - -module.exports = { - Timer, - random_range_inclusive, - string_ellipses, - object_sort, - array_chunks, - array_random, - math_clamp, - getMarkdownFriendlyTimestamp, -}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..03e166ad --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,35 @@ +{ + "defaultSeverity": "error", + "compilerOptions": { + "baseUrl": ".", + "rootDir": "./src", + "outDir": "./dist", + "allowJs": true, + "checkJs": false, + "target": "ESNext", + "module": "CommonJS", + "moduleResolution": "Node", + "resolveJsonModule": true, + "esModuleInterop": true, + "strictNullChecks": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "sourceMap": true, + "declaration": false, + "typeRoots": [ + "@types" + ], + "paths": { + "@root/*": [ "src/*" ], + } + }, + "exclude": [ + "node_modules", + "dist" + ], + "include": [ + "src", + ] +}