mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added startTyping stopTyping and added serverchannel.mention()
This commit is contained in:
@@ -46,6 +46,7 @@ var InternalClient = (function () {
|
||||
this.channels = new Cache();
|
||||
this.servers = new Cache();
|
||||
this.private_channels = new Cache();
|
||||
this.typingIntervals = [];
|
||||
this.voiceConnection = null;
|
||||
this.resolver = new Resolver(this);
|
||||
this.readyTime = null;
|
||||
@@ -934,6 +935,53 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
//def startTyping
|
||||
|
||||
InternalClient.prototype.startTyping = function startTyping(channel) {
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
self.resolver.resolveChannel(channel).then(next)["catch"](reject);
|
||||
|
||||
function next(channel) {
|
||||
|
||||
if (self.typingIntervals[channel.id]) {
|
||||
// typing interval already exists, leave it alone
|
||||
reject(new Error("Already typing in that channel"));
|
||||
return;
|
||||
}
|
||||
|
||||
self.sendTyping(channel);
|
||||
|
||||
self.typingIntervals[channel.id] = setInterval(function () {
|
||||
return self.sendTyping(channel);
|
||||
}, 4000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//def stopTyping
|
||||
|
||||
InternalClient.prototype.stopTyping = function stopTyping(channel) {
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
self.resolver.resolveChannel(channel).then(next)["catch"](reject);
|
||||
|
||||
function next(channel) {
|
||||
|
||||
if (!self.typingIntervals[channel.id]) {
|
||||
// typing interval doesn't exist
|
||||
reject(new Error("Not typing in that channel"));
|
||||
return;
|
||||
}
|
||||
|
||||
clearInterval(self.typingIntervals[channel.id]);
|
||||
self.typingIntervals[channel.id] = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//def setTopic
|
||||
|
||||
InternalClient.prototype.setTopic = function setTopic(chann) {
|
||||
|
||||
Reference in New Issue
Block a user