mirror of
https://github.com/danbulant/discord.js
synced 2026-07-05 03:00:35 +00:00
Webpack build for branch 11.3-dev: 2efe2d28f2
This commit is contained in:
parent
a33878101c
commit
f1639b5e71
2 changed files with 15 additions and 26 deletions
|
|
@ -5627,42 +5627,31 @@ class TextBasedChannel {
|
||||||
/**
|
/**
|
||||||
* Starts a typing indicator in the channel.
|
* Starts a typing indicator in the channel.
|
||||||
* @param {number} [count] The number of times startTyping should be considered to have been called
|
* @param {number} [count] The number of times startTyping should be considered to have been called
|
||||||
* @returns {Promise}
|
|
||||||
* @example
|
* @example
|
||||||
* // Start typing in a channel
|
* // Start typing in a channel
|
||||||
* channel.startTyping()
|
* channel.startTyping();
|
||||||
* .then(console.log)
|
|
||||||
* .catch(console.error);
|
|
||||||
*/
|
*/
|
||||||
startTyping(count) {
|
startTyping(count) {
|
||||||
if (typeof count !== 'undefined' && count < 1) throw new RangeError('Count must be at least 1.');
|
if (typeof count !== 'undefined' && count < 1) throw new RangeError('Count must be at least 1.');
|
||||||
if (this.client.user._typing.has(this.id)) {
|
if (this.client.user._typing.has(this.id)) {
|
||||||
const entry = this.client.user._typing.get(this.id);
|
const entry = this.client.user._typing.get(this.id);
|
||||||
entry.count = count || entry.count + 1;
|
entry.count = count || entry.count + 1;
|
||||||
return entry.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = {};
|
const entry = {
|
||||||
entry.promise = new Promise((resolve, reject) => {
|
count: count || 1,
|
||||||
Object.assign(entry, {
|
interval: this.client.setInterval(() => {
|
||||||
count: count || 1,
|
this.client.rest.methods.sendTyping(this.id).catch(() => {
|
||||||
interval: this.client.setInterval(() => {
|
this.client.clearInterval(entry.interval);
|
||||||
this.client.rest.methods.sendTyping(this.id).catch(error => {
|
this.client.user._typing.delete(this.id);
|
||||||
this.client.clearInterval(entry.interval);
|
});
|
||||||
this.client.user._typing.delete(this.id);
|
}, 9000),
|
||||||
reject(error);
|
};
|
||||||
});
|
this.client.rest.methods.sendTyping(this.id).catch(() => {
|
||||||
}, 9000),
|
this.client.clearInterval(entry.interval);
|
||||||
resolve,
|
this.client.user._typing.delete(this.id);
|
||||||
});
|
|
||||||
this.client.rest.methods.sendTyping(this.id).catch(error => {
|
|
||||||
this.client.clearInterval(entry.interval);
|
|
||||||
this.client.user._typing.delete(this.id);
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
this.client.user._typing.set(this.id, entry);
|
|
||||||
});
|
});
|
||||||
return entry.promise;
|
this.client.user._typing.set(this.id, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
2
discord.11.3-dev.min.js
vendored
2
discord.11.3-dev.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue