Working friends support with events and requests

This commit is contained in:
Nicholas Tay
2016-03-30 21:01:48 +11:00
parent 8e6427963b
commit f591542735
6 changed files with 324 additions and 5 deletions

View File

@@ -115,6 +115,48 @@ export default class Client extends EventEmitter {
return this.internal.private_channels;
}
/**
* The friends that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>|null} a Cache of friend Users (or null if bot account)
* @readonly
* @example
* // log names of the friends that the client is aware of
* for(var user of client.friends){
* console.log(user.username);
* }
*/
get friends() {
return this.internal.friends;
}
/**
* The incoming friend requests that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>|null} a Cache of incoming friend request Users (or null if bot account)
* @readonly
* @example
* // log names of the incoming friend requests that the client is aware of
* for(var user of client.incomingFriendRequests){
* console.log(user.username);
* }
*/
get incomingFriendRequests() {
return this.internal.incoming_friend_requests;
}
/**
* The outgoing friend requests that the Client is aware of. Only available after `ready` event has been emitted.
* @type {Cache<User>} a Cache of outgoing friend request Users
* @readonly
* @example
* // log names of the outgoing friend requests that the client is aware of
* for(var user of client.outgoingFriendRequests){
* console.log(user.username);
* }
*/
get outgoingFriendRequests() {
return this.internal.outgoing_friend_requests;
}
/**
* The active voice connection of the Client, or null if not applicable. Only available after `ready` event has been emitted.
* @type {VoiceConnection|null} the voice connection (if any).
@@ -912,6 +954,18 @@ export default class Client extends EventEmitter {
.then(dataCallback(callback), errorCallback(callback));
}
// def addFriend
addFriend(user, callback = (/*err, {}*/) => {}) {
return this.internal.addFriend(user)
.then(dataCallback(callback), errorCallback(callback));
}
// def removeFriend
removeFriend(user, callback = (/*err, {}*/) => {}) {
return this.internal.removeFriend(user)
.then(dataCallback(callback), errorCallback(callback));
}
// def awaitResponse
awaitResponse(msg, toSend = null, options = null, callback = (/*err, newMsg*/) => { }) {
var ret;