diff --git a/backend/package-lock.json b/backend/package-lock.json index bbc5e4e7..e0744d93 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -14,7 +14,7 @@ "cors": "^2.8.5", "cross-env": "^5.2.0", "deep-diff": "^1.0.2", - "discord.js": "^13.0.0-dev.d310e4f.1627560163", + "discord.js": "^13.0.0-dev.t1628078860.90c2e07", "dotenv": "^4.0.0", "emoji-regex": "^8.0.0", "erlpack": "github:discord/erlpack", @@ -81,8 +81,8 @@ "version": "30.0.0-beta.38", "license": "MIT", "dependencies": { - "discord-api-types": "^0.21.0-next.ab1951b.1626870574", - "discord.js": "^13.0.0-dev.4886ae2.1627214570", + "discord-api-types": "^0.18.1", + "discord.js": "github:monbrey/discord.js#9c42f571093b2565df28b756fdca4ac59cad0fe3", "knub-command-manager": "^9.1.0", "ts-essentials": "^6.0.7" }, @@ -161,11 +161,14 @@ } }, "node_modules/@discordjs/builders": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.2.0.tgz", - "integrity": "sha512-TVq7NZBCJrrTRc3CfxOr3IdgY5nrtqVxZ7qDUF1mN6LgxIiOldmFxsSwMrQBzLFVmOwqFyNLKCeblley8UpEuw==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.3.0.tgz", + "integrity": "sha512-yFBPqohVAtCWoDTQCYk5ubgmkiRbGpbiR4RfYGHCmV5S2YZc7j8WzfKVksjuy2o5IWRfXFsW6G2Lr+KpW41pEA==", "dependencies": { - "discord-api-types": "^0.18.1", + "@sindresorhus/is": "^4.0.1", + "discord-api-types": "^0.22.0", + "ow": "^0.26.0", + "ts-mixer": "^5.4.1", "tslib": "^2.3.0" }, "engines": { @@ -173,15 +176,29 @@ "npm": ">=7.0.0" } }, + "node_modules/@discordjs/builders/node_modules/@sindresorhus/is": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", + "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, "node_modules/@discordjs/builders/node_modules/tslib": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" }, "node_modules/@discordjs/collection": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", - "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz", + "integrity": "sha512-vhxqzzM8gkomw0TYRF3tgx7SwElzUlXT/Aa41O7mOcyN6wIJfj5JmDWaO5XGKsGSsNx7F3i5oIlrucCCWV1Nog==", + "engines": { + "node": ">=14.0.0" + } }, "node_modules/@discordjs/form-data": { "version": "3.0.1", @@ -1389,7 +1406,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, "engines": { "node": ">=6" } @@ -2151,41 +2167,33 @@ } }, "node_modules/discord-api-types": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.18.1.tgz", - "integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg==", + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", + "integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==", "engines": { "node": ">=12" } }, "node_modules/discord.js": { - "version": "13.0.0-dev.d310e4f.1627560163", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.d310e4f.1627560163.tgz", - "integrity": "sha512-qJmQrG4xCnBqYF/WQIOxl4IWY3gYAwK0UyNOAKhRpHzMXYHX99wx3FcGaYrZiqtXxGbN2lgVanBakKNsq/uYYw==", + "version": "13.0.0-dev.t1628078860.90c2e07", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.t1628078860.90c2e07.tgz", + "integrity": "sha512-Yet0FjFizVzCZkV2+cxenTh6Y2CzNWnA9BK12gmifSa6GuUJ0o98ptx5jpo+jpaXpwkKooivOCNl3wrulupmzg==", "dependencies": { - "@discordjs/builders": "^0.2.0", - "@discordjs/collection": "^0.1.6", + "@discordjs/builders": "^0.3.0", + "@discordjs/collection": "^0.2.1", "@discordjs/form-data": "^3.0.1", "@sapphire/async-queue": "^1.1.4", "@types/ws": "^7.4.5", "abort-controller": "^3.0.0", - "discord-api-types": "^0.19.0", + "discord-api-types": "^0.22.0", "node-fetch": "^2.6.1", "ws": "^7.5.1" }, "engines": { - "node": ">=14.0.0", + "node": ">=14.6.0", "npm": ">=7.0.0" } }, - "node_modules/discord.js/node_modules/discord-api-types": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.19.0.tgz", - "integrity": "sha512-t2HKLd43Lbe+rf+ffYfKVv9Kk5f6p7sFqvO6CMV55ZB0PgZv8WigCkt9FoJciYo5S3Q6CGYK+WnE/ZG+6vkBDQ==", - "engines": { - "node": ">=12" - } - }, "node_modules/dot-prop": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.2.0.tgz", @@ -2277,6 +2285,7 @@ "version": "0.1.3", "resolved": "git+ssh://git@github.com/discord/erlpack.git#e27db8f82892bdb9b28a0547cc394d68b5d2242d", "integrity": "sha512-uDE+ma9xOMfF4ncJHoymBWA084DqoO8q/hBDvGx4WUxmvFQfHoCsk3BYk1D1Lei/lhNCZXLf1vkeNYVBSqrSgw==", + "hasInstallScript": true, "license": "MIT", "dependencies": { "bindings": "^1.5.0", @@ -3106,7 +3115,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true, "engines": { "node": ">=8" } @@ -3961,6 +3969,61 @@ "node": ">=0.10.0" } }, + "node_modules/ow": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/ow/-/ow-0.26.0.tgz", + "integrity": "sha512-22YUQW9d6oUSCpIQuBV25djtC1uMtpWqmtUYnuh2UHWeNMpppCFCvq3eSBIWWMDbe2UVq26kWYvBHDzOIu5NYg==", + "dependencies": { + "@sindresorhus/is": "^4.0.1", + "callsites": "^3.1.0", + "dot-prop": "^6.0.1", + "lodash.isequal": "^4.5.0", + "type-fest": "^1.2.1", + "vali-date": "^1.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ow/node_modules/@sindresorhus/is": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", + "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/ow/node_modules/dot-prop": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", + "integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", + "dependencies": { + "is-obj": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ow/node_modules/type-fest": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.3.0.tgz", + "integrity": "sha512-mYUYkAy6fPatVWtUeCV/qGeGL3IVucmdJOzeAEfwgCJDx8gP0JaW8jn6KQ5xDfPec31e0KXWn5EUOZMhquR1zA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/p-cancelable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", @@ -5428,6 +5491,11 @@ "node": ">=0.10.0" } }, + "node_modules/ts-mixer": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-5.4.1.tgz", + "integrity": "sha512-Zo9HgPCtNouDgJ+LGtrzVOjSg8+7WGQktIKLwAfaNrlOK1mWGlz1ejsAF/YqUEqAGjUTeB5fEg8gH9Aui6w9xA==" + }, "node_modules/tsc-watch": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tsc-watch/-/tsc-watch-4.0.0.tgz", @@ -5903,6 +5971,14 @@ "uuid": "bin/uuid" } }, + "node_modules/vali-date": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz", + "integrity": "sha1-G5BKWWCfsyjvB4E4Qgk09rhnCaY=", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -6437,14 +6513,22 @@ } }, "@discordjs/builders": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.2.0.tgz", - "integrity": "sha512-TVq7NZBCJrrTRc3CfxOr3IdgY5nrtqVxZ7qDUF1mN6LgxIiOldmFxsSwMrQBzLFVmOwqFyNLKCeblley8UpEuw==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.3.0.tgz", + "integrity": "sha512-yFBPqohVAtCWoDTQCYk5ubgmkiRbGpbiR4RfYGHCmV5S2YZc7j8WzfKVksjuy2o5IWRfXFsW6G2Lr+KpW41pEA==", "requires": { - "discord-api-types": "^0.18.1", + "@sindresorhus/is": "^4.0.1", + "discord-api-types": "^0.22.0", + "ow": "^0.26.0", + "ts-mixer": "^5.4.1", "tslib": "^2.3.0" }, "dependencies": { + "@sindresorhus/is": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", + "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==" + }, "tslib": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", @@ -6453,9 +6537,9 @@ } }, "@discordjs/collection": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", - "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.2.1.tgz", + "integrity": "sha512-vhxqzzM8gkomw0TYRF3tgx7SwElzUlXT/Aa41O7mOcyN6wIJfj5JmDWaO5XGKsGSsNx7F3i5oIlrucCCWV1Nog==" }, "@discordjs/form-data": { "version": "3.0.1", @@ -7442,8 +7526,7 @@ "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==" }, "camelcase": { "version": "5.3.1", @@ -8029,31 +8112,24 @@ } }, "discord-api-types": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.18.1.tgz", - "integrity": "sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg==" + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.22.0.tgz", + "integrity": "sha512-l8yD/2zRbZItUQpy7ZxBJwaLX/Bs2TGaCthRppk8Sw24LOIWg12t9JEreezPoYD0SQcC2htNNo27kYEpYW/Srg==" }, "discord.js": { - "version": "13.0.0-dev.d310e4f.1627560163", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.d310e4f.1627560163.tgz", - "integrity": "sha512-qJmQrG4xCnBqYF/WQIOxl4IWY3gYAwK0UyNOAKhRpHzMXYHX99wx3FcGaYrZiqtXxGbN2lgVanBakKNsq/uYYw==", + "version": "13.0.0-dev.t1628078860.90c2e07", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-13.0.0-dev.t1628078860.90c2e07.tgz", + "integrity": "sha512-Yet0FjFizVzCZkV2+cxenTh6Y2CzNWnA9BK12gmifSa6GuUJ0o98ptx5jpo+jpaXpwkKooivOCNl3wrulupmzg==", "requires": { - "@discordjs/builders": "^0.2.0", - "@discordjs/collection": "^0.1.6", + "@discordjs/builders": "^0.3.0", + "@discordjs/collection": "^0.2.1", "@discordjs/form-data": "^3.0.1", "@sapphire/async-queue": "^1.1.4", "@types/ws": "^7.4.5", "abort-controller": "^3.0.0", - "discord-api-types": "^0.19.0", + "discord-api-types": "^0.22.0", "node-fetch": "^2.6.1", "ws": "^7.5.1" - }, - "dependencies": { - "discord-api-types": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.19.0.tgz", - "integrity": "sha512-t2HKLd43Lbe+rf+ffYfKVv9Kk5f6p7sFqvO6CMV55ZB0PgZv8WigCkt9FoJciYo5S3Q6CGYK+WnE/ZG+6vkBDQ==" - } } }, "dot-prop": { @@ -8760,8 +8836,7 @@ "is-obj": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" }, "is-path-cwd": { "version": "2.2.0", @@ -8877,8 +8952,8 @@ "@typescript-eslint/eslint-plugin": "^4.23.0", "@typescript-eslint/parser": "^4.23.0", "chai": "^4.3.4", - "discord-api-types": "^0.21.0-next.ab1951b.1626870574", - "discord.js": "^13.0.0-dev.4886ae2.1627214570", + "discord-api-types": "^0.18.1", + "discord.js": "github:monbrey/discord.js#9c42f571093b2565df28b756fdca4ac59cad0fe3", "eslint": "^7.2.0", "husky": "^4.3.8", "knub-command-manager": "^9.1.0", @@ -9462,6 +9537,39 @@ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, + "ow": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/ow/-/ow-0.26.0.tgz", + "integrity": "sha512-22YUQW9d6oUSCpIQuBV25djtC1uMtpWqmtUYnuh2UHWeNMpppCFCvq3eSBIWWMDbe2UVq26kWYvBHDzOIu5NYg==", + "requires": { + "@sindresorhus/is": "^4.0.1", + "callsites": "^3.1.0", + "dot-prop": "^6.0.1", + "lodash.isequal": "^4.5.0", + "type-fest": "^1.2.1", + "vali-date": "^1.0.0" + }, + "dependencies": { + "@sindresorhus/is": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", + "integrity": "sha512-Qm9hBEBu18wt1PO2flE7LPb30BHMQt1eQgbV76YntdNk73XZGpn3izvGTYxbGgzXKgbCjiia0uxTd3aTNQrY/g==" + }, + "dot-prop": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", + "integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", + "requires": { + "is-obj": "^2.0.0" + } + }, + "type-fest": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.3.0.tgz", + "integrity": "sha512-mYUYkAy6fPatVWtUeCV/qGeGL3IVucmdJOzeAEfwgCJDx8gP0JaW8jn6KQ5xDfPec31e0KXWn5EUOZMhquR1zA==" + } + } + }, "p-cancelable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", @@ -10623,6 +10731,11 @@ "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", "dev": true }, + "ts-mixer": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-5.4.1.tgz", + "integrity": "sha512-Zo9HgPCtNouDgJ+LGtrzVOjSg8+7WGQktIKLwAfaNrlOK1mWGlz1ejsAF/YqUEqAGjUTeB5fEg8gH9Aui6w9xA==" + }, "tsc-watch": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tsc-watch/-/tsc-watch-4.0.0.tgz", @@ -10976,6 +11089,11 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, + "vali-date": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/vali-date/-/vali-date-1.0.0.tgz", + "integrity": "sha1-G5BKWWCfsyjvB4E4Qgk09rhnCaY=" + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/backend/package.json b/backend/package.json index 8c917b27..d9c76424 100644 --- a/backend/package.json +++ b/backend/package.json @@ -29,7 +29,7 @@ "cors": "^2.8.5", "cross-env": "^5.2.0", "deep-diff": "^1.0.2", - "discord.js": "^13.0.0-dev.d310e4f.1627560163", + "discord.js": "^13.0.0-dev.t1628078860.90c2e07", "dotenv": "^4.0.0", "emoji-regex": "^8.0.0", "erlpack": "github:discord/erlpack", diff --git a/backend/src/data/GuildSavedMessages.ts b/backend/src/data/GuildSavedMessages.ts index 7fbcb120..ff4daf7f 100644 --- a/backend/src/data/GuildSavedMessages.ts +++ b/backend/src/data/GuildSavedMessages.ts @@ -45,9 +45,9 @@ export class GuildSavedMessages extends BaseGuildRepository { timestamp: msg.createdTimestamp, }; - if (msg.attachments.size) data.attachments = msg.attachments.array(); + if (msg.attachments.size) data.attachments = [...msg.attachments.values()]; if (msg.embeds.length) data.embeds = msg.embeds; - if (msg.stickers?.size) data.stickers = msg.stickers.array(); + if (msg.stickers?.size) data.stickers = [...msg.stickers.values()]; return data; } diff --git a/backend/src/plugins/Automod/actions/addRoles.ts b/backend/src/plugins/Automod/actions/addRoles.ts index e87a2cc2..91a12bca 100644 --- a/backend/src/plugins/Automod/actions/addRoles.ts +++ b/backend/src/plugins/Automod/actions/addRoles.ts @@ -53,7 +53,7 @@ export const AddRolesAction = automodAction({ await Promise.all( members.map(async member => { - const memberRoles = new Set(member.roles.cache.keyArray()); + const memberRoles = new Set(member.roles.cache.keys()); for (const roleId of rolesToAssign) { memberRoles.add(roleId as Snowflake); ignoreRoleChange(pluginData, member.id, roleId); diff --git a/backend/src/plugins/Automod/actions/removeRoles.ts b/backend/src/plugins/Automod/actions/removeRoles.ts index 54ce11f1..0e125fb7 100644 --- a/backend/src/plugins/Automod/actions/removeRoles.ts +++ b/backend/src/plugins/Automod/actions/removeRoles.ts @@ -54,7 +54,7 @@ export const RemoveRolesAction = automodAction({ await Promise.all( members.map(async member => { - const memberRoles = new Set(member.roles.cache.keyArray()); + const memberRoles = new Set(member.roles.cache.keys()); for (const roleId of rolesToRemove) { memberRoles.delete(roleId as Snowflake); ignoreRoleChange(pluginData, member.id, roleId); diff --git a/backend/src/plugins/CustomEvents/actions/addRoleAction.ts b/backend/src/plugins/CustomEvents/actions/addRoleAction.ts index d4f1b61a..6621763d 100644 --- a/backend/src/plugins/CustomEvents/actions/addRoleAction.ts +++ b/backend/src/plugins/CustomEvents/actions/addRoleAction.ts @@ -31,6 +31,6 @@ export async function addRoleAction( const rolesToAdd = Array.isArray(action.role) ? action.role : [action.role]; await target.edit({ - roles: Array.from(new Set([...target.roles.cache.array(), ...rolesToAdd])) as Snowflake[], + roles: Array.from(new Set([...target.roles.cache.values(), ...rolesToAdd])) as Snowflake[], }); } diff --git a/backend/src/plugins/Logs/events/LogsUserUpdateEvts.ts b/backend/src/plugins/Logs/events/LogsUserUpdateEvts.ts index 1f37a360..a5f7e9c7 100644 --- a/backend/src/plugins/Logs/events/LogsUserUpdateEvts.ts +++ b/backend/src/plugins/Logs/events/LogsUserUpdateEvts.ts @@ -27,8 +27,8 @@ export const LogsGuildMemberUpdateEvt = logsEvt({ } if (!isEqual(oldMember.roles, member.roles)) { - const addedRoles = diff(member.roles.cache.keyArray(), oldMember.roles.cache.keyArray()); - const removedRoles = diff(oldMember.roles.cache.keyArray(), member.roles.cache.keyArray()); + const addedRoles = diff([...member.roles.cache.keys()], [...oldMember.roles.cache.keys()]); + const removedRoles = diff([...oldMember.roles.cache.keys()], [...member.roles.cache.keys()]); let skip = false; if ( diff --git a/backend/src/plugins/MessageSaver/commands/SavePinsToDB.ts b/backend/src/plugins/MessageSaver/commands/SavePinsToDB.ts index ede884d6..e81c73fe 100644 --- a/backend/src/plugins/MessageSaver/commands/SavePinsToDB.ts +++ b/backend/src/plugins/MessageSaver/commands/SavePinsToDB.ts @@ -16,7 +16,7 @@ export const SavePinsToDBCmd = messageSaverCmd({ await msg.channel.send(`Saving pins from <#${args.channel.id}>...`); const pins = await args.channel.messages.fetchPinned(); - const { savedCount, failed } = await saveMessagesToDB(pluginData, args.channel, pins.keyArray()); + const { savedCount, failed } = await saveMessagesToDB(pluginData, args.channel, [...pins.keys()]); if (failed.length) { sendSuccessMessage( diff --git a/backend/src/plugins/ModActions/commands/AddCaseCmd.ts b/backend/src/plugins/ModActions/commands/AddCaseCmd.ts index f23d9500..dd968c76 100644 --- a/backend/src/plugins/ModActions/commands/AddCaseCmd.ts +++ b/backend/src/plugins/ModActions/commands/AddCaseCmd.ts @@ -60,7 +60,7 @@ export const AddCaseCmd = modActionsCmd({ return; } - const reason = formatReasonWithAttachments(args.reason, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]); // Create the case const casesPlugin = pluginData.getPlugin(CasesPlugin); diff --git a/backend/src/plugins/ModActions/commands/BanCmd.ts b/backend/src/plugins/ModActions/commands/BanCmd.ts index 8a40da77..6437a5e9 100644 --- a/backend/src/plugins/ModActions/commands/BanCmd.ts +++ b/backend/src/plugins/ModActions/commands/BanCmd.ts @@ -51,7 +51,7 @@ export const BanCmd = modActionsCmd({ } const time = args["time"] ? args["time"] : null; - const reason = formatReasonWithAttachments(args.reason, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]); const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id); // The moderator who did the action is the message author or, if used, the specified -mod let mod = msg.member; diff --git a/backend/src/plugins/ModActions/commands/ForcebanCmd.ts b/backend/src/plugins/ModActions/commands/ForcebanCmd.ts index 67df9ece..8a1df43e 100644 --- a/backend/src/plugins/ModActions/commands/ForcebanCmd.ts +++ b/backend/src/plugins/ModActions/commands/ForcebanCmd.ts @@ -61,7 +61,7 @@ export const ForcebanCmd = modActionsCmd({ mod = args.mod; } - const reason = formatReasonWithAttachments(args.reason, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]); ignoreEvent(pluginData, IgnoredEventType.Ban, user.id); pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id); diff --git a/backend/src/plugins/ModActions/commands/MassBanCmd.ts b/backend/src/plugins/ModActions/commands/MassBanCmd.ts index 7e61bb48..e4e4fd44 100644 --- a/backend/src/plugins/ModActions/commands/MassBanCmd.ts +++ b/backend/src/plugins/ModActions/commands/MassBanCmd.ts @@ -39,7 +39,7 @@ export const MassbanCmd = modActionsCmd({ return; } - const banReason = formatReasonWithAttachments(banReasonReply.content, msg.attachments.array()); + const banReason = formatReasonWithAttachments(banReasonReply.content, [...msg.attachments.values()]); // Verify we can act on each of the users specified for (const userId of args.userIds) { diff --git a/backend/src/plugins/ModActions/commands/MassUnbanCmd.ts b/backend/src/plugins/ModActions/commands/MassUnbanCmd.ts index 1141c26c..ea5e5770 100644 --- a/backend/src/plugins/ModActions/commands/MassUnbanCmd.ts +++ b/backend/src/plugins/ModActions/commands/MassUnbanCmd.ts @@ -37,7 +37,7 @@ export const MassunbanCmd = modActionsCmd({ return; } - const unbanReason = formatReasonWithAttachments(unbanReasonReply.content, msg.attachments.array()); + const unbanReason = formatReasonWithAttachments(unbanReasonReply.content, [...msg.attachments.values()]); // Ignore automatic unban cases and logs for these users // We'll create our own cases below and post a single "mass unbanned" log instead diff --git a/backend/src/plugins/ModActions/commands/MassmuteCmd.ts b/backend/src/plugins/ModActions/commands/MassmuteCmd.ts index 9f87ed81..5c82dd5b 100644 --- a/backend/src/plugins/ModActions/commands/MassmuteCmd.ts +++ b/backend/src/plugins/ModActions/commands/MassmuteCmd.ts @@ -39,7 +39,7 @@ export const MassmuteCmd = modActionsCmd({ return; } - const muteReason = formatReasonWithAttachments(muteReasonReceived.content, msg.attachments.array()); + const muteReason = formatReasonWithAttachments(muteReasonReceived.content, [...msg.attachments.values()]); // Verify we can act upon all users for (const userId of args.userIds) { diff --git a/backend/src/plugins/ModActions/commands/NoteCmd.ts b/backend/src/plugins/ModActions/commands/NoteCmd.ts index 3ed21806..92e1b0fa 100644 --- a/backend/src/plugins/ModActions/commands/NoteCmd.ts +++ b/backend/src/plugins/ModActions/commands/NoteCmd.ts @@ -31,7 +31,7 @@ export const NoteCmd = modActionsCmd({ } const userName = user.tag; - const reason = formatReasonWithAttachments(args.note, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.note, [...msg.attachments.values()]); const casesPlugin = pluginData.getPlugin(CasesPlugin); const createdCase = await casesPlugin.createCase({ diff --git a/backend/src/plugins/ModActions/commands/UnbanCmd.ts b/backend/src/plugins/ModActions/commands/UnbanCmd.ts index 38bb49f0..0e199b25 100644 --- a/backend/src/plugins/ModActions/commands/UnbanCmd.ts +++ b/backend/src/plugins/ModActions/commands/UnbanCmd.ts @@ -47,7 +47,7 @@ export const UnbanCmd = modActionsCmd({ } pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_UNBAN, user.id); - const reason = formatReasonWithAttachments(args.reason, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]); try { ignoreEvent(pluginData, IgnoredEventType.Unban, user.id); diff --git a/backend/src/plugins/ModActions/commands/WarnCmd.ts b/backend/src/plugins/ModActions/commands/WarnCmd.ts index d06f91b8..03d79b76 100644 --- a/backend/src/plugins/ModActions/commands/WarnCmd.ts +++ b/backend/src/plugins/ModActions/commands/WarnCmd.ts @@ -63,7 +63,7 @@ export const WarnCmd = modActionsCmd({ } const config = pluginData.config.get(); - const reason = formatReasonWithAttachments(args.reason, msg.attachments.array()); + const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]); const casesPlugin = pluginData.getPlugin(CasesPlugin); const priorWarnAmount = await casesPlugin.getCaseTypeAmountForUserId(memberToWarn.id, CaseTypes.Warn); diff --git a/backend/src/plugins/ModActions/functions/actualMuteUserCmd.ts b/backend/src/plugins/ModActions/functions/actualMuteUserCmd.ts index 64fd30df..f790604a 100644 --- a/backend/src/plugins/ModActions/functions/actualMuteUserCmd.ts +++ b/backend/src/plugins/ModActions/functions/actualMuteUserCmd.ts @@ -42,7 +42,7 @@ export async function actualMuteUserCmd( } const timeUntilUnmute = args.time && humanizeDuration(args.time); - const reason = args.reason ? formatReasonWithAttachments(args.reason, msg.attachments.array()) : undefined; + const reason = args.reason ? formatReasonWithAttachments(args.reason, [...msg.attachments.values()]) : undefined; let muteResult: MuteResult; const mutesPlugin = pluginData.getPlugin(MutesPlugin); diff --git a/backend/src/plugins/ModActions/functions/actualUnmuteUserCmd.ts b/backend/src/plugins/ModActions/functions/actualUnmuteUserCmd.ts index fb7465c7..46ab7be6 100644 --- a/backend/src/plugins/ModActions/functions/actualUnmuteUserCmd.ts +++ b/backend/src/plugins/ModActions/functions/actualUnmuteUserCmd.ts @@ -27,7 +27,7 @@ export async function actualUnmuteCmd( pp = msg.author; } - const reason = args.reason ? formatReasonWithAttachments(args.reason, msg.attachments.array()) : undefined; + const reason = args.reason ? formatReasonWithAttachments(args.reason, [...msg.attachments.values()]) : undefined; const mutesPlugin = pluginData.getPlugin(MutesPlugin); const result = await mutesPlugin.unmuteUser(user.id, args.time, { diff --git a/backend/src/plugins/ModActions/functions/updateCase.ts b/backend/src/plugins/ModActions/functions/updateCase.ts index 21b6e050..4d89105a 100644 --- a/backend/src/plugins/ModActions/functions/updateCase.ts +++ b/backend/src/plugins/ModActions/functions/updateCase.ts @@ -24,7 +24,7 @@ export async function updateCase(pluginData, msg: Message, args) { return; } - const note = formatReasonWithAttachments(args.note, msg.attachments.array()); + const note = formatReasonWithAttachments(args.note, [...msg.attachments.values()]); const casesPlugin = pluginData.getPlugin(CasesPlugin); await casesPlugin.createCaseNote({ diff --git a/backend/src/plugins/Mutes/functions/clearExpiredMutes.ts b/backend/src/plugins/Mutes/functions/clearExpiredMutes.ts index 7ad36e65..d812dd9d 100644 --- a/backend/src/plugins/Mutes/functions/clearExpiredMutes.ts +++ b/backend/src/plugins/Mutes/functions/clearExpiredMutes.ts @@ -21,7 +21,7 @@ export async function clearExpiredMutes(pluginData: GuildPluginData to <#${starboardChannel.id}>...`); - const pins = (await args.pinChannel.messages.fetchPinned()).array(); + const pins = [...(await args.pinChannel.messages.fetchPinned().catch(() => [])).values()]; pins.reverse(); // Migrate pins starting from the oldest message for (const pin of pins) { diff --git a/backend/src/plugins/Utility/commands/CleanCmd.ts b/backend/src/plugins/Utility/commands/CleanCmd.ts index e7778215..ca96d57f 100644 --- a/backend/src/plugins/Utility/commands/CleanCmd.ts +++ b/backend/src/plugins/Utility/commands/CleanCmd.ts @@ -118,7 +118,7 @@ export const CleanCmd = utilityCmd({ const deletePins = args["delete-pins"] != null ? args["delete-pins"] : false; let pins: Message[] = []; if (!deletePins) { - pins = (await msg.channel.messages.fetchPinned()).array(); + pins = [...(await msg.channel.messages.fetchPinned().catch(() => [])).values()]; } while (messagesToClean.length < args.count) { @@ -128,14 +128,14 @@ export const CleanCmd = utilityCmd({ }); if (potentialMessages.size === 0) break; - const existingStored = await pluginData.state.savedMessages.getMultiple(potentialMessages.keyArray()); + const existingStored = await pluginData.state.savedMessages.getMultiple([...potentialMessages.keys()]); const alreadyStored = existingStored.map(stored => stored.id); - const messagesToStore = potentialMessages - .array() - .filter(potentialMsg => !alreadyStored.includes(potentialMsg.id)); + const messagesToStore = [ + ...potentialMessages.filter(potentialMsg => !alreadyStored.includes(potentialMsg.id)).values(), + ]; await pluginData.state.savedMessages.createFromMessages(messagesToStore); - const potentialMessagesToClean = await pluginData.state.savedMessages.getMultiple(potentialMessages.keyArray()); + const potentialMessagesToClean = await pluginData.state.savedMessages.getMultiple([...potentialMessages.keys()]); if (potentialMessagesToClean.length === 0) break; const filtered: SavedMessage[] = []; diff --git a/backend/src/plugins/Utility/commands/VcdisconnectCmd.ts b/backend/src/plugins/Utility/commands/VcdisconnectCmd.ts index c5d4b14d..5bb69961 100644 --- a/backend/src/plugins/Utility/commands/VcdisconnectCmd.ts +++ b/backend/src/plugins/Utility/commands/VcdisconnectCmd.ts @@ -32,7 +32,7 @@ export const VcdisconnectCmd = utilityCmd({ const channel = pluginData.guild.channels.cache.get(args.member.voice.channelId) as VoiceChannel; try { - await args.member.voice.kick(); + await args.member.voice.disconnect(); } catch { sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member"); return; diff --git a/backend/src/plugins/Utility/commands/VcmoveCmd.ts b/backend/src/plugins/Utility/commands/VcmoveCmd.ts index 9e51dd5b..409918dd 100644 --- a/backend/src/plugins/Utility/commands/VcmoveCmd.ts +++ b/backend/src/plugins/Utility/commands/VcmoveCmd.ts @@ -9,6 +9,7 @@ import { LogType } from "../../../data/LogType"; import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils"; import { channelMentionRegex, isSnowflake, simpleClosestStringMatch } from "../../../utils"; import { utilityCmd } from "../types"; +import { ChannelTypeStrings } from "../../../types"; export const VcmoveCmd = utilityCmd({ trigger: "vcmove", @@ -45,9 +46,11 @@ export const VcmoveCmd = utilityCmd({ channel = potentialChannel; } else { // Search string -> find closest matching voice channel name - const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => { - return theChannel instanceof VoiceChannel; - }) as VoiceChannel[]; + const voiceChannels = [ + ...pluginData.guild.channels.cache + .filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE) + .values(), + ]; const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name); if (!closestMatch) { sendErrorMessage(pluginData, msg.channel, "No matching voice channels"); @@ -124,9 +127,11 @@ export const VcmoveAllCmd = utilityCmd({ channel = potentialChannel; } else { // Search string -> find closest matching voice channel name - const voiceChannels = pluginData.guild.channels.cache.array().filter(theChannel => { - return theChannel instanceof VoiceChannel; - }) as VoiceChannel[]; + const voiceChannels = [ + ...pluginData.guild.channels.cache + .filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE) + .values(), + ]; const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name); if (!closestMatch) { sendErrorMessage(pluginData, msg.channel, "No matching voice channels"); diff --git a/backend/src/plugins/Utility/functions/getChannelInfoEmbed.ts b/backend/src/plugins/Utility/functions/getChannelInfoEmbed.ts index c1dcc7d8..d1788bce 100644 --- a/backend/src/plugins/Utility/functions/getChannelInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getChannelInfoEmbed.ts @@ -130,11 +130,13 @@ export async function getChannelInfoEmbed( if (channel.type === ChannelTypeStrings.PRIVATE_THREAD || channel.type === ChannelTypeStrings.PUBLIC_THREAD) { const thread = channel as ThreadChannel; - const parentChannelName = thread.parent?.name ? thread.parent.name : `<#${thread.parentId}>`; + const parentChannelName = thread.parent?.name ?? `<#${thread.parentId}>`; const memberCount = thread.memberCount ?? thread.members.cache.size; - const owner = await pluginData.guild.members.fetch(thread.ownerId).catch(() => null); - const ownerMention = owner ? verboseUserMention(owner.user) : "Unknown#0000"; - const humanizedArchiveTime = `Archive duration: **${humanizeDuration(thread.autoArchiveDuration * MINUTES)}**`; + const owner = await thread.fetchOwner().catch(() => null); + const ownerMention = owner?.user ? verboseUserMention(owner.user) : "Unknown#0000"; + const humanizedArchiveTime = `Archive duration: **${humanizeDuration( + (thread.autoArchiveDuration ?? 0) * MINUTES, + )}**`; embed.fields.push({ name: preEmbedPadding + "Thread information", diff --git a/backend/src/utils.ts b/backend/src/utils.ts index a3dcec39..6f0edca8 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -535,7 +535,7 @@ export async function findRelevantAuditLogEntry( } } - const entries = auditLogs ? auditLogs.entries.array() : []; + const entries = auditLogs ? [...auditLogs.entries.values()] : []; entries.sort((a, b) => { if (a.createdAt > b.createdAt) return -1; @@ -1302,7 +1302,7 @@ export async function resolveInvite( return promise as ResolveInviteReturnType; } -const internalStickerCache: LimitedCollection = new LimitedCollection(500); +const internalStickerCache: LimitedCollection = new LimitedCollection({ maxSize: 500 }); export async function resolveStickerId(bot: Client, id: Snowflake): Promise { const cachedSticker = internalStickerCache.get(id); diff --git a/backend/src/utils/configAccessibleObjects.ts b/backend/src/utils/configAccessibleObjects.ts index 5904e48d..9319fc08 100644 --- a/backend/src/utils/configAccessibleObjects.ts +++ b/backend/src/utils/configAccessibleObjects.ts @@ -87,7 +87,7 @@ export function memberToConfigAccessibleMember(member: GuildMember | PartialGuil ...user, user, nick: member.nickname ?? "*None*", - roles: member.roles.cache.mapValues(r => roleToConfigAccessibleRole(r)).array(), + roles: [...member.roles.cache.mapValues(r => roleToConfigAccessibleRole(r)).values()], joinedAt: member.joinedTimestamp ?? undefined, guildName: member.guild.name, };