fix: move invite info to client
Since static methods do not have access to `this.client`, it was giving an error when trying to call these functions. The client itself is a better place for them. close #258
This commit is contained in:
parent
6c7a3f9899
commit
ad9ae1f703
3 changed files with 14 additions and 21 deletions
3
index.d.ts
vendored
3
index.d.ts
vendored
|
|
@ -10,6 +10,9 @@ declare namespace WAWebJS {
|
||||||
/**Accepts an invitation to join a group */
|
/**Accepts an invitation to join a group */
|
||||||
acceptInvite(inviteCode: string): Promise<void>
|
acceptInvite(inviteCode: string): Promise<void>
|
||||||
|
|
||||||
|
/**Returns an object with information about the invite code's group */
|
||||||
|
getInviteInfo(inviteCode: string): Promise<object>
|
||||||
|
|
||||||
/** Enables and returns the archive state of the Chat */
|
/** Enables and returns the archive state of the Chat */
|
||||||
archiveChat(): Promise<boolean>
|
archiveChat(): Promise<boolean>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -478,6 +478,17 @@ class Client extends EventEmitter {
|
||||||
return ContactFactory.create(this, contact);
|
return ContactFactory.create(this, contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object with information about the invite code's group
|
||||||
|
* @param {string} inviteCode
|
||||||
|
* @returns {Promise<object>} Invite information
|
||||||
|
*/
|
||||||
|
async getInviteInfo(inviteCode) {
|
||||||
|
return await this.pupPage.evaluate(inviteCode => {
|
||||||
|
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||||
|
}, inviteCode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts an invitation to join a group
|
* Accepts an invitation to join a group
|
||||||
* @param {string} inviteCode Invitation code
|
* @param {string} inviteCode Invitation code
|
||||||
|
|
|
||||||
|
|
@ -136,27 +136,6 @@ class GroupChat extends Chat {
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an object with information about the invite code's group
|
|
||||||
* @param {string} inviteCode
|
|
||||||
* @returns {Promise<object>} Invite information
|
|
||||||
*/
|
|
||||||
static async getInviteInfo(inviteCode) {
|
|
||||||
return await this.client.pupPage.evaluate(inviteCode => {
|
|
||||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
|
||||||
}, inviteCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Joins a group with an invite code
|
|
||||||
* @param {string} inviteCode
|
|
||||||
*/
|
|
||||||
static async join(inviteCode) {
|
|
||||||
return await this.client.pupPage.evaluate(inviteCode => {
|
|
||||||
return window.Store.Wap.acceptGroupInvite(inviteCode);
|
|
||||||
}, inviteCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the bot leave the group
|
* Makes the bot leave the group
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue