mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fixed typing and added createChannel
This commit is contained in:
@@ -384,6 +384,35 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
// def createChannel
|
||||
|
||||
InternalClient.prototype.createChannel = function createChannel(server, name) {
|
||||
var type = arguments.length <= 2 || arguments[2] === undefined ? "text" : arguments[2];
|
||||
|
||||
var self = this;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
server = self.resolver.resolveServer(server);
|
||||
|
||||
request.post(Endpoints.SERVER_CHANNELS(server.id)).set("authorization", self.token).send({
|
||||
name: name, type: type
|
||||
}).end(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
var channel;
|
||||
if (res.body.type === "text") {
|
||||
channel = new TextChannel(res.body, self.client, server);
|
||||
} else {
|
||||
channel = new VoiceChannel(res.body, self.client, server);
|
||||
}
|
||||
resolve(server.channels.add(self.channels.add(channel)));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
InternalClient.prototype.sendWS = function sendWS(object) {
|
||||
if (this.websocket) this.websocket.send(JSON.stringify(object));
|
||||
};
|
||||
@@ -760,11 +789,14 @@ var InternalClient = (function () {
|
||||
var channel = self.channels.get("id", data.channel_id);
|
||||
|
||||
if (user && channel) {
|
||||
|
||||
user.typing.since = Date.now();
|
||||
user.typing.channel = channel;
|
||||
client.emit("userTypingStart", user, channel);
|
||||
|
||||
if (user.typing.since) {
|
||||
user.typing.since = Date.now();
|
||||
user.typing.channel = channel;
|
||||
} else {
|
||||
user.typing.since = Date.now();
|
||||
user.typing.channel = channel;
|
||||
client.emit("userTypingStart", user, channel);
|
||||
}
|
||||
setTimeout(function () {
|
||||
if (Date.now() - user.typing.since > 5990) {
|
||||
// they haven't typed since
|
||||
|
||||
Reference in New Issue
Block a user