Class: WebUserData

WebUserData

The user data injected to be sent along with all user request to the web API.

new WebUserData(id, ip)

Create an instance of the user metadata.
Parameters:
Name Type Description
id string User ID of user performing request.
ip string IP of current request client.
Source:

Members


<private> _guilds :null|Array.<string>

Array of guild IDs this user is a part of. This will only be available if request was made using the user's token with 'guilds' as a scope, and thus may not exist in all requests.* It may be used to improve efficiency, to prevent looking up all guilds with the user performing the request.
Type:
  • null | Array.<string>
Source:
See:
  • {WebUserData~guilds}

<private, constant> _id :string

The user's ID.
Type:
  • string
Source:
See:
  • {WebUserData~id}

<private, constant> _ip :string

IP address of requesting client. Used for logging and rate limiting.
Type:
  • string
Source:
See:
  • {WebUserData~ip}

<private> _session :object

Legacy session data.
Type:
  • object
Deprecated:
  • Yes
Default Value:
  • {"id":"","expiration_date":""}
Source:

<private, nullable> _sessionExpirationDate :number

Session expiration timestamp for the user request.
Type:
  • number
Source:

<private, nullable> _sessionId :string

Session ID for the user request. Null if request was not made as a session.
Type:
  • string
Source:

<private> apiRequest :boolean

Is this user data, and this request, from the public API. If false, there are fewer restrictions because this request is from a private filtered internal source.
Type:
  • boolean
Source:

<nullable> avatar :string

Type:
  • string
Source:

<nullable> bot :boolean

Type:
  • boolean
Source:

<nullable> discriminator :string

Type:
  • string
Source:

<nullable> flags :number

Type:
  • number
Source:

guilds

Getter for guild list.
Source:
See:
  • WebUserData~_guilds

id

Getter for user ID.
Source:
See:
  • WebUserData~_id

ip

Getter for client IP address.
Source:
See:
  • WebUserData~_ip

<nullable> locale :string

Type:
  • string
Source:

<nullable> mfaEnabled :boolean

Is two factor authentication enabled on this user's account. https://discordapp.com/developers/docs/resources/user#user-object.
Type:
  • boolean
Source:

<nullable> premiumType :number

Type:
  • number
Source:

serializable

Get a serializable version of this class instance. Behaves differently than HG serializable getters in that private variables are converted to public instead of being removed. Assumes all variables are serializable if they aren't a function.
Source:

sessionExpirationDate

Getter for session expiration timestamp.
Source:
See:
  • WebUserData~_sessionExpirationDate

sessionId

Getter for session ID.
Source:
See:
  • WebUserData~_sessionId

<nullable> username :string

Type:
  • string
Source:

Methods


<static> from(obj)

Create this object from a Discord User Object response data.
Parameters:
Name Type Description
obj object Object data from Discord.
Source:
Returns:
Created object.
Type
WebUserData

setGuilds(guilds)

Set the list of guilds for this user.
Parameters:
Name Type Description
guilds Array.<object> Array of guild data for this user.
Source:
See:

setSession(sId, date)

Setter for session ID and expiration date.
Parameters:
Name Type Argument Description
sId string <nullable>
Session ID or null to unset.
date number | Date | string Date or timestamp, or null to unset.
Source:
See:
  • WebUserData~_sessionId
  • WebUserData~_sessionExpirationDate

setSessionExpirationDate(sED)

Setter for session expiration timestamp.
Parameters:
Name Type Description
sED number | Date | string Date or timestamp, or null to unset.
Source:
See:
  • WebUserData~_sessionExpirationDate

setSessionId(sId)

Setter for session ID.
Parameters:
Name Type Argument Description
sId string <nullable>
Session ID or null to unset.
Source:
See:
  • WebUserData~_sessionId