Class: WebAccount

WebAccount

Manages the account webpage.

new WebAccount()

Source:

Extends

Members


<nullable> bot :SpikeyBot

The parent SpikeyBot instance. Defaults to required cache value for autocompletion, updates to current reference at init.
Type:
Inherited From:
Source:

client :Discord~Client

The current bot client. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord~Client
Inherited From:
Source:

command :Command

The command object for registering command listeners. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Source:

<constant> commit :string

The commit at HEAD at the time this module was loaded. Essentially the version of this submodule.
Type:
  • string
Inherited From:
Source:

common :Common

The common object. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
Inherited From:
Source:

Discord :Discord

The current Discord object instance of the bot. Defaults to require cache value for editor autocompletion, updates to current reference at init.
Type:
  • Discord
Inherited From:
Source:

<abstract> helpMessage :undefined|string|Discord~EmbedBuilder

The help message to show the user in the main help message.
Type:
  • undefined | string | Discord~EmbedBuilder
Inherited From:
Source:

<protected, readonly> initialized :boolean

Has this subModule been initialized yet (Has begin() been called).
Type:
  • boolean
Inherited From:
Source:

<constant> loadTime :number

The time at which this module was loaded for use in checking if the module needs to be reloaded because the file has been modified since loading.
Type:
  • number
Inherited From:
Source:

<abstract, protected> myName :string

The name of this submodule. Used for differentiating in the log. Should be defined before begin().
Type:
  • string
Inherited From:
Overrides:
Source:

<abstract> postPrefix :string

The postfix for the global prefix for this subModule. Must be defined before begin(), otherwise it is ignored.
Type:
  • string
Inherited From:
Source:

<private, inner, constant> patreonSettingsFilename :string

The filename in the user's directory of the file where the settings related to Patreon rewards are stored.
Type:
  • string
Default Value:
  • /patreonSettings.json
Source:

<private, inner> patreonSettingsTemplate :object.<object>

The parsed data from WebAccount~patreonSettingsTemplateFile. Data that outlines the available options that can be changed, and their possible values.
Type:
  • object.<object>
Default Value:
  • {}
Source:

<private, inner, constant> patreonSettingsTemplateFile :string

File where the template for the Patreon settings is stored.
Type:
  • string
Default Value:
  • ./save/patreonSettingTemplate.json
Source:
See:

<private, inner, constant> sockets :object.<Socket>

Map of all currently connected sockets.
Type:
  • object.<Socket>
Source:

Methods


begin(Discord, client, command, common, bot)

Initialize this submodule.
Parameters:
Name Type Description
Discord Discord The Discord object for the API library.
client Discord~Client The client that represents this bot.
command Command The command instance in which to register command listeners.
common Common Class storing common functions.
bot SpikeyBot The parent SpikeyBot instance.
Inherited From:
Source:

<protected> debug(msg)

Log using common.logDebug, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

end()

Trigger subModule to shutdown and get ready for process terminating.
Inherited From:
Source:

<protected> error(msg)

Log using common.error, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

<protected> initialize()

The function called at the end of begin() for further initialization specific to the subModule. Must be defined before begin() is called.
Inherited From:
Overrides:
Source:

<protected> log(msg)

Log using common.log, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

<abstract> reloadable()

Check if this module is in a state that is ready to be reloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state. This is different from unloadable, which checks if this module can be stopped completely, this checks if the module can be stopped and restarted.
Inherited From:
Source:
See:
  • SubModule~unloadable
Returns:
True if can be reloaded, false if cannot.
Type
boolean

<abstract> save( [opt])

Saves all data to files necessary for saving current state.
Parameters:
Name Type Argument Default Description
opt string <optional>
'sync' Can be 'async', otherwise defaults to synchronous.
Inherited From:
Source:

shutdown()

Causes a full shutdown of all servers.
Overrides:
Source:

unloadable()

Check if this module is in a state that is ready to be unloaded. If false is returned, this module should not be unloaded and doing such may risk putting the module into an uncontrollable state.
Inherited From:
Overrides:
Source:
See:
  • SubModule~reloadable
Returns:
True if can be unloaded, false if cannot.
Type
boolean

<protected> warn(msg)

Log using common.logWarning, but automatically set name.
Parameters:
Name Type Description
msg string The message to log.
Inherited From:
Source:

<private, inner> changePatreonSetting(userid, setting, value, cb)

Change a user's setting that is related to Patreon rewards.
Parameters:
Name Type Description
userid string | number The Discord id of the user to change the setting for.
setting string The name of the setting to change.
value string The value to set the setting to.
cb function Callback that is called once the operations are complete with a single parameter for errors, string if error, null if none.
Source:

<private, inner> dateToSQL(date)

Convert the given date into a format that SQL can understand.
Parameters:
Name Type Description
date * Something that `new Date()` can interpret.
Source:
Returns:
Formatted Datetime string not including fractions of a second.
Type
string

<private, inner> getPatreonSettings(userid, cb)

Fetch a user's current patreon settings from file.
Parameters:
Name Type Description
userid string | number Thd Discord id of the user to lookup.
cb function Callback with 2 parameters, the first is the error string or null if no error, the second will be the settings object if there is no error.
Source:

<private, inner> handler(req, res)

Handler for all http requests. Should never be called.
Parameters:
Name Type Description
req http.IncomingMessage The client's request.
res http.ServerResponse Our response to the client.
Source:

<private, inner> handleSpotifyTokenResponse(userid, content, ip, cb)

Handle the response after successfully requesting the user's tokens.
Parameters:
Name Type Description
userid string | number Discord user id.
content string The response from Spotify.
ip string Unique identifier for the client that caused this to happen. Used for logging.
cb function Callback with single parameter, string if error, null if no error.
Source:

<private, inner> handleSpotifyUserResponse(userid, content, vals, ip, cb)

Handle the response after successfully requesting the user's basic account information.
Parameters:
Name Type Description
userid string | number Discord user id.
content string The response from Spotify.
vals Object The object storing user session information.
ip string Unique identifier for the client that caused this to happen. Used for logging.
cb function Callback with single parameter, string if error, null if no error.
Source:

<private, inner> socketConnection(socket)

Handler for a new socket connecting.
Parameters:
Name Type Description
socket socketIo~Socket The socket.io socket that connected.
Source:

<private, inner> updatePatreonSettingsTemplate()

Parse template from file.
Source:
See:

<private, inner> updateUserPatreonId(userid, patreonid, cb)

Update our Discord table with the retrieved patreon account ID for the Discord user.
Parameters:
Name Type Description
userid string | number The Discord ID of the user to link to the patreonid.
patreonid string | number The Patreon id of the account to link to the Discord ID.
cb function Callback with single argument that is string if error, or null if no error.
Source:

<private, inner> updateUserSpotifyId(userid, spotifyid, cb)

Update our Discord table with the retrieved spotify account ID for the Discord user. Deletes row from Spotify table if the userId is falsey.
Parameters:
Name Type Description
userid string | number The Discord ID of the user to link to the patreonid.
spotifyid string | number The Spotify id of the account to link to the Discord ID.
cb function Callback with single argument that is string if error, or null if no error.
Source:

<private, inner> validatePatreonCode(code, userid, ip, cb)

Validate a code received from the client, then use it to retrieve the user ID associated with it.
Parameters:
Name Type Description
code string The code received from Patreon OAuth2 flow.
userid string | number The Discord user ID associated with this code in order to link accounts.
ip string The unique identifier for this connection for logging purposes.
cb function Callback with a single parameter. The parameter is a string if there was an error, or null if no error.
Source:

<private, inner> validateSpotifyCode(code, userid, ip, cb)

Validate a code received from the client, then use it to retrieve the user ID associated with it.
Parameters:
Name Type Description
code string The code received from Patreon OAuth2 flow.
userid string | number The Discord user ID associated with this code in order to link accounts.
ip string The unique identifier for this connection for logging purposes.
cb function Callback with a single parameter. The parameter is a string if there was an error, or null if no error.
Source: