mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Add TextBasedChannel.setTyping(bool)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -376,6 +376,14 @@ class RESTMethods {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendTyping(channelID) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.rest.makeRequest('post', `${Constants.Endpoints.channel(channelID)}/typing`, true)
|
||||||
|
.then(resolve)
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateGuildRole(role, _data) {
|
updateGuildRole(role, _data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class ClientUser extends User {
|
|||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.email = data.email;
|
this.email = data.email;
|
||||||
|
|
||||||
|
this._typing = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ class DMChannel extends Channel {
|
|||||||
bulkDelete() {
|
bulkDelete() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTyping() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(DMChannel, true);
|
TextBasedChannel.applyToClass(DMChannel, true);
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ class GroupDMChannel extends Channel {
|
|||||||
bulkDelete() {
|
bulkDelete() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTyping() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(GroupDMChannel, true);
|
TextBasedChannel.applyToClass(GroupDMChannel, true);
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ class TextChannel extends GuildChannel {
|
|||||||
bulkDelete() {
|
bulkDelete() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTyping() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextBasedChannel.applyToClass(TextChannel, true);
|
TextBasedChannel.applyToClass(TextChannel, true);
|
||||||
|
|||||||
@@ -98,6 +98,28 @@ class TextBasedChannel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts or stops a typing indicator in the channel.
|
||||||
|
* <info>It can take a few seconds for the Client User to stop typing.</info>
|
||||||
|
* @param {Boolean} typing whether or not the client user should be typing
|
||||||
|
* @returns {null}
|
||||||
|
* @example
|
||||||
|
* // start typing in a channel
|
||||||
|
* channel.setTyping(true);
|
||||||
|
* @example
|
||||||
|
* // stop typing in a channel
|
||||||
|
* channel.setTyping(false);
|
||||||
|
*/
|
||||||
|
setTyping(typing) {
|
||||||
|
clearInterval(this.client.user._typing.get(this.id));
|
||||||
|
if (typing) {
|
||||||
|
this.client.user._typing.set(this.id, setInterval(() => {
|
||||||
|
this.client.rest.methods.sendTyping(this.id);
|
||||||
|
}, 4000));
|
||||||
|
this.client.rest.methods.sendTyping(this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_cacheMessage(message) {
|
_cacheMessage(message) {
|
||||||
const maxSize = this.client.options.max_message_cache;
|
const maxSize = this.client.options.max_message_cache;
|
||||||
if (maxSize === 0) {
|
if (maxSize === 0) {
|
||||||
@@ -125,6 +147,7 @@ exports.applyToClass = (structure, full = false) => {
|
|||||||
props.push('_cacheMessage');
|
props.push('_cacheMessage');
|
||||||
props.push('getMessages');
|
props.push('getMessages');
|
||||||
props.push('bulkDelete');
|
props.push('bulkDelete');
|
||||||
|
props.push('setTyping');
|
||||||
}
|
}
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
applyProp(structure, prop);
|
applyProp(structure, prop);
|
||||||
|
|||||||
Reference in New Issue
Block a user