hackchat-engine 1.1.18 → 1.1.20

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.
@@ -14,15 +14,19 @@ class UpdateUser extends AbstractEvent {
14
14
  const { client } = this;
15
15
  const user = client.users.get(data.userid);
16
16
 
17
+ let targetUser = null;
18
+
17
19
  if (user) {
18
20
  user.updateUser(data);
21
+ targetUser = user;
19
22
  }
20
23
 
21
24
  if (client.myUser && client.myUser.userid === data.userid) {
22
25
  client.myUser.updateUser(data);
26
+ targetUser = client.myUser;
23
27
  }
24
28
 
25
- return user;
29
+ return targetUser || user;
26
30
  }
27
31
  }
28
32
 
@@ -1,4 +1,5 @@
1
1
  import AbstractEvent from './AbstractEvent.js';
2
+ import { Events } from '../util/Constants.js';
2
3
 
3
4
  /**
4
5
  * This class handles an incoming `leave` event from the server
@@ -19,10 +20,16 @@ class UserLeave extends AbstractEvent {
19
20
 
20
21
  if (user.channels.size === 0) {
21
22
  user.online = false;
23
+ user.userEffect = 0;
24
+
25
+ client.emit(Events.USER_UPDATE, user);
22
26
  }
23
27
  }
24
28
 
25
- return user;
29
+ return {
30
+ user,
31
+ channel: data.channel,
32
+ };
26
33
  }
27
34
  }
28
35
 
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "lintfix": "eslint --fix --ignore-path .gitignore .",
60
60
  "test": "echo \"Error: no test specified\" && exit 1"
61
61
  },
62
- "version": "1.1.18"
62
+ "version": "1.1.20"
63
63
  }
@@ -11,10 +11,10 @@ class Emote {
11
11
  Object.defineProperty(this, 'client', { value: client });
12
12
 
13
13
  /**
14
- * User who sent the emote
15
- * @type {User}
16
- * @readonly
17
- */
14
+ * User who sent the emote
15
+ * @type {User}
16
+ * @readonly
17
+ */
18
18
  Object.defineProperty(this, 'user', { value: user });
19
19
 
20
20
  this.setup(data);
@@ -283,12 +283,12 @@ class User {
283
283
  if (typeof data.hash !== 'undefined') this.userhash = data.hash;
284
284
  if (typeof data.effect !== 'undefined') this.userEffect = data.effect;
285
285
 
286
- this.username = data.nick;
287
- this.userlevel = data.uType;
288
- this.botting = data.isBot;
289
- this.nickColor = data.color;
290
- this.flair = data.flair;
291
- this.permissionLevel = data.level;
286
+ if (typeof data.nick !== 'undefined') this.username = data.nick;
287
+ if (typeof data.uType !== 'undefined') this.userlevel = data.uType;
288
+ if (typeof data.isBot !== 'undefined') this.botting = data.isBot;
289
+ if (typeof data.color !== 'undefined') this.nickColor = data.color;
290
+ if (typeof data.flair !== 'undefined') this.flair = data.flair;
291
+ if (typeof data.level !== 'undefined') this.permissionLevel = data.level;
292
292
  }
293
293
 
294
294
  /**