Skip to content

Commit

Permalink
there are weird issues with a user with an undefined id
Browse files Browse the repository at this point in the history
  • Loading branch information
IRONM00N committed Dec 25, 2023
1 parent 6ee8989 commit 071ae26
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 253 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"neu-item-repo": true
},
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.format": true
"source.organizeImports": "explicit",
"source.format": "explicit"
},
"editor.formatOnSave": true,
"diffEditor.wordWrap": "on",
Expand Down
Empty file modified .yarn/releases/yarn-4.0.2.cjs
100644 → 100755
Empty file.
6 changes: 5 additions & 1 deletion lib/extensions/discord-akairo/TanzaniteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { BotCache } from '#lib/common/BotCache.js';
import { HighlightManager } from '#lib/common/HighlightManager.js';
import { AllowedMentions } from '#lib/utils/AllowedMentions.js';
import { BotClientUtils } from '#lib/utils/BotClientUtils.js';
import { emojis } from '#lib/utils/Constants.js';
import { TimeSec, emojis } from '#lib/utils/Constants.js';
import { Logger } from '#lib/utils/Logger.js';
import { updateEveryCache } from '#lib/utils/UpdateCache.js';
import { formatError, inspect } from '#lib/utils/Utils.js';
Expand Down Expand Up @@ -255,6 +255,10 @@ export class TanzaniteClient<Ready extends boolean = boolean> extends AkairoClie
}
}
}),
sweepers: {
...Options.DefaultSweeperSettings,
users: { interval: TimeSec.Hour, filter: () => (v, k) => k != null || v.id != null }
},
failIfNotExists: false,
rest: { api: 'https://canary.discord.com/api' }
});
Expand Down
9 changes: 8 additions & 1 deletion lib/extensions/discord.js/ExtendedUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { User } from 'discord.js';
import { Client, User } from 'discord.js';
import type { RawUserData } from 'discord.js/typings/rawDataTypes.js';
import type { TanzaniteClient } from '../discord-akairo/TanzaniteClient.js';

interface Extension {
Expand All @@ -19,6 +20,12 @@ declare module 'discord.js' {
}

export class ExtendedUser extends User implements Extension {
public constructor(client: Client<true>, data: RawUserData) {
super(client, data);

if (this.id == null) throw Error(`Invalid user id: ${this.id}`, { cause: this });
}

public override isOwner(): boolean {
return this.client.isOwner(this);
}
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"@discordjs/rest": "^2.2.0",
"@ironm00n/nbt-ts": "^1.4.0",
"@napi-rs/canvas": "^0.1.44",
"@sentry/integrations": "^7.83.0",
"@sentry/node": "^7.83.0",
"@sentry/tracing": "^7.83.0",
"@sentry/integrations": "^7.91.0",
"@sentry/node": "^7.91.0",
"@sentry/tracing": "^7.91.0",
"@tanzanite/deep-lock": "^1.1.1",
"@tanzanite/discord-akairo": "dev",
"@tanzanite/discord.js-minesweeper": "^1.2.0",
Expand All @@ -72,40 +72,40 @@
"@tanzanite/simplify-number": "^2.0.1",
"@tanzanite/wolfram-alpha": "^1.1.0",
"chalk": "^5.3.0",
"discord-api-types": "0.37.65",
"discord-api-types": "0.37.66",
"discord.js": "^14.14.1",
"fuse.js": "^7.0.0",
"googleapis": "^128.0.0",
"googleapis": "^129.0.0",
"lodash-es": "^4.17.21",
"mathjs": "12.1.0",
"nanoid": "^5.0.3",
"mathjs": "12.2.1",
"nanoid": "^5.0.4",
"numeral": "^2.0.6",
"pg": "^8.11.3",
"pg-hstore": "^2.3.4",
"prettier": "^3.1.0",
"prettier": "^3.1.1",
"pretty-bytes": "^6.1.1",
"rimraf": "^5.0.5",
"sequelize": "6.35.1",
"sequelize": "6.35.2",
"tinycolor2": "^1.6.0",
"typescript": "^5.3.2",
"typescript": "^5.3.3",
"vm2": "^3.9.19"
},
"devDependencies": {
"@sapphire/snowflake": "^3.5.1",
"@sentry/types": "^7.83.0",
"@types/eslint": "^8.44.7",
"@sapphire/snowflake": "^3.5.2",
"@sentry/types": "^7.91.0",
"@types/eslint": "^8.56.0",
"@types/express": "^4.17.21",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.10.0",
"@types/node": "^20.10.5",
"@types/node-fetch": "^2.6.9",
"@types/numeral": "^2.0.5",
"@types/pg": "^8.10.9",
"@types/tinycolor2": "^1.4.6",
"@types/validator": "^13.11.7",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-deprecation": "^2.0.0"
},
"packageManager": "[email protected]",
Expand Down
Loading

0 comments on commit 071ae26

Please sign in to comment.