Skip to content

Latest commit

 

History

History
2139 lines (1612 loc) · 91.2 KB

API.md

File metadata and controls

2139 lines (1612 loc) · 91.2 KB

Modules

cache

Cache functions

constants
db

Database functions

dotaBot

Dota bot functions

guild
ihl
ihlCommand
ihlManager
lobby
matchTracker

cache

Cache functions

constants

constants.CONSTANTS : enum

Enum for all constant values.

Kind: static enum of constants
Read only: true

db

Database functions

db~sequelize

External namespace for discord.js classes.

Kind: inner external of db
Category: Sequelize
See: http://docs.sequelizejs.com/

sequelize.Model

Kind: static class of sequelize
Category: Sequelize
See: http://docs.sequelizejs.com/class/lib/model.js~Model.html

new Model()

External Sequelize Model class.

dotaBot

Dota bot functions

dotaBot~DotaBot ⇐ EventEmitter

Class representing a Dota bot. Handles all in game functions required to host an inhouse lobby.

Kind: inner class of dotaBot
Extends: EventEmitter

new DotaBot(steamClient, steamUser, steamFriends, dotaClient, config)

Constructor of the DotaBot. This prepares an object for connecting to Steam and the Dota2 Game Coordinator.

Param Type Description
steamClient SteamClient A SteamClient instance.
steamUser SteamUser A SteamUser instance.
steamFriends SteamFriends A SteamFriends instance.
dotaClient Dota2Client A Dota2Client instance.
config module:db.Bot Bot configuration object.

dotaBot.teamCache ⇒ object

Get the player to team mapping object

Kind: instance property of DotaBot
Returns: object - The player to team mapping object.

dotaBot.teamCache

Set the player to team mapping object

Kind: instance property of DotaBot

Param Type Description
newCache object The new player to team mapping object.

dotaBot.steamId64 ⇒ string

Get bot steamId64

Kind: instance property of DotaBot
Returns: string - The bot steam 64 id.

dotaBot.lobby ⇒ object

Get the dota lobby object

Kind: instance property of DotaBot
Returns: object - The current lobby state

dotaBot.dotaLobbyId ⇒ Long

Get the dota lobby id

Kind: instance property of DotaBot
Returns: Long - The id of the current lobby.

dotaBot.playerState ⇒ object

Get the dota lobby player state

Kind: instance property of DotaBot
Returns: object - The current lobby player state

dotaBot.lobbyChannelName ⇒ string

Get the dota lobby channel name

Kind: instance property of DotaBot
Returns: string - The channel name of the current lobby.

dotaBot.accountId ⇒ number

Get the bot account id

Kind: instance property of DotaBot
Returns: number - The account id.

dotaBot.state ⇒ string

Get the current state of the queue

Kind: instance property of DotaBot
Returns: string - The current state of the queue.

dotaBot.rateLimit ⇒ number

Get the current rate limit factor

Kind: instance property of DotaBot
Returns: number - The current queue rate limit factor in milliseconds.

dotaBot.rateLimit

Set the rate limiting factor

Kind: instance property of DotaBot

Param Type Description
rateLimit number Milliseconds to wait between requests.

dotaBot.backoff ⇒ number

Get the current backoff time of the queue

Kind: instance property of DotaBot
Returns: number - The current queue backoff time in milliseconds.

dotaBot.backoff

Set the backoff time of the queue

Kind: instance property of DotaBot

Param Type Description
backoff number Exponential backoff time in milliseconds.

dotaBot.schedule()

Schedule a function for execution. This function will be executed as soon as the GC is available.

Kind: instance method of DotaBot

dotaBot.block()

Block the queue

Kind: instance method of DotaBot

dotaBot.release()

Unblock the queue

Kind: instance method of DotaBot

dotaBot.clear()

Clear the queue

Kind: instance method of DotaBot

dotaBot.onSteamClientLoggedOff()

Steam client logged off handler. Attempts to log on to steam and connect to Dota

Kind: instance method of DotaBot

dotaBot.onSteamClientError()

Steam client error handler. Attempts to connect to steam and connect to Dota

Kind: instance method of DotaBot

dotaBot.onDotaReady()

Dota ready handler. Unblocks the queue.

Kind: instance method of DotaBot

dotaBot.onDotaUnready()

Dota unready handler. Blocks the queue.

Kind: instance method of DotaBot

dotaBot.connect()

Initiates the connection to Steam and the Dota2 Game Coordinator.

Kind: instance method of DotaBot

dotaBot.logOnToSteam()

Log on to steam. Set online state and display name.

Kind: instance method of DotaBot

dotaBot.connectToDota()

Connect to dota and unblock queue.

Kind: instance method of DotaBot

dotaBot.disconnect()

Disconnect from the Game Coordinator. This will also cancel all queued operations!

Kind: instance method of DotaBot

dotaBot.inviteToLobby(steamId64)

Invites the given steam id to the Dota lobby.

Kind: instance method of DotaBot

Param Type Description
steamId64 string A steam id.

dotaBot.practiceLobbyKickFromTeam(accountId)

Kick the given account id from the lobby team slots.

Kind: instance method of DotaBot

Param Type Description
accountId number An account id.

dotaBot.practiceLobbyKick(accountId)

Kick the given account id from the lobby.

Kind: instance method of DotaBot

Param Type Description
accountId number An account id.

dotaBot.joinPracticeLobby(dotaLobbyId)

Join the lobby by dota lobby id.

Kind: instance method of DotaBot

Param Type Description
dotaLobbyId string A dota lobby id.

dotaBot~slotToTeam(slot) ⇒ number

Converts a Dota team slot value to a faction value.

Kind: inner method of dotaBot
Returns: number - An inhouse lobby faction.

Param Type Description
slot number The Dota team slot.

dotaBot~updatePlayerState(steamId64, slot, playerState) ⇒ Object

Updates a player to team mapping object. Used to track which players have joined team slots in lobby. A null slot value will remove the player from the mapping meaning they are not in a team slot.

Kind: inner method of dotaBot
Returns: Object - A player to team mapping.

Param Type Description
steamId64 string The player's steamid64.
slot number The lobby team slot the player joined.
playerState Object A player to team mapping.

dotaBot~isDotaLobbyReady(teamCache, playerState) ⇒ boolean

Checks if all entries in a player to team mapping match the player to team state mapping.

Kind: inner method of dotaBot
Returns: boolean - Whether the player state matches the team cache.

Param Type Description
teamCache Object The intended player to team state.
playerState Object The current state of players to teams.

dotaBot~startDotaLobby(dotaBot) ⇒ string

Start a dota lobby and return the match id.

Kind: inner method of dotaBot
Returns: string - The match id.

Param Type Description
dotaBot module:dotaBot.DotaBot The dota bot.

dotaBot~Long

A Long class for representing a 64 bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.

Kind: inner external of dotaBot
Category: Other
See: long npm package

dotaBot~Dota2

External namespace for Dota2 classes.

Kind: inner external of dotaBot
Category: node-dota2
See: https://github.com/Arcana/node-dota2

Dota2.Dota2Client

Kind: static class of Dota2
Category: node-dota2
See: https://github.com/Arcana/node-dota2#module_Dota2.Dota2Client

new Dota2Client()

External Dota2 Dota2Client class.

dotaBot~steam

The Steam for Node JS package, allowing interaction with Steam.

Kind: inner external of dotaBot
Category: node-steam
See: steam npm package

steam.SteamClient

Kind: static class of steam
Category: node-steam
See: https://github.com/seishun/node-steam#steamclient

new SteamClient()

External steam SteamClient class.

steam.SteamUser

Kind: static class of steam
Category: node-steam
See: https://github.com/seishun/node-steam/tree/master/lib/handlers/user

new SteamUser()

External steam SteamUser class.

steam.SteamFriends

Kind: static class of steam
Category: node-steam
See: https://github.com/seishun/node-steam/tree/master/lib/handlers/friends

new SteamFriends()

External steam SteamFriends class.

guild

guild~resolveUser()

Kind: inner method of guild
Throws:

  • InvalidArgumentException Argument userResolvable must be a Discord.js GuildMember, discord id string, an object with a discordId string property, or an object with a steamId64 property.
  • DiscordUserNotFound Will throw if a guild member is not found with the discord id.

guild~resolveRole()

Kind: inner method of guild
Throws:

  • InvalidArgumentException Argument userResolvable must be a role name string or a Discord.js Role object.
  • DiscordUserNotFound Will throw if a role with the given name is not found.

guild~discordjs

External namespace for discord.js classes.

Kind: inner external of guild
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/general/welcome

discordjs.Client

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/Client

new Client()

External Discord.js Client class.

discordjs.Guild

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/Guild

new Guild()

External Discord.js Guild class.

discordjs.CategoryChannel

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/CategoryChannel

new CategoryChannel()

External Discord.js CategoryChannel class.

discordjs.GuildChannel

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/GuildChannel

new GuildChannel()

External Discord.js GuildChannel class.

discordjs.Role

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/Role

new Role()

External Discord.js Role class.

discordjs.GuildMember

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/GuildMember

new GuildMember()

External Discord.js GuildMember class.

discordjs.User

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/User

new User()

External Discord.js User class.

discordjs.Message

Kind: static class of discordjs
Category: discord.js
See: https://discord.js.org/#/docs/main/stable/class/Message

new Message()

External Discord.js Message class.

ihl

ihl.InhouseState : Object

Kind: static typedef of ihl

ihl.LeagueGuildObject : Object

Kind: static typedef of ihl

ihl~getUserRankTier(steamId64) ⇒ number

Gets a player's badge rank from opendota.

Kind: inner method of ihl
Returns: number - The player badge rank.

Param Type Description
steamId64 string The player's steamid64.

ihl~registerUser(guildId, steamId64, discordId) ⇒ User

Adds a player to the inhouse league.

Kind: inner method of ihl
Returns: User - The newly created user database record.

Param Type Description
guildId string A guild id.
steamId64 string The player's steamid64.
discordId string The player's discord id.

ihl~createInhouseState() ⇒ InhouseState

Creates an inhouse state. Sets up the inhouse category, channel, and role.

Kind: inner method of ihl
Returns: InhouseState - An inhouse state object.

ihl~hasActiveLobbies(user) ⇒ boolean

Checks if a user has active lobbies.

Kind: inner method of ihl
Returns: boolean - Whether the user has active lobbies.

Param Type Description
user module:db.User The user to check.

ihl~joinLobbyQueue(lobbyState, user)

Adds a user to a lobby queue.

Kind: inner method of ihl

Param Type Description
lobbyState LobbyState A lobby state.
user module:db.User The player to queue.

ihl~getAllLobbyQueues(inhouseState, user)

Add a user to all lobby queues.

Kind: inner method of ihl

Param Type Description
inhouseState InhouseState An inhouse state.
user module:db.User The player to queue.

ihl~leaveLobbyQueue(lobbyState, user)

Removes a user from a lobby queue.

Kind: inner method of ihl

Param Type Description
lobbyState LobbyState A lobby state.
user module:db.User The player to dequeue.

ihl~getAllLobbyQueuesForUser(inhouseState, user)

Removes a user from all lobby queues.

Kind: inner method of ihl

Param Type Description
inhouseState InhouseState An inhouse state.
user module:db.User The player to dequeue.

ihl~banInhouseQueue(user, timeout)

Bans a user from an inhouse queue.

Kind: inner method of ihl

Param Type Description
user module:db.User The player to ban.
timeout number The duration of ban in minutes.

ihlCommand

ihlCommand.BotListCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeagueInfoCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeagueSeasonCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeagueTicketCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeagueUpdateCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyDraftCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyFirstPickCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyGameModeCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyInviteCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyKickCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyKillCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyLeaveCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyRunCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyStartCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbyStateCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LobbySwapCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueBanCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueClearCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UserBadgeCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UserVouchCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UserVouchCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.ChallengeListCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.ChallengeCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UnchallengeCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.CommendCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.DireCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.FirstCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.GameModeCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.InviteCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeaderboardCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.NicknameCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.PickCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.RadiantCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.RegisterCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.RepCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.RolesCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.SecondCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UncommendCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.UnrepCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.WhoisCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.BotAddCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.BotLeaveCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.BotRemoveCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.BotStatusCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.DumpMembersCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.InviteUrlCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LeagueCreateCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.LogLevelCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.RestartCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.TicketAddCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.TicketRemoveCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueJoinCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueLeaveCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueReadyCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand.QueueStatusCommand ⇐ IHLCommand

Kind: static class of ihlCommand
Extends: IHLCommand
Category: Commands

ihlCommand~IHLCommand ⇐ external:commando.Command

Kind: inner class of ihlCommand
Extends: external:commando.Command

ihlCommand~commando

External namespace for discord.js Commando classes.

Kind: inner external of ihlCommand
Category: Other
See: https://github.com/discordjs/Commando/tree/djs-v11

ihlManager

ihlManager.EventListeners

This provides methods used for ihlManager event handling.

Kind: static mixin of ihlManager

ihlManager.LobbyQueueHandlers

This provides methods used for ihlManager lobby queue state handling.

Kind: static mixin of ihlManager

ihlManager.LobbyStateHandlers

This provides methods used for ihlManager lobby state handling.

Kind: static mixin of ihlManager

ihlManager~IHLManager

Class representing the inhouse league manager.

Kind: inner class of ihlManager

new IHLManager()

Creates an inhouse league manager.

ihlManager.init(client)

Initializes the inhouse league manager with a discord client and loads inhouse states for each league.

Kind: instance method of IHLManager

Param Type Description
client external:Client A discord.js client.

ihlManager.onClientReady()

Discord client ready handler.

Kind: instance method of IHLManager
Emits: ready

ihlManager.onDiscordMessage(msg)

Discord message handler.

Kind: instance method of IHLManager

Param Type Description
msg Message The discord message.

ihlManager.onDiscordMemberLeave(member)

Discord user left guild handler.

Kind: instance method of IHLManager

Param Type Description
member GuildMember The member that left.

ihlManager.createNewLeague(guild)

Creates a new inhouse in a discord guild.

Kind: instance method of IHLManager

Param Type Description
guild Guild The discord guild for the inhouse.

ihlManager.createChallengeLobby(inhouseState, captain1, captain2, challenge)

Creates and runs a challenge lobby.

Kind: instance method of IHLManager

Param Type Description
inhouseState module:ihl.inhouseState The inhouse state.
captain1 module:db.User The first lobby captain.
captain2 module:db.User The second lobby captain.
challenge module:db.Challenge The challenge between the two captains.

ihlManager.runLobbiesForInhouse(inhouseState)

Runs all lobbies for an inhouse.

Kind: instance method of IHLManager

Param Type Description
inhouseState module:ihl.inhouseState The inhouse state.

ihlManager.joinLobbyQueue(lobbyState, user, discordUser)

Adds a user to a lobby queue.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState The lobby to join.
user module:db.User The user to queue.
discordUser User A discord.js user.

ihlManager.joinAllLobbyQueues(inhouseState, user, discordUser)

Adds a user to all lobby queues.

Kind: instance method of IHLManager

Param Type Description
inhouseState InhouseState The inhouse to queue.
user module:db.User The user to queue.
discordUser User A discord.js user.

ihlManager.leaveLobbyQueue(lobbyState, user, discordUser)

Removes a user from a lobby queue.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState The lobby to join.
user module:db.User The user to dequeue.
discordUser User A discord.js user.

ihlManager.leaveAllLobbyQueues(inhouseState, user, discordUser)

Removes a user from all lobby queues.

Kind: instance method of IHLManager

Param Type Description
inhouseState InhouseState The inhouse to dequeue.
user module:db.User The user to dequeue.
discordUser User A discord.js user.

ihlManager.clearLobbyQueue(lobbyState)

Clear a lobby queue.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState The lobby queue to clear.

ihlManager.clearAllLobbyQueues(inhouseState)

Clear all lobby queues.

Kind: instance method of IHLManager

Param Type Description
inhouseState InhouseState The inhouse queue to clear.

ihlManager.banInhouseQueue(inhouseState, user, timeout, discordUser)

Bans a user from the inhouse queue.

Kind: instance method of IHLManager

Param Type Description
inhouseState InhouseState The inhouse to dequeue.
user module:db.User The player to ban.
timeout number Duration of ban in minutes.
discordUser User A discord.js user.

ihlManager.registerLobbyTimeout(lobbyState)

Creates and registers a ready up timer for a lobby state.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.

ihlManager.unregisterLobbyTimeout(lobbyState)

Clears and unregisters the ready up timer for a lobby state.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.

ihlManager.runLobby(_lobbyState, states)

Processes and executes a lobby state if it matches any of the given states. If no states to match against are given, the lobby state is run by default.

Kind: instance method of IHLManager

Param Type Description
_lobbyState LobbyState An inhouse lobby state.
states Array.<string> A list of valid lobby states.

ihlManager.onCreateLobbyQueue(_lobbyState)

Creates a queue lobby.

Kind: instance method of IHLManager

Param Type Description
_lobbyState LobbyState The lobby state to create the queue from.

ihlManager.onSetLobbyState(_lobbyState, state)

Sets a lobby state.

Kind: instance method of IHLManager

Param Type Description
_lobbyState LobbyState The lobby state being changed.
state string The state to set the lobby to.

ihlManager.onSetBotStatus(steamId64, status)

Sets a bot status.

Kind: instance method of IHLManager

Param Type Description
steamId64 string Bot steam id.
status string Bot status.

ihlManager.onLeagueTicketAdd(league, leagueid, name)

Associates a league with a ticket.

Kind: instance method of IHLManager

Param Type Description
league module:db.League The league to add the ticket to.
leagueid number The ticket league id.
name string The ticket name.

ihlManager.onLeagueTicketSet(league, leagueid) ⇒ module:db.Ticket

Sets the league ticket.

Kind: instance method of IHLManager

Param Type Description
league module:db.League The league to set the ticket to.
leagueid number The ticket league id.

ihlManager.onLeagueTicketRemove(league, leagueid)

Removes a ticket from a league.

Kind: instance method of IHLManager

Param Type Description
league module:db.League The league to remove the ticket from.
leagueid number The ticket league id.

ihlManager.onBotAvailable()

Runs lobbies waiting for bots.

Kind: instance method of IHLManager

ihlManager.onBotLobbyLeft()

Set bot idle then call onBotAvailable to run lobbies waiting for bots.

Kind: instance method of IHLManager

ihlManager.onLobbyTimedOut(lobbyState)

Runs a lobby state when its ready up timer has expired. Checks for STATE_CHECKING_READY lobby state

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.

ihlManager.onPlayerReady(lobbyState, user)

Runs a lobby state when a player has readied up and update their player ready state. Checks for STATE_CHECKING_READY lobby state

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.
user module:db.User An inhouse user.

ihlManager.onSelectionPick(_lobbyState, captain, pick)

Updates a lobby state with a captain pick selection

Kind: instance method of IHLManager

Param Type Description
_lobbyState LobbyState An inhouse lobby state.
captain module:db.User The captain user
pick number The selected pick

ihlManager.onSelectionSide(_lobbyState, captain, side)

Updates a lobby state with a captain side selection

Kind: instance method of IHLManager

Param Type Description
_lobbyState LobbyState An inhouse lobby state.
captain module:db.User The captain user
side number The selected faction

ihlManager.onDraftMember(lobbyState, user, faction)

Checks if a player is draftable and fires an event representing the result. If the player is draftable, checks for STATE_DRAFTING_PLAYERS lobby state and runs the lobby state.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.
user module:db.User The picked user
faction number The picking faction

ihlManager.onForceLobbyDraft(lobbyState, captain1, captain2)

Force lobby into player draft with assigned captains.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.
captain1 module:db.User The captain 1 user
captain2 module:db.User The captain 2 user

ihlManager.onStartDotaLobby(_lobbyState, _dotaBot) ⇒ module:lobby.lobbyState

Start a dota lobby if all players are in the lobby and on the correct teams.

Kind: instance method of IHLManager

Param Type Description
_lobbyState module:lobby.lobbyState The lobby state to check.
_dotaBot module:lobby.lobbyState The bot to check.

ihlManager.onLobbySwapTeams(lobbyState)

Swap teams in the dota lobby.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.

ihlManager.onLobbyKick(lobbyState, user)

Kicks a player from the dota lobby.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.
user module:db.User The player to kick

ihlManager.onLobbyInvite(lobbyState, user)

Invites a player to the dota lobby.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.
user module:db.User The player to invite

ihlManager.onLobbyReady(dotaLobbyId)

Runs a lobby state when the lobby is ready (all players have joined and are in the right team slot). Checks for STATE_WAITING_FOR_PLAYERS lobby state

Kind: instance method of IHLManager

Param Type Description
dotaLobbyId string A dota lobby id.

ihlManager.onLobbyKill(lobbyState)

Puts a lobby state in STATE_PENDING_KILL and runs lobby.

Kind: instance method of IHLManager

Param Type Description
lobbyState LobbyState An inhouse lobby state.

ihlManager.onMatchSignedOut(matchId)

Handles match signed out bot event. Updates STATE_MATCH_IN_PROGRESS lobby state to STATE_MATCH_ENDED

Kind: instance method of IHLManager

Param Type Description
matchId number A dota match id.

ihlManager.onMatchOutcome(dotaLobbyId, matchOutcome, members)

Handles match outcome bot event. Updates lobby winner and player stats. Sends match stats message. Puts lobby into STATE_MATCH_STATS state

Kind: instance method of IHLManager

Param Type Description
dotaLobbyId string A dota lobby id.
matchOutcome external:Dota2.schema.EMatchOutcome The dota match outcome
members Array.<external:Dota2.schema.CDOTALobbyMember> Array of dota lobby members

ihlManager.onMatchStats(lobby)

Handles match tracker match stats event. Sends match stats message. Puts lobby into STATE_MATCH_STATS state

Kind: instance method of IHLManager

Param Type Description
lobby module:db.Lobby A lobby database model

ihlManager.onMatchNoStats(lobby)

Handles match tracker match no stats event. Sends match no stats message. Puts lobby into STATE_MATCH_NO_STATS state

Kind: instance method of IHLManager

Param Type Description
lobby module:db.Lobby A lobby database model

ihlManager.processEventQueue()

Processes the inhouse manager event queue until it is empty. Events are actions to perform (mostly on lobby states or something that resolves to a lobby state). An event consists of a function, the arguments to call it with, and the resolve and reject callbacks of the Promise wrapping the action. When the action is executed, resolve with the returned value or reject if an error was thrown. The queue blocks while processing an action, so only 1 can be processed at a time.

Kind: instance method of IHLManager
Emits: empty

ihlManager.queueEvent(fn, ...args)

Adds a lobby processing function and its arguments to the queue. When the queue is processed the function will be executed with its arguments.

Kind: instance method of IHLManager

Param Type Description
fn eventCallback A lobby processing event function.
...args * A list of arguments the lobby processing event function will be called with.

ihlManager.getBot(botId) ⇒ module:dotaBot.DotaBot

Gets a bot.

Kind: instance method of IHLManager

Param Type Description
botId number The bot id.

ihlManager.getBotBySteamId(steamId64) ⇒ module:dotaBot.DotaBot

Gets a bot by steam id.

Kind: instance method of IHLManager

Param Type Description
steamId64 number The bot steam id.

ihlManager.loadBotById(botId) ⇒ module:dotaBot.DotaBot

Start a dota bot by id.

Kind: instance method of IHLManager

Param Type Description
botId number The bot id.

ihlManager.loadBotBySteamId(steamId64) ⇒ module:dotaBot.DotaBot

Start a dota bot by steam id.

Kind: instance method of IHLManager

Param Type Description
steamId64 number The bot steam id.

ihlManager.loadBot(bot) ⇒ module:dotaBot.DotaBot

Start a dota bot.

Kind: instance method of IHLManager

Param Type Description
bot module:db.Bot The bot model.

ihlManager.removeBot(botId)

Remove a dota bot.

Kind: instance method of IHLManager

Param Type Description
botId number The bot id.

ihlManager.botLeaveLobby(lobbyState) ⇒ null | string

Disconnect a dota bot from its lobby. The bot should eventually emit EVENT_BOT_LOBBY_LEFT.

Kind: instance method of IHLManager
Returns: null | string - Null if the bot left the lobby or a string containing the error reason.

Param Type Description
lobbyState module:lobby.lobbyState The lobby for the bot.

ihlManager.attachListeners()

Bind all events to their corresponding event handler functions

Kind: instance method of IHLManager

ihlManager~findUser(guild, member) ⇒ Array

Searches the discord guild for a member.

Kind: inner method of ihlManager
Returns: Array - The search result in an array containing the user record, discord guild member, and type of match.

Param Type Description
guild external:Guild A list of guilds to initialize leagues with.
member string | external:GuildMember A name or search string for an inhouse player or their guild member instance.

ihlManager~loadInhouseStates(guilds, leagues) ⇒ Array.<InhouseState>

Maps league records to inhouse states.

Kind: inner method of ihlManager
Returns: Array.<InhouseState> - The inhouse states loaded from league records.

Param Type Description
guilds Array.<external:Guild> A list of guilds to initialize leagues with.
leagues Array.<module:db.League> A list of database league records.

ihlManager~loadInhouseStatesFromLeagues(guilds) ⇒ Array.<InhouseState>

Gets all league records from the database turns them into inhouse states.

Kind: inner method of ihlManager
Returns: Array.<InhouseState> - The inhouse states loaded from all league records.

Param Type Description
guilds Array.<external:Guild> A list of guilds to initialize leagues with.

"ready"

IHLManager ready event.

Kind: event emitted by ihlManager

"empty"

IHLManager event queue empty event.

Kind: event emitted by ihlManager

"EVENT_MATCH_STATS" (lobby)

Event for returning stats from a lobby.

Kind: event emitted by ihlManager

Param Type Description
lobby module:db.Lobby The lobby with stats.

ihlManager~eventCallback : function

Callback for a lobby processing event.

Kind: inner typedef of ihlManager

ihlManager~EventEmitter

Node.js EventEmitter object

Kind: inner external of ihlManager
Category: Other
See: https://nodejs.org/api/events.html#events_class_eventemitter

lobby

lobby.LobbyState : Object

Kind: static typedef of lobby

matchTracker

matchTracker~MatchTracker

Match tracker checks opendota and valve match apis to see if a match has finished and saves the match data to the database.

Kind: inner class of matchTracker

new MatchTracker()

Creates an inhouse league match tracker.

matchTracker.run()

The match polling loop

Kind: instance method of MatchTracker
Emits: EVENT_MATCH_STATS

matchTracker.enable()

Enables the match polling loop

Kind: instance method of MatchTracker

matchTracker.disable()

Disables the match polling loop

Kind: instance method of MatchTracker