Class: HGWeb

HGWeb

Creates a web interface for managing the Hungry Games. Expects ../hungryGames.js is loaded or will be loaded.

new HGWeb()

Source:

Members


<private, inner, constant> imageBuffer :object

Buffer storing all current image uploads and their associated meta-data.
Type:
  • object
Source:

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

Map of all sockets connected that are siblings.
Type:
  • object.<Socket>
Source:

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

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

Methods


addEvent(userData, socket, gId, type, eId [, cb])

Add an existing event to a guild's custom events.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId string The guild ID of the guild to modify.
type string The event category to add the event to.
eId string The event ID to add.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames~EventContainer~fetch

claimLegacyEvents(userData, socket, gId [, cb])

Claim legacy events to the user.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames~claimLegacy

createEvent(userData, socket, evt [, cb])

Create a game event.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
evt HungryGames~Event The event data of the event to create.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames~createEvent
  • HungryGames~EventContainer~fetch

createGame(userData, socket, gId [, cb])

Create a Game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.createGame

createStatGroup(userData, socket, guildId, name [, cb])

Create a stat group.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId string The guild id to look at.
name string <nullable>
The name of the new group.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

deleteEvent(userData, socket, eId [, cb])

Delete a game event.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
eId string The event ID to delete.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.deleteEvent

deleteStatGroup(userData, socket, guildId, groupId [, cb])

Delete a stat group.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId string The guild id to look at.
groupId string The group id to delete.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

editTeam(userData, socket, gId, cmd, one, two [, cb])

Edit the teams.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cmd string The command to run.
one string The first argument.
two string The second argument.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.editTeam

endGame(userData, socket, gId [, cb])

End the game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.endGame

excludeMember(userData, socket, gId, mId [, cb])

Exclude a member from the Games.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
mId number | string The member id to exclude.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.excludeUsers

fetchActions(userData, socket, gId [, cb])

Fetch the game's current action/trigger information.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchChannel(userData, socket, gId, cId [, cb])

Fetch data about a channel of a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cId number | string The channel's id to lookup.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchDay(userData, socket, gId [, cb])

Fetch the updated game's day information.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.getGame

fetchEvent(userData, socket, eId [, cb])

Fetch a single event data.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
eId string The event ID to fetch.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames~EventContainer~fetch

fetchGames(userData, socket, gId [, cb])

Fetch all game data within a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.getGame

fetchGuild(userData, socket, gId [, cb])

Fetch a single guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId string | number The ID of the guild that was requested.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchLeaderboard(userData, socket, guildId, groupId, opt [, cb])

Respond with leaderboard information.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId number | string The guild id to look at.
groupId string The ID of the group.
opt HGStatGroupUserSelectOptions Data select options.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchMember(userData, socket, gId, mId [, cb])

Fetch data about a member of a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
mId number | string The member's id to lookup.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchNextDay(userData, socket, gId [, cb])

Fetch the game's next day information.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.getGame

fetchRoles(userData, socket, gId [, cb])

Fetch data about a role in a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchStatGroupList(userData, socket, gId [, cb])

Respond with list of stat groups for the requested guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchStatGroupMetadata(userData, socket, guildId, groupId [, cb])

Respond with metadata for the requested stat group.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId number | string The guild id to look at.
groupId string The ID of the group.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchStats(userData, socket, guildId, groupId, userId [, cb])

Respond with stats for a specific user in a group.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId number | string The guild id to look at.
groupId string The ID of the group.
userId string The ID of the user.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

fetchUserEvents(userData, socket [, cb])

Fetch list of IDs of all events the user has created.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames~fetchUserEvents

forcePlayerState(userData, socket, gId, list, state [, text] [, persists] [, cb])

Force a player in the game to end a day in a certain state.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId number | string The guild id to run this command on.
list Array.<string> The list of user IDs of the players to effect.
state string The forced state.
text string <optional>
The message to show in the games as a result of this command.
persists boolean <optional>
Will this state be forced until the game ends.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames.forcePlayerState

gameStep(userData, socket, gId, cId [, cb])

Step the game once.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cId number | string Channel to send the messages in.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.gameStep

getNumClients()

Returns the number of connected clients that are not siblings.
Source:
Returns:
Number of sockets.
Type
number

imageChunk(userData, socket, gId, iId, chunkId, chunk [, cb])

Handle receiving image data for avatar uploading.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
iId string The image ID that is being uploaded.
chunkId string Id of the chunk being received.
chunk Buffer <nullable>
Chunk of data received, or null if all data has been sent.
cb function <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

imageInfo(userData, socket, gId, meta [, cb])

Handle client requesting to begin image upload.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
meta object Metadata to associate with this upload.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed. If succeeded, an upload ID will be passed as the second parameter. Any error will be the first parameter.
Source:

includeMember(userData, socket, gId, mId [, cb])

Include a member in the Games.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
mId number | string The member id to include.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.includeUsers

initialize()

Source:

insertAction(userData, socket, gId, trigger, action, args [, cb])

Add an action to a trigger in a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
trigger string The name of the trigger.
action string The name of the action.
args object Optional arguments to pass for the action creation.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

modifyInventory(userData, socket, gId, uId, weapon, count [, cb])

Give or take weapons from a player.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
uId string The ID of the user to give or take weapon from.
weapon string The ID of the weapon to give or take.
count number Number of weapons to give or take. Positive is give, negative is take.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

nextDay(userData, socket, gId, cId [, cb])

Start the next day.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cId number | string Channel to send the messages in.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.nextDay

pauseAutoplay(userData, socket, gId [, cb])

Disable autoplay.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.pauseAutoplay

pauseGame(userData, socket, gId [, cb])

Pause game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.pauseGame

removeAction(userData, socket, gId, trigger, id [, cb])

Remove an action from a trigger in a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
trigger string The name of the trigger.
id string The id of the action to remove.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

removeEvent(userData, socket, gId, type, eId [, cb])

Remove an event from a guild's custom events.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId string The guild ID of the guild to modify.
type string The event category to remove the event from.
eId string The event ID to remove.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames~EventContainer~remove

removeNPC(userData, socket, gId, npcId [, cb])

Remove an NPC from a game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId number | string The guild id to run this command on.
npcId string The ID of the NPC to remove.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames.removeNPC

renameGame(userData, socket, gId, name [, cb])

Rename the guild's game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId number | string The guild id to run this command on.
name string The name to change the game to.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames.renameGame

renameNPC(userData, socket, gId, npcId, username [, cb])

Rename an NPC in a game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId number | string The guild id to run this command on.
npcId string The ID of the NPC to rename.
username string The new username for the NPC.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames.renameNPC

replaceEvent(userData, socket, evt [, cb])

Replace a custom event with new data.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
evt HungryGames~Event The event data to update the event to.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames~replaceEvent

resetGame(userData, socket, gId, cmd [, cb])

Reset game data.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cmd string Command specifying what data to delete.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.resetGame

selectStatGroup(userData, socket, guildId, groupId [, cb])

Set the currently selected stat group.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
guildId string The guild id to look at.
groupId string <nullable>
The ID of the group to select, or null to set none.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

shutdown()

Causes a full shutdown of all servers.
Source:

startAutoplay(userData, socket, gId, cId [, cb])

Enable autoplay.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cId number | string Channel to send the messages in.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.startAutoplay

startGame(userData, socket, gId, cId [, cb])

Start the game.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
cId number | string Channel to start the game in.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.startGame

toggleEvent(userData, socket, gId, type, event, value [, cb])

Enable or disable an event without deleting it.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo-Socket The socket connection to reply on.
gId number | string The guild id to run this command on.
type string The type of event that we are toggling.
event string The ID of the event to toggle.
value boolean <nullable>
Set the enabled value instead of toggling.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete.
Source:
See:
  • HungryGames.toggleEvent

toggleOption(userData, socket, gId, option, value, extra [, cb])

Toggle an option in the Games.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
option string The option to change.
value string | number The value to set option to.
extra string The extra text if the option is in an object.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:
See:
  • HungryGames.setOption

updateAction(userData, socket, gId, trigger, id, key, value [, cb])

Update an action for a trigger in a guild.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
gId number | string The guild id to look at.
trigger string The name of the trigger.
id string The id of the action to remove.
key string The key of the value to change.
value number | string The value to set.
cb HGWeb~basicCB <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

<private, inner> beginImageUpload(uId)

Create an upload ID and buffer for a client to send to. Automatically cancelled after 60 seconds.
Parameters:
Name Type Description
uId string The user ID that started this upload.
Source:
Returns:
The metadata storing object.
Type
object

<private, inner> broadcastGame(hg, gId)

Handles broadcasting the game data to all relevant clients.
Parameters:
Name Type Description
hg HungryGames HG object firing event.
gId string The guild ID to data for.
Source:
Listens to Events:
  • HG#event:create
  • HG#event:refresh

<private, inner> cancelImageUpload(iId)

Cancel and clean up a current image upload.
Parameters:
Name Type Description
iId string Image upload ID to purge and abort.
Source:

<private, inner> checkChannelPerm(userData, gId, cId, cmd)

Check that the given user has permission to see and send messages in the given channel, as well as manage the games in the given guild.
Parameters:
Name Type Description
userData UserData The user to check.
gId string The guild id of the guild that contains the channel.
cId string The channel id to check against.
cmd string The command being attempted to check permisisons for.
Source:
Returns:
Whther the user has permission or not to manage the hungry games in the given guild and has permission to send messages in the given channel.
Type
boolean

<private, inner> checkMyGuild(gId)

Checks if the current shard is responsible for the requested guild.
Parameters:
Name Type Description
gId number | string The guild id to check.
Source:
Returns:
True if this shard has this guild.
Type
boolean

<private, inner> checkPerm(userData, gId, cId, cmd)

Check that the given user has permission to manage the games in the given guild.
Parameters:
Name Type Argument Description
userData UserData The user to check.
gId string The guild id to check against.
cId string <nullable>
The channel id to check against.
cmd string The command being attempted.
Source:
Returns:
Whther the user has permission or not to manage the hungry games in the given guild.
Type
boolean

<private, inner> clientSocketConnection(socket)

Handler for connecting as a client to the server.
Parameters:
Name Type Description
socket socketIo~Socket The socket.io socket that connected.
Source:

<private, inner> dayStateChange(hg, gId)

This gets fired whenever the day state of any game changes in the hungry games. This then notifies all clients that the state changed, if they care about the guild.
Parameters:
Name Type Description
hg HungryGames HG object firing the event.
gId string Guild id of the state change.
Source:
Listens to Events:
  • HG#event:dayStateChange

<private, inner> fetchGuilds(userData, socket [, cb])

Fetch all relevant data for all mutual guilds with the user and send it to the user.
Parameters:
Name Type Argument Description
userData object The current user's session data.
socket socketIo~Socket The socket connection to reply on.
cb function <optional>
Callback that fires once the requested action is complete, or has failed.
Source:

<private, inner> guildBroadcast(gId, event, args)

Broadcast a message to all relevant clients.
Parameters:
Name Type Argument Description
gId string Guild ID to broadcast message for.
event string The name of the event to broadcast.
args * <repeatable>
Data to send in broadcast.
Source:

<private, inner> handleActionUpdate(hg, gId)

Handle actions being modified in a server.
Parameters:
Name Type Description
hg HungryGames HG object firing event.
gId string The guild ID that was updated.
Source:
Listens to Events:
  • HG#event:actionInsert
  • HG#event:actionRemove
  • HG#event:actionUpdate

<private, inner> handleEventAdded(hg, gId, type, eId)

Handle events being added to a server.
Parameters:
Name Type Description
hg HungryGames HG object firing event.
gId string The guild ID that was updated.
type string The event category.
eId string The ID of the event that was added.
Source:
Listens to Events:
  • HG#event:eventAdded

<private, inner> handleEventRemoved(hg, gId, type, eId)

Handle events being removed from a server.
Parameters:
Name Type Description
hg HungryGames HG object firing event.
gId string The guild ID that was updated.
type string The event category.
eId string The ID of the event that was removed.
Source:
Listens to Events:
  • HG#event:eventRemoved

<private, inner> handleEventToggled(hg, gId, type, eId, value)

Handle events being toggled in a server.
Parameters:
Name Type Description
hg HungryGames HG object firing event.
gId string The guild ID that was updated.
type string The category the event was toggled in.
eId string The ID of the event that was toggled.
value boolean The if event is now enabled.
Source:
Listens to Events:
  • HG#event:eventToggled

<private, inner> handleGuildMemberAdd(member)

Handle a member being added to a guild.
Parameters:
Name Type Description
member Discord~GuildMember The member added.
Source:
Listens to Events:
  • Discord~Client#event:guildMemberAdd

<private, inner> handleGuildMemberRemove(member)

Handle a member being removed from a guild.
Parameters:
Name Type Description
member Discord~GuildMember The member removed.
Source:
Listens to Events:
  • Discord~Client#event:guildMemberRemove

<private, inner> handleMemberAdd(hg, gId, mId)

Handle a member being added to a guild.
Parameters:
Name Type Description
hg HungryGames HG object firing the event.
gId string Guild ID of the member added.
mId string Member ID that was added.
Source:
Listens to Events:
  • HG#event:memberAdd

<private, inner> handleMemberRemove(hg, gId, mId)

Handle a member being removed from a guild.
Parameters:
Name Type Description
hg HungryGames HG object firing the event.
gId string Guild ID of the member removed.
mId string Member ID that was removed.
Source:
Listens to Events:
  • HG#event:memberRemove

<private, inner> handleOptionChange(hg, gId, opt1, opt2 [, opt3])

Handles an option being changed and broadcasting the update to clients.
Parameters:
Name Type Argument Description
hg HungryGames HG object firing the event.
gId string Guild ID of the option change.
opt1 string Option key.
opt2 string Option second key or value.
opt3 string <optional>
Option value if object option.
Source:
Listens to Events:
  • HG#event:toggleOption

<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> hg()

Update the reference to HungryGames.
Source:
Returns:
Reference to the currently loaded HungryGames subModule.
Type
HG

<private, inner> makeMember(m)

Strips a Discord~GuildMember to only the necessary data that a client will need.
Parameters:
Name Type Description
m Discord~GuildMember The guild member to strip the data from.
Source:
Returns:
The minimal member.
Type
object

<private, inner> makeMessage(uId, gId, cId, msg)

Forms a Discord~Message similar object from given IDs.
Parameters:
Name Type Argument Description
uId string The id of the user who wrote this message.
gId string The id of the guild this message is in.
cId string <nullable>
The id of the channel this message was 'sent' in.
msg string <nullable>
The message content.
Source:
Returns:
The created message-like object, or null if invalid channel.
Type
MessageMaker

<private, inner> replyNoPerm(socket, cmd [, gId])

Send a message to the given socket informing the client that the command they attempted failed due to insufficient permission.
Parameters:
Name Type Argument Description
socket Socket The socket.io socket to reply on.
cmd string The command the client attempted.
gId string <optional>
The guild ID for locale info.
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> startClient()

Start a socketio client connection to the primary running server.
Source:

<private, inner> stripGuilds(guilds, userData)

Strip a Discord~Guild to the basic information the client will need.
Parameters:
Name Type Description
guilds Array.<Discord~Guild> The array of guilds to strip.
userData object The current user's session data.
Source:
Returns:
The stripped guilds.
Type
Array.<object>

<private, inner> unlinkHG()

Unregister all event handlers from `hg_`.
Source:

Type Definitions


basicCB(err, res)

Basic callback with single argument. The argument is null if there is no error, or a string if there was an error.
Parameters:
Name Type Argument Description
err string <nullable>
The error response.
res * Response data if no error.
Source:

SocketFunction(userData, socket, args [, cb])

Function calls handlers for requested commands.
Parameters:
Name Type Argument Description
userData WebUserData The user data of the user performing the request.
socket socketIo~Socket The socket connection firing the command. Not necessarily the socket that will reply to the end client.
args * <repeatable>
Additional function-specific arguments.
cb HGWeb~basicCB <optional>
Callback that fires once requested action is complete or has failed. Client may not pass a callback.
Source: