gamerbot-module 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,11 +23,11 @@ export class ConfigData {
23
23
  Object.keys(this).forEach((key) => {
24
24
  if (key == "json_data")
25
25
  return;
26
- const value = Object.entries(this).find(([k, v]) => k == key &&
27
- ((!Array.isArray(v) &&
28
- !Object.is(v, this.json_data[key])) ||
29
- (Array.isArray(v) &&
30
- !GamerBotAPI.arraysEqual(v, this.json_data[key]))));
26
+ const value = Object.entries(this).find(([k, v]) => {
27
+ if (k != key)
28
+ return false;
29
+ return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
30
+ });
31
31
  if (value)
32
32
  changed_data[key] = value[1];
33
33
  });
@@ -31,11 +31,11 @@ export class GuildData {
31
31
  Object.keys(this).forEach((key) => {
32
32
  if (key == "json_data")
33
33
  return;
34
- const value = Object.entries(this).find(([k, v]) => k == key &&
35
- ((!Array.isArray(v) &&
36
- !Object.is(v, this.json_data[key])) ||
37
- (Array.isArray(v) &&
38
- !GamerBotAPI.arraysEqual(v, this.json_data[key]))));
34
+ const value = Object.entries(this).find(([k, v]) => {
35
+ if (k != key)
36
+ return false;
37
+ return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
38
+ });
39
39
  if (value)
40
40
  changed_data[key] = value[1];
41
41
  });
@@ -17,7 +17,8 @@ export declare class PorfileData {
17
17
  minecraftWhiteList: boolean;
18
18
  minecraftUsername: string;
19
19
  minecraftUuid: string;
20
- old_old_messages: Array<string>;
20
+ old_messages: Array<string>;
21
+ hashed_email: string;
21
22
  json_data: any;
22
23
  constructor(json_data: any);
23
24
  /**
@@ -21,7 +21,8 @@ export class PorfileData {
21
21
  this.minecraftWhiteList = json_data.minecraftWhiteList;
22
22
  this.minecraftUsername = json_data.minecraftUsername;
23
23
  this.minecraftUuid = json_data.minecraftUuid;
24
- this.old_old_messages = json_data.old_old_messages;
24
+ this.old_messages = json_data.old_messages;
25
+ this.hashed_email = json_data.hashed_email;
25
26
  }
26
27
  /**
27
28
  * Saves user data to database
@@ -33,11 +34,11 @@ export class PorfileData {
33
34
  Object.keys(this).forEach((key) => {
34
35
  if (key == "json_data")
35
36
  return;
36
- const value = Object.entries(this).find(([k, v]) => k == key &&
37
- ((!Array.isArray(v) &&
38
- !Object.is(v, this.json_data[key])) ||
39
- (Array.isArray(v) &&
40
- !GamerBotAPI.arraysEqual(v, this.json_data[key]))));
37
+ const value = Object.entries(this).find(([k, v]) => {
38
+ if (k != key)
39
+ return false;
40
+ return JSON.stringify(v) != JSON.stringify(this.json_data[key]);
41
+ });
41
42
  if (value)
42
43
  changed_data[key] = value[1];
43
44
  });
@@ -34,15 +34,20 @@ export class GamerBotAPI {
34
34
  }
35
35
  }
36
36
  static arraysEqual(a, b) {
37
- // if the other array is a falsy value, return
38
- if (!a)
39
- return false;
40
- // if the argument is the same array, we can be sure the contents are same as well
41
37
  if (a === b)
42
38
  return true;
43
- // compare lengths - can save a lot of time
44
- if (b.length != a.length)
39
+ if (a == null || b == null)
40
+ return false;
41
+ if (a.length !== b.length)
45
42
  return false;
43
+ for (let i = 0; i < a.length; ++i) {
44
+ if (typeof a[i] === 'object' && typeof b[i] === 'object') {
45
+ if (!this.arraysEqual(Object.entries(a[i]), Object.entries(b[i])))
46
+ return false;
47
+ }
48
+ else if (a[i] !== b[i])
49
+ return false;
50
+ }
46
51
  return true;
47
52
  }
48
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gamerbot-module",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",