diff --git a/lib/Client.js b/lib/Client.js index 54ed14d17..d3d6f1f78 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1728,7 +1728,7 @@ var Client = (function () { } }, { key: "startTyping", - value: function startTyping(chann) { + value: function startTyping(chann, stopTypeTime) { var self = this; this.resolveDestination(chann).then(next); @@ -1747,6 +1747,12 @@ var Client = (function () { var interval = setInterval(fn, 3000); self.typingIntervals[channel] = interval; + + if (stopTypeTime) { + setTimeout(function () { + self.stopTyping(channel); + }, stopTypeTime); + } } } }, { diff --git a/src/Client.js b/src/Client.js index 67b36bd7d..ef51e2c42 100644 --- a/src/Client.js +++ b/src/Client.js @@ -1469,7 +1469,7 @@ class Client { this.setStatusIdle(); } - startTyping(chann){ + startTyping(chann, stopTypeTime){ var self = this; this.resolveDestination(chann).then(next); @@ -1491,6 +1491,12 @@ class Client { var interval = setInterval(fn, 3000); self.typingIntervals[channel] = interval; + + if(stopTypeTime){ + setTimeout(function(){ + self.stopTyping(channel); + }, stopTypeTime); + } } } diff --git a/test/bot.1.js b/test/bot.1.js index 03c507889..4eb5ab07f 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -19,12 +19,7 @@ mybot.on("message", function (message) { var onlineUsers = 0; - mybot.startTyping(message.channel); - - setTimeout(function(){ - mybot.reply(message, "stopping now k"); - mybot.stopTyping(message.channel); - }, 6000); + mybot.startTyping(message.channel, 6000); });