Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PartMan7/PS-Client
Browse files Browse the repository at this point in the history
  • Loading branch information
PartMan7 committed Jan 15, 2024
2 parents 3701194 + 5ffd89a commit 6171c4a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/user.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class User {
/**
* List of rooms the user is currently in
*/
rooms: { [key: string]: { isPrivate?: true } };
rooms: { [key: string]: { isPrivate?: true } } | false;
/**
* The Bot this user is attached to
*/
Expand Down
6 changes: 4 additions & 2 deletions client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Message from './classes/message';
import Room from './classes/room';
import User from './classes/user';

type UserDetails = { userid: string, [key: string]: any };

type ClientOpts = {
username: string,
password?: string,
Expand Down Expand Up @@ -114,7 +116,7 @@ export class Client extends events.EventEmitter {
* @param details The details of the user to add
* @returns The added User
*/
addUser (details: { userid: string, [key: string]: any }): User;
addUser (details: UserDetails): User;

/**
* Gets the specified user (or their current user, if they were seen on an alt)
Expand All @@ -129,7 +131,7 @@ export class Client extends events.EventEmitter {
* @param user The user being queried
* @returns A promise that resolves with the queried userdetails
*/
getUserDetails (userid: string): Promise<Message>;
getUserDetails (userid: string): Promise<UserDetails>;

/**
* Gets a (cached) room from its name (aliases not supported)
Expand Down
5 changes: 4 additions & 1 deletion client.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ class Client extends EventEmitter {
if (!userdetails) break;
this.addUser(userdetails);
const user = this._userdetailsQueue.find(u => u.id === userdetails.id);
if (user) user.resolve(userdetails);
if (user) {
user.resolve(userdetails);
this._userdetailsQueue.splice(this._userdetailsQueue.indexOf(user), 1);
}
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Bot.on('message', message => {

describe('PS-Client', () => {
before(function () {
this.timeout(30_000);
return new Promise((resolve, reject) => {
Bot.connect();
Bot.on('ready', () => resolve());
Expand Down

0 comments on commit 6171c4a

Please sign in to comment.