Added startTyping and stopTyping

This commit is contained in:
hydrabolt
2015-09-26 22:41:33 +01:00
parent 3094c223ec
commit 5fa7bace10
3 changed files with 93 additions and 9 deletions

View File

@@ -43,7 +43,7 @@ var Client = (function () {
this.user = null;
this.alreadySentData = false;
this.serverCreateListener = {};
this.typingIntervals = {};
this.email = "abc";
this.password = "abc";
@@ -1354,7 +1354,7 @@ var Client = (function () {
op: 2,
d: {
token: this.token,
v: 2,
v: 3,
properties: {
"$os": "discord.js",
"$browser": "discord.js",
@@ -1666,6 +1666,47 @@ var Client = (function () {
value: function setStatusAway() {
this.setStatusIdle();
}
}, {
key: "startTyping",
value: function startTyping(chann) {
var self = this;
this.resolveDestination(chann).then(next);
function next(channel) {
if (self.typingIntervals[channel]) {
return;
}
var fn = function fn() {
console.log(Endpoints.CHANNELS + "/" + channel + "/typing");
request.post(Endpoints.CHANNELS + "/" + channel + "/typing").set("authorization", self.token).end();
};
fn();
var interval = setInterval(fn, 3000);
self.typingIntervals[channel] = interval;
}
}
}, {
key: "stopTyping",
value: function stopTyping(chann) {
var self = this;
this.resolveDestination(chann).then(next);
function next(channel) {
if (!self.typingIntervals[channel]) {
return;
}
clearInterval(self.typingIntervals[channel]);
delete self.typingIntervals[channel];
}
}
}, {
key: "setStatus",
value: function setStatus(stat) {