1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 00:31:00 -05:00

Compare commits

..

11 Commits

Author SHA1 Message Date
toast-ts
2616b8996b Merge branch 'master' into sequelize-v7 2024-03-18 13:22:20 +11:00
toast-ts
3309da55f2 Dedupe @types/node 2024-03-18 13:17:25 +11:00
dependabot[bot]
4a1d4e9eed
Bump systeminformation from 5.22.2 to 5.22.3 (#95)
Bumps [systeminformation](https://github.com/sebhildebrandt/systeminformation) from 5.22.2 to 5.22.3.
- [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebhildebrandt/systeminformation/compare/v5.22.2...v5.22.3)

---
updated-dependencies:
- dependency-name: systeminformation
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-18 13:14:29 +11:00
github-actions[bot]
711bb3a053
Combined Dependabot PR (#98)
* Bump fast-xml-parser from 4.3.5 to 4.3.6

Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 4.3.5 to 4.3.6.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v4.3.5...v4.3.6)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump simple-git from 3.22.0 to 3.23.0

Bumps [simple-git](https://github.com/steveukx/git-js/tree/HEAD/simple-git) from 3.22.0 to 3.23.0.
- [Release notes](https://github.com/steveukx/git-js/releases)
- [Changelog](https://github.com/steveukx/git-js/blob/main/simple-git/CHANGELOG.md)
- [Commits](https://github.com/steveukx/git-js/commits/simple-git@3.23.0/simple-git)

---
updated-dependencies:
- dependency-name: simple-git
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump @types/node from 20.11.27 to 20.11.28

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.11.27 to 20.11.28.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-18 13:11:37 +11:00
toast-ts
49dc4c2f7e I guess we can try secrets? 2024-03-18 13:00:23 +11:00
toast-ts
4571cdfc7e See if it can pick up another NPM registry 2024-03-18 12:47:47 +11:00
toast-ts
6c34752c0b It's like trying to repair a hole in a car tire. 2024-03-18 12:15:16 +11:00
toast-ts
a86efd78a5 Improve the code comment for API ratelimit that is set by GIANTS 2024-03-16 20:53:39 +11:00
toast-ts
ca3f926cb8 bruh.exe has stopped responding. 2024-03-15 21:02:30 +11:00
toast-ts
4fbdbcf79a Improve MPModule's failure rate 2024-03-15 15:12:56 +11:00
toast-ts
2e8299491d Add 'es' to automod regex. 2024-03-13 09:11:58 +11:00
9 changed files with 122 additions and 88 deletions

View File

@ -4,6 +4,12 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2 version: 2
registries:
toast:
type: npm-registry
url: "https://git.toast-server.net/api/packages/toast/npm/"
token: ${{ secrets.GITEA_TOKEN }}
updates: updates:
- package-ecosystem: "npm" - package-ecosystem: "npm"
directory: "/" directory: "/"
@ -13,7 +19,11 @@ updates:
timezone: "Australia/NSW" timezone: "Australia/NSW"
assignees: assignees:
- "toast-ts" - "toast-ts"
reviewers:
- "toast-ts"
labels: labels:
- "dependencies" - "dependencies"
open-pull-requests-limit: 8 open-pull-requests-limit: 8
rebase-strategy: auto rebase-strategy: auto
registries:
- toast

68
.pnp.cjs generated
View File

@ -31,24 +31,24 @@ const RAW_RUNTIME_STATE =
["@sequelize/core", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:7.0.0-alpha.37"],\ ["@sequelize/core", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:7.0.0-alpha.37"],\
["@toast/tokenservice-client", "npm:1.0.16::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.16%2Ftokenservice-client-1.0.16.tgz"],\ ["@toast/tokenservice-client", "npm:1.0.16::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.16%2Ftokenservice-client-1.0.16.tgz"],\
["@types/ms", "npm:0.7.34"],\ ["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.25"],\ ["@types/node", "npm:20.11.28"],\
["@types/node-cron", "npm:3.0.11"],\ ["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.11.2"],\ ["@types/pg", "npm:8.11.2"],\
["ansi-colors", "npm:4.1.3"],\ ["ansi-colors", "npm:4.1.3"],\
["dayjs", "npm:1.11.10"],\ ["dayjs", "npm:1.11.10"],\
["discord.js", "npm:14.14.1"],\ ["discord.js", "npm:14.14.1"],\
["fast-xml-parser", "npm:4.3.5"],\ ["fast-xml-parser", "npm:4.3.6"],\
["mathjs", "npm:12.4.0"],\ ["mathjs", "npm:12.4.1"],\
["ms", "npm:2.1.3"],\ ["ms", "npm:2.1.3"],\
["node-cron", "npm:3.0.3"],\ ["node-cron", "npm:3.0.3"],\
["pg", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:8.11.3"],\ ["pg", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:8.11.3"],\
["pg-hstore", "npm:2.3.4"],\ ["pg-hstore", "npm:2.3.4"],\
["postgres-array", "npm:3.0.2"],\ ["postgres-array", "npm:3.0.2"],\
["redis", "npm:4.6.13"],\ ["redis", "npm:4.6.13"],\
["simple-git", "npm:3.22.0"],\ ["simple-git", "npm:3.23.0"],\
["systeminformation", "npm:5.22.0"],\ ["systeminformation", "npm:5.22.3"],\
["typescript", "patch:typescript@npm%3A5.4.2#optional!builtin<compat/typescript>::version=5.4.2&hash=5adc0c"],\ ["typescript", "patch:typescript@npm%3A5.4.2#optional!builtin<compat/typescript>::version=5.4.2&hash=5adc0c"],\
["undici", "npm:6.7.1"]\ ["undici", "npm:6.9.0"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}]\ }]\
@ -738,10 +738,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["@types/node", [\ ["@types/node", [\
["npm:20.11.25", {\ ["npm:20.11.28", {\
"packageLocation": "./.yarn/cache/@types-node-npm-20.11.25-b6ac39dd46-861265f1bb.zip/node_modules/@types/node/",\ "packageLocation": "./.yarn/cache/@types-node-npm-20.11.28-6be967407c-b03f69213a.zip/node_modules/@types/node/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/node", "npm:20.11.25"],\ ["@types/node", "npm:20.11.28"],\
["undici-types", "npm:5.26.5"]\ ["undici-types", "npm:5.26.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
@ -761,7 +761,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-pg-npm-8.11.2-bdf321bea4-7c05cf63be.zip/node_modules/@types/pg/",\ "packageLocation": "./.yarn/cache/@types-pg-npm-8.11.2-bdf321bea4-7c05cf63be.zip/node_modules/@types/pg/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/pg", "npm:8.11.2"],\ ["@types/pg", "npm:8.11.2"],\
["@types/node", "npm:20.11.25"],\ ["@types/node", "npm:20.11.28"],\
["pg-protocol", "npm:1.6.0"],\ ["pg-protocol", "npm:1.6.0"],\
["pg-types", "npm:4.0.2"]\ ["pg-types", "npm:4.0.2"]\
],\ ],\
@ -782,7 +782,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-ws-npm-8.5.10-a877a38f71-9b414dc5e0.zip/node_modules/@types/ws/",\ "packageLocation": "./.yarn/cache/@types-ws-npm-8.5.10-a877a38f71-9b414dc5e0.zip/node_modules/@types/ws/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/ws", "npm:8.5.10"],\ ["@types/ws", "npm:8.5.10"],\
["@types/node", "npm:20.11.25"]\ ["@types/node", "npm:20.11.28"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\ }],\
@ -790,7 +790,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\ "packageLocation": "./.yarn/cache/@types-ws-npm-8.5.9-91d1b2ab07-7cf66383b8.zip/node_modules/@types/ws/",\
"packageDependencies": [\ "packageDependencies": [\
["@types/ws", "npm:8.5.9"],\ ["@types/ws", "npm:8.5.9"],\
["@types/node", "npm:20.11.25"]\ ["@types/node", "npm:20.11.28"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -878,24 +878,24 @@ const RAW_RUNTIME_STATE =
["@sequelize/core", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:7.0.0-alpha.37"],\ ["@sequelize/core", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:7.0.0-alpha.37"],\
["@toast/tokenservice-client", "npm:1.0.16::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.16%2Ftokenservice-client-1.0.16.tgz"],\ ["@toast/tokenservice-client", "npm:1.0.16::__archiveUrl=https%3A%2F%2Fgit.toast-server.net%2Fapi%2Fpackages%2Ftoast%2Fnpm%2F%2540toast%252Ftokenservice-client%2F-%2F1.0.16%2Ftokenservice-client-1.0.16.tgz"],\
["@types/ms", "npm:0.7.34"],\ ["@types/ms", "npm:0.7.34"],\
["@types/node", "npm:20.11.25"],\ ["@types/node", "npm:20.11.28"],\
["@types/node-cron", "npm:3.0.11"],\ ["@types/node-cron", "npm:3.0.11"],\
["@types/pg", "npm:8.11.2"],\ ["@types/pg", "npm:8.11.2"],\
["ansi-colors", "npm:4.1.3"],\ ["ansi-colors", "npm:4.1.3"],\
["dayjs", "npm:1.11.10"],\ ["dayjs", "npm:1.11.10"],\
["discord.js", "npm:14.14.1"],\ ["discord.js", "npm:14.14.1"],\
["fast-xml-parser", "npm:4.3.5"],\ ["fast-xml-parser", "npm:4.3.6"],\
["mathjs", "npm:12.4.0"],\ ["mathjs", "npm:12.4.1"],\
["ms", "npm:2.1.3"],\ ["ms", "npm:2.1.3"],\
["node-cron", "npm:3.0.3"],\ ["node-cron", "npm:3.0.3"],\
["pg", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:8.11.3"],\ ["pg", "virtual:20c353e2d6536e37339997f03975c6a660f4d296e664d291bd43620c6162cca8eb5ef90b0998dc9db75ff6862e5da587d0530bae26805f5fadc8f17aaa4ff794#npm:8.11.3"],\
["pg-hstore", "npm:2.3.4"],\ ["pg-hstore", "npm:2.3.4"],\
["postgres-array", "npm:3.0.2"],\ ["postgres-array", "npm:3.0.2"],\
["redis", "npm:4.6.13"],\ ["redis", "npm:4.6.13"],\
["simple-git", "npm:3.22.0"],\ ["simple-git", "npm:3.23.0"],\
["systeminformation", "npm:5.22.0"],\ ["systeminformation", "npm:5.22.3"],\
["typescript", "patch:typescript@npm%3A5.4.2#optional!builtin<compat/typescript>::version=5.4.2&hash=5adc0c"],\ ["typescript", "patch:typescript@npm%3A5.4.2#optional!builtin<compat/typescript>::version=5.4.2&hash=5adc0c"],\
["undici", "npm:6.7.1"]\ ["undici", "npm:6.9.0"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}]\ }]\
@ -1024,10 +1024,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["fast-xml-parser", [\ ["fast-xml-parser", [\
["npm:4.3.5", {\ ["npm:4.3.6", {\
"packageLocation": "./.yarn/cache/fast-xml-parser-npm-4.3.5-3cd12e5b84-ccfd943e4e.zip/node_modules/fast-xml-parser/",\ "packageLocation": "./.yarn/cache/fast-xml-parser-npm-4.3.6-b71efbeb6c-3e431e5949.zip/node_modules/fast-xml-parser/",\
"packageDependencies": [\ "packageDependencies": [\
["fast-xml-parser", "npm:4.3.5"],\ ["fast-xml-parser", "npm:4.3.6"],\
["strnum", "npm:1.0.5"]\ ["strnum", "npm:1.0.5"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
@ -1165,10 +1165,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["mathjs", [\ ["mathjs", [\
["npm:12.4.0", {\ ["npm:12.4.1", {\
"packageLocation": "./.yarn/cache/mathjs-npm-12.4.0-4e73cebf2f-ee168a7e4b.zip/node_modules/mathjs/",\ "packageLocation": "./.yarn/cache/mathjs-npm-12.4.1-ca45bb0559-171cdf4b6a.zip/node_modules/mathjs/",\
"packageDependencies": [\ "packageDependencies": [\
["mathjs", "npm:12.4.0"],\ ["mathjs", "npm:12.4.1"],\
["@babel/runtime", "npm:7.24.0"],\ ["@babel/runtime", "npm:7.24.0"],\
["complex.js", "npm:2.1.1"],\ ["complex.js", "npm:2.1.1"],\
["decimal.js", "npm:10.4.3"],\ ["decimal.js", "npm:10.4.3"],\
@ -1575,10 +1575,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["simple-git", [\ ["simple-git", [\
["npm:3.22.0", {\ ["npm:3.23.0", {\
"packageLocation": "./.yarn/cache/simple-git-npm-3.22.0-42ea3caec2-309e7f0b73.zip/node_modules/simple-git/",\ "packageLocation": "./.yarn/cache/simple-git-npm-3.23.0-a7d8879afb-08ddfcbc31.zip/node_modules/simple-git/",\
"packageDependencies": [\ "packageDependencies": [\
["simple-git", "npm:3.22.0"],\ ["simple-git", "npm:3.23.0"],\
["@kwsites/file-exists", "npm:1.1.1"],\ ["@kwsites/file-exists", "npm:1.1.1"],\
["@kwsites/promise-deferred", "npm:1.1.1"],\ ["@kwsites/promise-deferred", "npm:1.1.1"],\
["debug", "virtual:8dde907e274d6cda4b3be6cd808e5a16421eab0e2ce2f6110b97323dbadda969b2dab36e690fd106d5bd3c87e0525cade2b2ba6fb4fb0c0e439212e4cf5c851b#npm:4.3.4"]\ ["debug", "virtual:8dde907e274d6cda4b3be6cd808e5a16421eab0e2ce2f6110b97323dbadda969b2dab36e690fd106d5bd3c87e0525cade2b2ba6fb4fb0c0e439212e4cf5c851b#npm:4.3.4"]\
@ -1605,10 +1605,10 @@ const RAW_RUNTIME_STATE =
}]\ }]\
]],\ ]],\
["systeminformation", [\ ["systeminformation", [\
["npm:5.22.0", {\ ["npm:5.22.3", {\
"packageLocation": "./.yarn/unplugged/systeminformation-npm-5.22.0-ae815bb44c/node_modules/systeminformation/",\ "packageLocation": "./.yarn/unplugged/systeminformation-npm-5.22.3-b08524e9a7/node_modules/systeminformation/",\
"packageDependencies": [\ "packageDependencies": [\
["systeminformation", "npm:5.22.0"]\ ["systeminformation", "npm:5.22.3"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -1712,10 +1712,10 @@ const RAW_RUNTIME_STATE =
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\ }],\
["npm:6.7.1", {\ ["npm:6.9.0", {\
"packageLocation": "./.yarn/cache/undici-npm-6.7.1-cc741edc29-7e66eb7fb6.zip/node_modules/undici/",\ "packageLocation": "./.yarn/cache/undici-npm-6.9.0-9cc1c4dd88-ee22751758.zip/node_modules/undici/",\
"packageDependencies": [\ "packageDependencies": [\
["undici", "npm:6.7.1"]\ ["undici", "npm:6.9.0"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -1768,7 +1768,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\ "packageLocation": "./.yarn/cache/wkx-npm-0.5.0-fca5152cd8-b8975e33f9.zip/node_modules/wkx/",\
"packageDependencies": [\ "packageDependencies": [\
["wkx", "npm:0.5.0"],\ ["wkx", "npm:0.5.0"],\
["@types/node", "npm:20.11.25"]\ ["@types/node", "npm:20.11.28"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\

View File

@ -34,21 +34,21 @@
"ansi-colors": "4.1.3", "ansi-colors": "4.1.3",
"dayjs": "1.11.10", "dayjs": "1.11.10",
"discord.js": "14.14.1", "discord.js": "14.14.1",
"fast-xml-parser": "4.3.5", "fast-xml-parser": "4.3.6",
"mathjs": "12.4.0", "mathjs": "12.4.1",
"ms": "2.1.3", "ms": "2.1.3",
"node-cron": "3.0.3", "node-cron": "3.0.3",
"pg": "8.11.3", "pg": "8.11.3",
"pg-hstore": "2.3.4", "pg-hstore": "2.3.4",
"postgres-array": "3.0.2", "postgres-array": "3.0.2",
"redis": "4.6.13", "redis": "4.6.13",
"simple-git": "3.22.0", "simple-git": "3.23.0",
"systeminformation": "5.22.0", "systeminformation": "5.22.3",
"undici": "6.7.1" "undici": "6.9.0"
}, },
"devDependencies": { "devDependencies": {
"@types/ms": "0.7.34", "@types/ms": "0.7.34",
"@types/node": "20.11.25", "@types/node": "20.11.28",
"@types/node-cron": "3.0.11", "@types/node-cron": "3.0.11",
"@types/pg": "8.11.2", "@types/pg": "8.11.2",
"typescript": "5.4.2" "typescript": "5.4.2"

View File

@ -4,7 +4,7 @@ import Logger from '../helpers/Logger.js';
export default class Automoderator { export default class Automoderator {
private static logPrefix:string = 'Automod'; private static logPrefix:string = 'Automod';
private static lockQuery:Set<Discord.Snowflake> = new Set(); private static lockQuery:Set<Discord.Snowflake> = new Set();
static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b|ed\b/g, '').split(' ').join(''); static scanMsg =(message:Discord.Message)=>message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b|ed\b|es\b/g, '').split(' ').join('');
static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban'|'softban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) { static async repeatedMessages(client:TClient, message:Discord.Message, action:'mute'|'ban'|'softban', thresholdTime:number, thresholdAmount:number, type:string, duration:string, reason:string) {
const now = Date.now(); const now = Date.now();

View File

@ -29,6 +29,7 @@ export default class CacheServer {
if (jsonMode) return await RedisClient.json.set(key, '.', value); if (jsonMode) return await RedisClient.json.set(key, '.', value);
else return await RedisClient.set(key, JSON.stringify(value)); else return await RedisClient.set(key, JSON.stringify(value));
} }
/** @param time Cache expiration in seconds */
public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong public static expiry = async(key:any, time:number)=>await RedisClient.expire(key, time); // NOTE: time is in seconds, not milliseconds -- you know what you did wrong
public static delete = async(key:any)=>await RedisClient.del(key); public static delete = async(key:any)=>await RedisClient.del(key);
public static init() { public static init() {

View File

@ -2,6 +2,7 @@ import Discord from 'discord.js';
import TClient from '../client.js'; import TClient from '../client.js';
import Logger from '../helpers/Logger.js'; import Logger from '../helpers/Logger.js';
import MessageTool from '../helpers/MessageTool.js'; import MessageTool from '../helpers/MessageTool.js';
import CacheServer from '../components/CacheServer.js';
const logPrefix = 'Interaction'; const logPrefix = 'Interaction';
export default class InteractionCreate { export default class InteractionCreate {
static async run(client:TClient, interaction:Discord.BaseInteraction){ static async run(client:TClient, interaction:Discord.BaseInteraction){
@ -41,17 +42,24 @@ export default class InteractionCreate {
return console.log('An error occurred while running autocomplete:\n', error) return console.log('An error occurred while running autocomplete:\n', error)
} }
} }
static handleButton(client:TClient, interaction:Discord.ButtonInteraction<'cached'>) { static async handleButton(client:TClient, interaction:Discord.ButtonInteraction<'cached'>) {
const time = Date.now();
if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){ if (interaction.customId.startsWith('reaction-') && client.config.botSwitches.buttonRoles){
const RoleID = interaction.customId.replace('reaction-',''); const RoleID = interaction.customId.replace('reaction-','');
let key = `${interaction.user.id}:role_room`;
const isRatelimited = await CacheServer.get(key, false);
const timeDiff = time - isRatelimited;
if (timeDiff < 5000) return interaction.reply({content: 'You are on **__cooldown__**, please avoid spam-clicking next time.\n\n*This system is put in place due to selfbots.. I\'m sorry!*', ephemeral: true});
const MFFarm1 = '1149139369433776269'; const MFFarm1 = '1149139369433776269';
const MFFarm2 = '1149139583729160325'; const MFFarm2 = '1149139583729160325';
if (interaction.member.roles.cache.has(RoleID)) interaction.member.roles.remove(RoleID, 'Button Role').then(()=>interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true})); if (interaction.member.roles.cache.has(RoleID)) interaction.member.roles.remove(RoleID, 'Button Role').then(()=>interaction.reply({content: `You have been removed from <@&${RoleID}>`, ephemeral: true}));
else interaction.member.roles.add(RoleID, 'Button Role').then(()=>{ else interaction.member.roles.add(RoleID, 'Button Role').then(async()=>{
this.roleConflictHandler(interaction, MFFarm1, MFFarm2, RoleID); this.roleConflictHandler(interaction, MFFarm1, MFFarm2, RoleID);
interaction.reply({content: `You have been added to <@&${RoleID}>`, ephemeral: true, fetchReply: true}) await interaction.reply({content: `You have been added to <@&${RoleID}>`, ephemeral: true, fetchReply: true});
CacheServer.set(key, time, false).then(()=>CacheServer.expiry(key, 10));
}); });
} else if (interaction.customId.includes('deleteEvalEmbed')) { } else if (interaction.customId.includes('deleteEvalEmbed')) {
if (!client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You are not whitelisted, therefore you cannot delete this message.', ephemeral: true}); if (!client.config.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You are not whitelisted, therefore you cannot delete this message.', ephemeral: true});

View File

@ -66,7 +66,10 @@ setInterval(async()=>{
if (!dailyMsgs.find(x=>x.dataValues.day === formattedDate)) { if (!dailyMsgs.find(x=>x.dataValues.day === formattedDate)) {
let total = (await client.userLevels.fetchEveryone()).reduce((a,b)=>a + b.messages, 0); // Sum of all users let total = (await client.userLevels.fetchEveryone()).reduce((a,b)=>a + b.messages, 0); // Sum of all users
const yesterday = dailyMsgs.find(x=>x.day === formattedDate - 1) const yesterday = dailyMsgs.find(x=>x.day === formattedDate - 1)
if (total < yesterday?.total) total = yesterday.total; // Messages went down. if (yesterday && total < yesterday.total) Logger.console('log', 'DailyMsgs', `Total messages for day ${formattedDate} is less than total messages for day ${formattedDate - 1}.`);
// Update total if it's the same as yesterday's total
if (yesterday && total === yesterday.total) total = (await client.userLevels.fetchEveryone()).reduce((a,b)=>a + b.messages, 0); // Recalculate total
await client.dailyMsgs.newDay(formattedDate, total); await client.dailyMsgs.newDay(formattedDate, total);
Logger.console('log', 'DailyMsgs', `Pushed [${formattedDate}, ${total}]`) Logger.console('log', 'DailyMsgs', `Pushed [${formattedDate}, ${total}]`)

View File

@ -8,7 +8,6 @@ import {IServer} from '../models/MPServer.js';
import {XMLParser} from 'fast-xml-parser'; import {XMLParser} from 'fast-xml-parser';
import {FSPlayer, FSData, FSCareerSavegame} from 'src/interfaces'; import {FSPlayer, FSData, FSCareerSavegame} from 'src/interfaces';
let failedAttempts:number = 0;
let loggingPrefix:string = 'MPModule'; let loggingPrefix:string = 'MPModule';
let dataUnavailable:string = 'Unavailable'; let dataUnavailable:string = 'Unavailable';
export let refreshTimerSecs:number = 45000; export let refreshTimerSecs:number = 45000;
@ -17,6 +16,10 @@ let refreshIntrvlTxt:string = `Refreshes every ${refreshTimerSecs/1000} seconds.
let offlineStatus:string = 'Server is offline'; let offlineStatus:string = 'Server is offline';
let unavailableStatus:string = 'Server didn\'t respond'; let unavailableStatus:string = 'Server didn\'t respond';
interface IServerExt extends IServer {
failureCount?:number;
}
export default async(client:TClient)=>{ export default async(client:TClient)=>{
const message = await (client.channels.resolve(isBotInDevMode ? '1091300529696673792' : '543494084363288637') as Discord.TextChannel).messages.fetch(isBotInDevMode ? '1104563309451161742' : '1149141188079779900'); const message = await (client.channels.resolve(isBotInDevMode ? '1091300529696673792' : '543494084363288637') as Discord.TextChannel).messages.fetch(isBotInDevMode ? '1104563309451161742' : '1149141188079779900');
if (!client.config.botSwitches.mpSys) return message.edit({content: null, embeds: [mpModuleDisabled(client)]}); if (!client.config.botSwitches.mpSys) return message.edit({content: null, embeds: [mpModuleDisabled(client)]});
@ -123,25 +126,34 @@ async function multifarmWebhook(client:TClient, server:IServer, webhookId:string
}) })
} }
export async function requestServerData(client:TClient, server:IServer):Promise<{dss:FSData, csg:FSCareerSavegame}|undefined>{ export async function requestServerData(client:TClient, server:IServerExt):Promise<{dss:FSData, csg:FSCareerSavegame}|undefined>{
async function retryReqs(url:string) { async function retryReqs(url:string) {
// Attempt to reduce the failure rate of the requests before giving up and retrying in next refresh. // Attempt to reduce the failure rate of the requests before giving up and retrying in next refresh.
let maxRetries:number = 3; let maxRetries:number = 4;
let delay:number = 500;
for (let i = 0; i < maxRetries; i++) { for (let i = 0; i < maxRetries; i++) {
try { try {
const data = await Undici.fetch(url, {keepalive: true, signal: AbortSignal.timeout(12000), headers: {'User-Agent': `${client.user.username} - MPModule/undici`}}); const data = await Undici.fetch(url, {keepalive: true, signal: AbortSignal.timeout(12000), headers: {'User-Agent': `${client.user.username} - MPModule/undici`}});
if (data.status === 200 ?? 204) return data; if (data.status === 200 ?? 204) {
else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`) server.failureCount = 0;
delay = 500;
return data
} else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`);
else if (data.status === 400) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (400), bad endpoint or ratelimited`); // Seems to be taking L's left and right hourly...
} catch(err) { } catch(err) {
Logger.console('log', loggingPrefix, `Couldn't get data for ${server.serverName}: ${err.message}`); Logger.console('log', loggingPrefix, `Couldn't get data for ${server.serverName}: ${err.message}`);
failedAttempts++; server.failureCount++;
if (failedAttempts >= 5 && server.isActive) { if (server.failureCount >= 6 && server.isActive) {
Logger.console('log', loggingPrefix, `Maximum failed requests (${failedAttempts}) reached for ${server.serverName}, silenced server for 10 minutes`); Logger.console('log', loggingPrefix, `Maximum failed requests (${server.failureCount}) reached for ${server.serverName}, silenced server for 10 minutes`);
silenceServer(client, server, 600000); silenceServer(client, server, 600000);
} }
return null; return null;
} }
await new Promise(resolve=>setTimeout(resolve, 500)) await new Promise(resolve=>setTimeout(resolve, delay));
delay *= 2;
Logger.console('log', loggingPrefix, `Request delayed by ${delay} for ${server.serverName}`);
// Workaround for the API ratelimit (seen by panel responding with HTTP 400 apparently...)
} }
return null; return null;
} }
@ -189,8 +201,8 @@ function convertPlayerUptime(playTime:number) {
return (Days > 0 ? Days+' d ':'')+(Hours > 0 ? Hours+' h ':'')+(Minutes > 0 ? Minutes+' m':'') return (Days > 0 ? Days+' d ':'')+(Hours > 0 ? Hours+' h ':'')+(Minutes > 0 ? Minutes+' m':'')
} }
function silenceServer(client:TClient, server:IServer, time:number):void { function silenceServer(client:TClient, server:IServerExt, time:number):void {
client.MPServer.toggleServerUsability(server.serverName, false); client.MPServer.toggleServerUsability(server.serverName, false);
setTimeout(()=>client.MPServer.toggleServerUsability(server.serverName, true), time) setTimeout(()=>client.MPServer.toggleServerUsability(server.serverName, true), time)
failedAttempts = 0; server.failureCount = 0;
} }

View File

@ -5,7 +5,7 @@ __metadata:
version: 8 version: 8
cacheKey: 10 cacheKey: 10
"@babel/runtime@npm:^7.23.9": "@babel/runtime@npm:^7.24.0":
version: 7.24.0 version: 7.24.0
resolution: "@babel/runtime@npm:7.24.0" resolution: "@babel/runtime@npm:7.24.0"
dependencies: dependencies:
@ -530,12 +530,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:20.11.25": "@types/node@npm:*, @types/node@npm:20.11.28":
version: 20.11.25 version: 20.11.28
resolution: "@types/node@npm:20.11.25" resolution: "@types/node@npm:20.11.28"
dependencies: dependencies:
undici-types: "npm:~5.26.4" undici-types: "npm:~5.26.4"
checksum: 10/861265f1bbb151404bd8842b595f027a4ff067c61ecff9a37b9f7f53922c18dd532c8e795e8e7675dd8dba056645623fd2b9848d5ef72863ec3609096cd2923e checksum: 10/b03f69213ac6e7cd5f7efa86139f24e23ff70a12fed04adeac5413b62d6982343ce94906f74c401c5afefda48d36ae0efd6a575240996b15a5cf80b456ab4221
languageName: node languageName: node
linkType: hard linkType: hard
@ -642,24 +642,24 @@ __metadata:
"@sequelize/core": "npm:7.0.0-alpha.37" "@sequelize/core": "npm:7.0.0-alpha.37"
"@toast/tokenservice-client": "npm:1.0.16" "@toast/tokenservice-client": "npm:1.0.16"
"@types/ms": "npm:0.7.34" "@types/ms": "npm:0.7.34"
"@types/node": "npm:20.11.25" "@types/node": "npm:20.11.28"
"@types/node-cron": "npm:3.0.11" "@types/node-cron": "npm:3.0.11"
"@types/pg": "npm:8.11.2" "@types/pg": "npm:8.11.2"
ansi-colors: "npm:4.1.3" ansi-colors: "npm:4.1.3"
dayjs: "npm:1.11.10" dayjs: "npm:1.11.10"
discord.js: "npm:14.14.1" discord.js: "npm:14.14.1"
fast-xml-parser: "npm:4.3.5" fast-xml-parser: "npm:4.3.6"
mathjs: "npm:12.4.0" mathjs: "npm:12.4.1"
ms: "npm:2.1.3" ms: "npm:2.1.3"
node-cron: "npm:3.0.3" node-cron: "npm:3.0.3"
pg: "npm:8.11.3" pg: "npm:8.11.3"
pg-hstore: "npm:2.3.4" pg-hstore: "npm:2.3.4"
postgres-array: "npm:3.0.2" postgres-array: "npm:3.0.2"
redis: "npm:4.6.13" redis: "npm:4.6.13"
simple-git: "npm:3.22.0" simple-git: "npm:3.23.0"
systeminformation: "npm:5.22.0" systeminformation: "npm:5.22.3"
typescript: "npm:5.4.2" typescript: "npm:5.4.2"
undici: "npm:6.7.1" undici: "npm:6.9.0"
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -759,14 +759,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fast-xml-parser@npm:4.3.5": "fast-xml-parser@npm:4.3.6":
version: 4.3.5 version: 4.3.6
resolution: "fast-xml-parser@npm:4.3.5" resolution: "fast-xml-parser@npm:4.3.6"
dependencies: dependencies:
strnum: "npm:^1.0.5" strnum: "npm:^1.0.5"
bin: bin:
fxparser: src/cli/cli.js fxparser: src/cli/cli.js
checksum: 10/ccfd943e4ed400bf3acd4b6fcba9a15ec992a4a76c9a0cf825fc06f2b35a79a6d1de477b9a73c23633597c4f2a35838550ec3013a056f2591aa8cb3989d1f242 checksum: 10/3e431e594960f04996e60a01fb51d8f4346138a7ba60d97244bf7866a3072eaf2f6dc73008d7b07871b98b606a8d7db955efdeae787992f685dd0e5bcc67c36a
languageName: node languageName: node
linkType: hard linkType: hard
@ -878,11 +878,11 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"mathjs@npm:12.4.0": "mathjs@npm:12.4.1":
version: 12.4.0 version: 12.4.1
resolution: "mathjs@npm:12.4.0" resolution: "mathjs@npm:12.4.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.23.9" "@babel/runtime": "npm:^7.24.0"
complex.js: "npm:^2.1.1" complex.js: "npm:^2.1.1"
decimal.js: "npm:^10.4.3" decimal.js: "npm:^10.4.3"
escape-latex: "npm:^1.2.0" escape-latex: "npm:^1.2.0"
@ -893,7 +893,7 @@ __metadata:
typed-function: "npm:^4.1.1" typed-function: "npm:^4.1.1"
bin: bin:
mathjs: bin/cli.js mathjs: bin/cli.js
checksum: 10/ee168a7e4be0bebe9fbd69292462f162d6aae973500e00dbf00f44392ccf80f4de86883819576df2434e9b3e4d6c222a14613e2c0450db8316c373f130bee2b6 checksum: 10/171cdf4b6ad4786f902d112d4208a2e5b02381cd08a2b974d957b56d0102808064ddfcc7b953bef6022ad0302f3181b7f6146b3be6b54a240579a36b90c463ff
languageName: node languageName: node
linkType: hard linkType: hard
@ -1224,14 +1224,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"simple-git@npm:3.22.0": "simple-git@npm:3.23.0":
version: 3.22.0 version: 3.23.0
resolution: "simple-git@npm:3.22.0" resolution: "simple-git@npm:3.23.0"
dependencies: dependencies:
"@kwsites/file-exists": "npm:^1.1.1" "@kwsites/file-exists": "npm:^1.1.1"
"@kwsites/promise-deferred": "npm:^1.1.1" "@kwsites/promise-deferred": "npm:^1.1.1"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
checksum: 10/309e7f0b73550f99949c0c6cfd4b4799ec0452fc4835dc440f89ec9351fe553c979c4e2bf7a772308e608697d3a27512281fbc64df0328a73607641f389b0aaf checksum: 10/08ddfcbc310bfeaba066ef7b0d178967d9984aa1bc5e29f0360d166b0ccf820a3e5bb67d02036fca40fde6cdfc998f2b5fb2db9a8bbbad29b4feb4c1391f39e0
languageName: node languageName: node
linkType: hard linkType: hard
@ -1249,12 +1249,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"systeminformation@npm:5.22.0": "systeminformation@npm:5.22.3":
version: 5.22.0 version: 5.22.3
resolution: "systeminformation@npm:5.22.0" resolution: "systeminformation@npm:5.22.3"
bin: bin:
systeminformation: lib/cli.js systeminformation: lib/cli.js
checksum: 10/a739041bf0ef572eaebd06819ed54bb5f4a785793e3d542f16f39914ae5bbbf7d44b204ec936dcf560056709e97e2e55c11ee3ceda7b9585e778979f63ab7e3b checksum: 10/a4b0bf49e5319424c828aff805a7cf158235ec79407039acfa13133e9dcfe2b6121aaafeffec94cae45dc85899dd91fd00583a4bc018ed507d38a4aea7ae6459
conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android) conditions: (os=darwin | os=linux | os=win32 | os=freebsd | os=openbsd | os=netbsd | os=sunos | os=android)
languageName: node languageName: node
linkType: hard linkType: hard
@ -1362,10 +1362,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici@npm:6.7.1": "undici@npm:6.9.0":
version: 6.7.1 version: 6.9.0
resolution: "undici@npm:6.7.1" resolution: "undici@npm:6.9.0"
checksum: 10/7e66eb7fb6b3641efc9381b335334a7fe0d69d4b8004147b2a7658f279adfd392fb908acf71627e2cd1f863d9ab4d5b1470139364468d486ab69aee43a8246e5 checksum: 10/ee227517586f96b73db3b7a24387f101d191df6a6395ec0199688d6e56195dbe8c9d3456be2fa4a70af30fb1a9a905142826f9bf89c328dec842f00b55e9e5c2
languageName: node languageName: node
linkType: hard linkType: hard