mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Add User typing methods
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -84,6 +84,36 @@ class User {
|
||||
return Constants.Endpoints.avatar(this.id, this.avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the user is typing in a channel.
|
||||
* @param {ChannelResolvable} channel The channel to check in
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isTyping(channel) {
|
||||
channel = this.client.resolver.resolveChannel(channel);
|
||||
return channel._typing.has(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time that the user started typing.
|
||||
* @param {ChannelResolvable} channel The channel to get the time in
|
||||
* @returns {?Date}
|
||||
*/
|
||||
typingSince(channel) {
|
||||
channel = this.client.resolver.resolveChannel(channel);
|
||||
return channel._typing.has(this.id) ? new Date(channel._typing.get(this.id).since) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of time the user has been typing in a channel for (in milliseconds), or -1 if they're not typing.
|
||||
* @param {ChannelResolvable} channel The channel to get the time in
|
||||
* @returns {number}
|
||||
*/
|
||||
typingDuration(channel) {
|
||||
channel = this.client.resolver.resolveChannel(channel);
|
||||
return channel._typing.has(this.id) ? channel._typing.get(this.id).elapsedTime : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a DM Channel (if one exists) between the Client and the User. Resolves with the Channel if successful.
|
||||
* @returns {Promise<DMChannel>}
|
||||
|
||||
Reference in New Issue
Block a user