-
-
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:
- Inherited From:
-
- Source:
-
-
-
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:
- Inherited From:
-
- Source:
-
-
-
The common object. Defaults to require cache value for editor
autocompletion, updates to current reference at init.
Type:
- Inherited From:
-
- Source:
-
-
<constant> defaultOptions :object.<{value: (string|number|boolean), values: (null|Array.<string>), comment: string}>
-
Default options for a game.
Type:
-
object.<{value: (string|number|boolean), values: (null|Array.<string>), comment: string}>
- 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:
- Inherited From:
-
- Source:
-
-
-
- Source:
-
-
helpMessage :undefined|string|Discord~EmbedBuilder
-
The help message to show the user in the main help message.
Type:
-
undefined
|
string
|
Discord~EmbedBuilder
- Inherited From:
-
- Overrides:
- Source:
-
-
<protected, readonly> initialized :boolean
-
Has this subModule been initialized yet (Has begin() been called).
Type:
- 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:
- Inherited From:
-
- Source:
-
-
<constant> maxBytes :number
-
The maximum number of bytes allowed to be received from a client in an
image upload.
Type:
- Default Value:
-
- Source:
-
-
<abstract, protected> myName :string
-
The name of this submodule. Used for differentiating in the log. Should
be defined before begin().
Type:
- Inherited From:
-
- Overrides:
- Source:
-
-
NPC
-
- Source:
-
-
<abstract> postPrefix :string
-
The postfix for the global prefix for this subModule. Must be defined
before begin(), otherwise it is ignored.
Type:
- Inherited From:
-
- Overrides:
- Source:
-
-
<private, inner, constant> battleFile :string
-
The file path to read battle events.
Type:
- Default Value:
-
- Source:
-
- See:
-
-
<private, inner> battles :Object
-
All attacks and outcomes for battles.
Type:
- Source:
-
- See:
-
-
<private, inner, constant> defaultColor :Discord~ColorResolveable
-
Default color to choose for embedded messages.
Type:
- Default Value:
-
- Source:
-
-
-
Container for all default events.
Type:
- Source:
-
-
-
Default options for a game.
Type:
- Source:
-
-
<private, inner, constant> emoji :object.<string>
-
Helper object of emoji characters mapped to names.
Type:
- Source:
-
-
<private, inner, constant> eventFileList :string
-
The file where the default event IDs are listed.
Type:
- Default Value:
-
- ./save/hgDefaultEvents.json
- Source:
-
-
<private, inner, constant> eventHandlers :object.<Array.<function()>>
-
All registered event handlers.
Type:
-
object.<Array.<function()>>
- Source:
-
-
<private, inner, constant> helpObject
-
The object that stores all data to be formatted into the help
message.
- Source:
-
-
<private, inner> listenersEndTime :number
-
The last time the currently scheduled reaction event listeners are expected
to end. Used for checking of submoduleis unloadable.
Type:
- Source:
-
-
<private, inner, constant> maxReactAwaitTime :number
-
Maximum amount of time to wait for reactions to a message.
Type:
- Default Value:
-
- Source:
-
-
<private, inner, constant> optionMessages :object.<Discord~Message>
-
Messages I have sent showing current options.
Type:
- Default Value:
-
- Source:
-
-
<private, inner, constant> patreonColor :number
-
Color to put above patrons avatars. RGBA Hex (0xRRGGBBAA).
Type:
- Default Value:
-
- Source:
-
-
<private, inner, constant> patreonSettingKeys :Array.<string>
-
The permission tags for all settings related to the Hungry Games.
Type:
- Default Value:
-
- ["hg:fun_translators","hg:bar_color","hg:customize_stats","hg:personal_weapon"]
- Source:
-
-
<private, inner, constant> strings :Strings
-
Instance of locale string manager.
Type:
- Source:
-
-
<private, inner, constant> urlRegex :RegExp
-
Regex to match all URLs in a string.
Type:
- Source:
-
-
<private, inner, constant> webSM :string
-
Name of the HG Web submodule for lookup.
Type:
- Default Value:
-
- Source:
-
-
<private> _fire(evt, args)
-
Fire an event on all listeners.
Parameters:
Name |
Type |
Argument |
Description |
evt |
string
|
|
The event to fire. |
args |
*
|
<repeatable>
|
Arguments for the event. |
- Source:
-
-
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:
-
-
calcColNum(numCols, statusList)
-
Calculates the number of columns for the given player list. Assumes maximum
character count of 1024 per section. The number of columns also becomes
limited to 5, because we will run into the embed total character limit of
6000 if we add any more.
[Discord API Docs](
https://discordapp.com/developers/docs/resources/channel#embed-limits).
Parameters:
Name |
Type |
Description |
numCols |
number
|
Minimum number of columns. |
statusList |
Array.<string>
|
List of text to check. |
- Source:
-
Returns:
Number of columns the data shall be formatted as.
-
Type
-
number
-
claimLegacy(game, owner, cb)
-
Claim legacy events to the given owner's account.
Parameters:
Name |
Type |
Description |
game |
HungryGames~GuildGame
|
The game storing legacy events. |
owner |
string
|
The ID of ther user to attach the events to. |
cb |
function
|
Callback once completed. First argument is optional
error string, second is otherwise success information string, third will
always be the stringified legacy events. |
- Source:
-
-
createGame(id [, cb])
-
Create a Hungry Games for a guild.
Parameters:
Name |
Type |
Argument |
Description |
id |
string
|
|
The id of the guild to create the game in. |
cb |
function
|
<optional>
|
Callback that fires once loading is complete. Only
parameter is created HungryGames~GuildGame or null if failed. |
- Source:
-
-
createNPC(gId, username, avatar, id)
-
Create an npc in a guild.
Parameters:
Name |
Type |
Description |
gId |
string
|
number
|
The guild id to add the npc to. |
username |
string
|
The name of the npc. |
avatar |
string
|
The url path to the avatar. Must be valid url to
this server. (ex:
https://www.spikeybot.com/avatars/NPCBBBADEF031F83638/avatar1.png). |
id |
string
|
The npc id of this npc. Must match the id in the avatar
url. |
- Source:
-
Returns:
Error message key or null if no error.
-
Type
-
string
-
createReactJoinMessage(channel)
-
Send a message with a reaction for users to click on. Records
message id and channel id in game data.
Parameters:
Name |
Type |
Description |
channel |
Discord~TextChannel
|
string
|
The channel in the guild to
send the message, or the ID of the channel. |
- 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:
-
-
editTeam(uId, gId, cmd, one, two)
-
Allows editing teams. Entry for all team actions.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user is running the action. |
gId |
string
|
The id of the guild to run this in. |
cmd |
string
|
The command to run on the teams. |
one |
string
|
The id of the user to swap, or the new name of the team
if we're renaming a team. |
two |
string
|
The id of the user to swap, or the team id if we're
moving a player to a team. |
- Source:
-
Returns:
Error message or null if no error.
-
Type
-
string
-
end()
-
Trigger subModule to shutdown and get ready for process terminating.
- Inherited From:
-
- Source:
-
-
endGame(uId, gId)
-
End the games in the given guild as the given user.
Parameters:
Name |
Type |
Description |
uId |
string
|
Discord~Message
|
The id of the user who trigged the
games to end, or a Discord message sent by the user who triggered this. |
gId |
string
|
The id of the guild to end the games in. |
- Source:
-
-
endReactJoinMessage(id [, cb])
-
End the reaction join and update the included users to only
include those who reacted to the message.
Parameters:
Name |
Type |
Argument |
Description |
id |
string
|
|
The guild id of which to end the react join. |
cb |
function
|
<optional>
|
Callback once this is complete. First parameter is a
string key if error, null otherwise, the second is a string with info if
success or null otherwise. |
- 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:
-
-
excludeUsers(users, id, cb)
-
Removes users from a games of a given guild.
Parameters:
Name |
Type |
Description |
users |
string
|
Array.<string>
|
Array.<Discord~User>
|
Array.<HungryGames~NPC>
|
The users
to exclude, or
'everyone' to exclude everyone. |
id |
string
|
The guild id to remove the users from. |
cb |
function
|
Callback for when long running operations complete.
Single argument with a string with the outcomes of each user. May have
multiple lines for a single user. |
- Source:
-
Fires:
-
gameStep(uId, gId, cId)
-
Show only the next event in a day.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user who trigged this step. |
gId |
string
|
The id of the guild to step the game in. |
cId |
string
|
The id of the channel the request was sent from. |
- Source:
-
-
getDefaultBattles()
-
- Source:
-
Returns:
Array of all default battle events.
-
Type
-
Array.<HungryGames~Battle>
-
getDefaultEvents()
-
Returns an object storing all of the default events for the
games.
- Source:
-
Returns:
Object storing default events.
-
Type
-
HungryGames~EventContainer
-
getDefaultWeapons()
-
Returns the object storing all default
HungryGames~Weapons parsed from file.
- Source:
-
Returns:
Array of all default weapons.
-
Type
-
Array.<HungryGames~Weapon>
-
getHG()
-
Fetch a reference to the current HungryGames instance.
- Source:
-
Returns:
Current instance.
-
Type
-
HungryGames
-
getNumSimulating()
-
Returns the number of games that are currently being shown to
users.
- Source:
-
Returns:
Number of games simulating.
-
Type
-
number
-
getString(str, gId [, rep])
-
Get the locale string in the given guild.
Parameters:
Name |
Type |
Argument |
Description |
str |
string
|
|
String ID to get. |
gId |
string
|
|
ID of guild to get locale from. |
rep |
string
|
<optional>
|
Replacements for string. |
- Source:
-
- See:
-
Returns:
Found string with replacements, or null.
-
Type
-
string
-
includeUsers(users, id, cb)
-
Adds a user back into the next game.
Parameters:
Name |
Type |
Description |
users |
string
|
Array.<string>
|
Array.<Discord~User>
|
Array.<HungryGames~NPC>
|
The users
to include, 'everyone' to include all users, 'online' to include online
users, 'offline', 'idle', or 'dnd' for respective users. |
id |
string
|
The guild id to add the users to. |
cb |
function
|
Callback for when long running operations complete.
Single argument with a string with the outcomes of each user. May have
multiple lines for a single user. |
- Source:
-
Fires:
-
<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:
-
-
nextDay(uId, gId, cId)
-
Start the next day of the game in the given channel and guild by the given
user.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user who trigged autoplay to start. |
gId |
string
|
The id of the guild to run autoplay in. |
cId |
string
|
The id of the channel to run autoplay in. |
- Source:
-
-
on(evt, handler)
-
Register an event listener. Handlers are called in order they
are registered. Earlier events can modify event data.
Parameters:
Name |
Type |
Description |
evt |
string
|
The name of the event to listen for. |
handler |
function
|
The function to call when the event is fired. |
- Source:
-
-
pauseAutoplay(uId, gId)
-
Pause autoplay in the given guild as the given user.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user who trigged autoplay to end. |
gId |
string
|
The id of the guild to end autoplay. |
- Source:
-
-
pauseGame(id)
-
Pause the game in by clearing the current interval.
Parameters:
Name |
Type |
Description |
id |
string
|
The id of the guild to pause in. |
- Source:
-
Returns:
User information of the outcome of this command.
-
Type
-
string
-
readImage(url)
-
Attempt to fetch an image from a URL. Checks if the file has been cached to
the filesystem first.
Parameters:
Name |
Type |
Description |
url |
string
|
Jimp
|
Buffer
|
The url to fetch the image from, or
anything Jimp supports. |
- Source:
-
Returns:
Promise from JIMP with image data.
-
Type
-
Promise
-
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:
-
- Overrides:
- Source:
-
- See:
-
Returns:
True if can be reloaded, false if cannot.
-
Type
-
boolean
-
removeListener(evt, handler)
-
Remove an event listener;.
Parameters:
Name |
Type |
Description |
evt |
string
|
The name of the event that was being listened for. |
handler |
function
|
The currently registered handler. |
- Source:
-
-
removeNPC(gId, npc [, locale])
-
Delete an NPC from a guild.
Parameters:
Name |
Type |
Argument |
Description |
gId |
string
|
|
Guild id of which to remove npc. |
npc |
string
|
|
ID of npc to delete. |
locale |
string
|
<optional>
|
Language locale to create EmbedBuilder with. |
- Source:
-
Returns:
String key if error, EmbedBuilder to
send if success.
-
Type
-
string
|
Discord~EmbedBuilder
-
renameGame(id, name)
-
Rename the guild's game to the given custom name.
Parameters:
Name |
Type |
Description |
id |
string
|
number
|
The guild id of which to change the game's name. |
name |
string
|
The custom name to change to. Must be 100 characters
or fewer. |
- Source:
-
Returns:
True if successful, false if failed. Failure is probably
due to a game not existing or the name being longer than 100 characters.
-
Type
-
boolean
-
renameNPC(gId, npcId, username)
-
Rename an npc in a guild.
Parameters:
Name |
Type |
Description |
gId |
string
|
number
|
The guild ID context. |
npcId |
string
|
The ID of the NPC to rename. |
username |
string
|
The new name of the npc. |
- Source:
-
Returns:
Error message or null if no error.
-
Type
-
string
-
save( [opt] [, wait])
-
Save all game data to file.
Parameters:
Name |
Type |
Argument |
Default |
Description |
opt |
string
|
<optional>
|
'sync'
|
Can be 'async', otherwise defaults to
synchronous. |
wait |
boolean
|
<optional>
|
false
|
If requested before subModule is
initialized, keep trying until it is initialized. |
- Inherited From:
-
- Overrides:
- Source:
-
-
setOption(id, option, value [, text])
-
Change an option to a value for the given guild.
Parameters:
Name |
Type |
Argument |
Default |
Description |
id |
string
|
|
|
The guild id to change the option in. |
option |
string
|
<nullable>
|
|
The option key to change. |
value |
string
|
boolean
|
number
|
|
|
The value to change the option to. |
text |
string
|
<optional>
|
''
|
The original message sent without the command
prefix in the case we are changing the value of an object and require all
user inputted data. |
- Source:
-
Returns:
A message saying what happened, or null if we should show
the user the list of options instead.
-
Type
-
string
-
<protected> shutdown()
-
Shutdown and disable this submodule. Removes all event listeners.
- Inherited From:
-
- Overrides:
- Source:
-
-
sortTeams(game)
-
Sort the includedUsers and teams for the given game.
Parameters:
- Source:
-
-
startAutoplay(uId, gId, cId)
-
Start autoplay in the given channel and guild by the given user.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user who trigged autoplay to start. |
gId |
string
|
The id of the guild to run autoplay in. |
cId |
string
|
The id of the channel to run autoplay in. |
- Source:
-
-
startGame(uId, gId, cId)
-
Start the games in the given channel and guild by the given user.
Parameters:
Name |
Type |
Description |
uId |
string
|
The id of the user who trigged the games to start. |
gId |
string
|
The id of the guild to run the games in. |
cId |
string
|
The id of the channel to run the games in. |
- Source:
-
-
toggleEvent(id, type, evtId [, value])
-
Enable or disable an event without deleting it completely.
Parameters:
Name |
Type |
Argument |
Description |
id |
number
|
string
|
|
The guild id that the event shall be toggled in. |
type |
string
|
|
The type of event. 'bloodbath', 'player', 'weapon', or
'arena'. |
evtId |
string
|
|
The event ID of which to toggle in the category. |
value |
boolean
|
<optional>
|
Set enabled to a value instead of toggling. |
- Source:
-
Fires:
Returns:
Error message or null if no error.
-
Type
-
string
-
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:
-
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> changeObjectValue(obj, defaultObj, option, value, values, id [, range] [, keys])
-
Recurse through an object to change a certain child value based off a given
array of words.
Parameters:
Name |
Type |
Argument |
Default |
Description |
obj |
HungryGames~GuildGame.options
|
|
|
The object with the values to
change. |
defaultObj |
HungryGames~defaultOptions
|
|
|
The default template object
to base changes off of. |
option |
string
|
|
|
The first value to check. |
value |
number
|
boolean
|
string
|
|
|
The value to change to, or the next
option key to check if we have not found an end to a branch yet. |
values |
Array.<(string|boolean|number)>
|
|
|
All keys leading to the final
value, as well as the final value. |
id |
string
|
|
|
The id of the guild this was triggered for. |
range |
Object
|
<optional>
|
|
Allowable range for values that
are numbers. |
keys |
Array.<string>
|
<optional>
|
[]
|
List of previous option keys. |
- Source:
-
Fires:
Returns:
Message saying what happened. Can be an error message.
-
Type
-
string
-
<private, inner> commandClaimLegacyEvents(msg, id)
-
Update all legacy custom events to the newer ID based system.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> commandDeleteGroup(msg, id)
-
Deletes an existing stat group.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandGiveWeapon(msg, id)
-
Give a certain amount of a weapon to a player.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
- See:
-
Listens to Events:
-
<private, inner> commandGroups(msg, id)
-
Responds with list of all stat group names and IDs.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandHeal(msg, id [, game])
-
Allows the game creator to heal or revive a player in the
game.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> commandKill(msg, id [, game])
-
Allows the game creator to kill a player in the game.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> commandLeaderboard(msg, id)
-
Ranks players by stat.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandMakeMeLose(msg)
-
Tell a user their chances of losing have not increased.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
Message that triggered command. |
- Source:
-
Listens to Events:
- Command#event:hg makemelose
-
<private, inner> commandMakeMeWin(msg)
-
Tell a user their chances of winning have not increased.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
Message that triggered command. |
- Source:
-
Listens to Events:
- Command#event:hg makemelose
-
<private, inner> commandModifyWeapon(msg, id [, flip])
-
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
flip |
boolean
|
<optional>
|
false
|
Should the parsed number value be multiplied
by -1. |
- Source:
-
-
<private, inner> commandNewGroup(msg, id [, game])
-
Creates a new stat group.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
Guild ID this command was called from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> commandNums(msg)
-
Replies to the user with stats about all the currently loaded
games in this shard.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
- Source:
-
-
<private, inner> commandReactJoin(msg, id [, game])
-
Start or stop allowing users to enter in to a game by clicking
on a reaction to a message.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> commandRename(msg, id [, game])
-
Rename a guild's game to a custom name.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> commandRenameGroup(msg, id)
-
Renames an existing stat group.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandRig(msg)
-
Replies to the user with an image saying "rigged". That is
all.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
- Source:
-
-
<private, inner> commandSelectGroup(msg, id)
-
Selects an existing stat group.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandStats(msg, id)
-
Responds with stats about a player in the games.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
Guild ID this command was called from. |
- Source:
-
-
<private, inner> commandStep(msg, id)
-
Show only the next event in a day.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> commandTakeWeapon(msg, id)
-
Take a certain amount of a weapon from a player.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
- See:
-
Listens to Events:
-
<private, inner> commandWound(msg, id [, game])
-
Allows the game creator to wound a player in the game.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> createGame(msg, id [, silent] [, cb])
-
Create a Hungry Games for a guild.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
<nullable>
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
silent |
boolean
|
<optional>
|
false
|
Should we suppress replies to message. |
cb |
function
|
<optional>
|
|
Callback that fires once loading is complete. Only
parameter is created HungryGames~GuildGame or null if failed. |
- Source:
-
-
<private, inner> createNPC(msg, id)
-
Create a new NPC.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> editTeam(msg, id [, silent])
-
Entry for all team commands.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
silent |
boolean
|
<optional>
|
false
|
Should we disable replying to the given
message? |
- Source:
-
Returns:
Error message or null if no error.
-
Type
-
string
-
<private, inner> endDayCheck(msg, id)
-
Trigger the end of a day.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> endGame(msg, id [, silent])
-
End a game early.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
silent |
boolean
|
<optional>
|
false
|
Prevent sending messages. |
- Source:
-
-
<private, inner> excludeIterate(game, obj [, onlyError] [, large] [, locale])
-
Exclude a single user from the game as a single iteration step
of the exclude command.
Parameters:
Name |
Type |
Argument |
Default |
Description |
game |
HungryGames~GuildGame
|
|
|
The game to manipulate. |
obj |
string
|
HungryGames~Player
|
HungryGames~NPC
|
|
|
Player for this
iteration. |
onlyError |
boolean
|
<optional>
|
false
|
Only add error messages to response. |
large |
boolean
|
<optional>
|
false
|
Is this a large game where excluded users
are not tracked. |
locale |
string
|
<optional>
<nullable>
|
null
|
String locale for respons formatting. |
- Source:
-
Returns:
Response text for the user performing the operation.
-
Type
-
string
-
<private, inner> excludeNPC(msg, id)
-
Exclude an NPC from the game.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> excludeUser(msg, id [, game])
-
Remove a user from users to be in next game.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
Game object to exclude user from. |
- Source:
-
-
<private, inner> fetchPatreonSettings(players, cId, gId [, cb])
-
Given an array of players, lookup the settings for each and update their
data. This is asynchronous.
Parameters:
Name |
Type |
Argument |
Description |
players |
Array.<HungryGames~Player>
|
|
The players to lookup and update. |
cId |
string
|
number
|
|
The channel ID to fetch the settings for. |
gId |
string
|
number
|
|
The guild ID to fetch the settings for. |
cb |
function
|
<optional>
|
Calls this callback on completion. No parameters. |
- Source:
-
-
-
Clean up username, and format to rules similar to Discord.
Parameters:
Name |
Type |
Argument |
Description |
u |
string
|
|
The username. |
remove |
string
|
RegExp
|
<optional>
|
A substring or RegExp to remove. |
- Source:
-
Returns:
Formatted username.
-
Type
-
string
-
<private, inner> getName(guild, user)
-
Get the username of a user id if available, or their id if they couldn't be
found.
Parameters:
Name |
Type |
Description |
guild |
Discord~Guild
|
The guild to look for the user in. |
user |
string
|
The id of the user to find the name of. |
- Source:
-
Returns:
The user's name or id if name was unable to be found.
-
Type
-
string
-
<private, inner> getStatsString( [short] [, locale])
-
Get this shard's stats and format it into a human readable
string.
Parameters:
Name |
Type |
Argument |
Default |
Description |
short |
boolean
|
<optional>
|
false
|
Provide a short version. |
locale |
string
|
<optional>
<nullable>
|
null
|
Language to use for strings. |
- Source:
-
Returns:
The formatted string.
-
Type
-
string
-
<private, inner> help(msg)
-
Send help message to DM and reply to server.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
- Source:
-
-
<private, inner> includeIterate(game, obj [, onlyError] [, locale])
-
Include a single user from the game as a single iteration step
of the include command.
Parameters:
Name |
Type |
Argument |
Default |
Description |
game |
HungryGames~GuildGame
|
|
|
The game to manipulate. |
obj |
string
|
HungryGames~Player
|
HungryGames~NPC
|
|
|
Player for this
iteration. |
onlyError |
boolean
|
<optional>
|
false
|
Only add error messages to response. |
locale |
string
|
<optional>
<nullable>
|
null
|
String locale for respons formatting. |
- Source:
-
Returns:
Response text for the user performing the operation.
-
Type
-
string
-
<private, inner> includeNPC(msg, id)
-
Include an NPC in the game.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> includeUser(msg, id [, game])
-
Add a user back into the next game.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> listNPCs(msg, id)
-
List all currently created NPCs.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> listPlayers(msg, id)
-
Show a formatted message of all users and teams in current server.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> loadDefaultsFromIds(obj)
-
Load all default events from file, described by the loaded
list from file.
Parameters:
Name |
Type |
Description |
obj |
Object
|
List of IDs to load. |
- Source:
-
-
<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.
-
Type
-
MessageMaker
-
<private, inner> makePlayerListEmbed(game [, finalMessage] [, locale])
-
Create a Discord~EmbedBuilder that lists all
included and excluded players in the game.
Parameters:
Name |
Type |
Argument |
Default |
Description |
game |
HungryGames~GuildGame
|
|
|
The game to format. |
finalMessage |
Discord~EmbedBuilder
|
<optional>
|
|
Optional existing
embed to modify instead of creating a new one. |
locale |
string
|
<optional>
<nullable>
|
null
|
Language locale to format titles. |
- Source:
-
Returns:
The created message embed.
-
Type
-
Discord~EmbedBuilder
-
<private, inner> mkCmd(cb)
-
Make a subcommand handler with the given callback function. This is a
wrapper around existing functions.
Parameters:
- Source:
-
Returns:
Subcommand initial handler that will fire
when command is fired. Calls the passed callback handler with the mapped
parameters.
-
Type
-
Command~commandHandler
-
<private, inner> moveTeamUser(msg, id [, game])
-
Move a single user to another team.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> newReact(duration)
-
Update HungryGames~listenersEndTime because a new listener was
registered with the given duration.
Parameters:
Name |
Type |
Description |
duration |
number
|
The length of time the listener will be active. |
- Source:
-
-
<private, inner> nextDay(msg, id [, autoStep])
-
Simulate a single day then show events to users.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
autoStep |
boolean
|
<optional>
|
true
|
Value to pass for autoStep. |
- Source:
-
-
<private, inner> nothing()
-
Get a random word that means "nothing".
- Source:
-
Returns:
A word meaning "nothing".
-
Type
-
string
-
<private, inner> onChannelDelete(channel)
-
Handle a channel being deleted. Cleans up games that may be in
progress in these channels.
Parameters:
Name |
Type |
Description |
channel |
Discord~DMChannel
|
Discord~GuildChannel
|
The channel that
was deleted. |
- Source:
-
Listens to Events:
- Discord~Client#event:channelDelete
-
<private, inner> onGuildDelete(guild)
-
Handle being removed from a guild.
Parameters:
Name |
Type |
Description |
guild |
Discord~Guild
|
The guild that we just left. |
- Source:
-
Listens to Events:
- Discord~Client#event:guildDelete
-
<private, inner> optChangeListener(msg_, options, index)
-
The callback for when the user chooses to change page of the options.
Parameters:
Name |
Type |
Description |
msg_ |
Discord~Message
|
The message we sent showing the options. |
options |
object
|
The options to show in the message. |
index |
number
|
The page index to show. |
- Source:
-
-
<private, inner> parseGamePlayers(msg, game)
-
Fetch an array of user IDs that are in the current game and
have been referenced in any way due to the given message from the user.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
game |
HungryGames~GuildGame
|
The game this is for. |
- Source:
-
Returns:
Array of user IDs that are in the current game that
were mentioned.
-
Type
-
Array.<string>
-
<private, inner> parseMentions(msg)
-
Parse all mentioned users from all softMentions and Discord
mentions, including roles.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message containing mention data. |
- Source:
-
Returns:
Collection of all users
mentioned.
-
Type
-
Discord~Collection.<Discord~User>
-
<private, inner> pauseAutoplay(msg, id)
-
Stop autoplaying.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> pauseGame(msg, id)
-
Stop the game in the middle of the day until resumed. Just clears the
interval for the game.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> randomizeTeams(msg, id [, silent])
-
Swap random users between teams.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
silent |
boolean
|
<optional>
|
false
|
If true, this will not attempt to send
messages to the channel where the msg was sent.. |
- Source:
-
-
<private, inner> removeNPC(msg, id)
-
Delete an NPC.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> renameNPC(msg, id)
-
Rename an NPC.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> renameTeam(msg, id [, silent])
-
Rename a team.
Parameters:
Name |
Type |
Argument |
Default |
Description |
msg |
Discord~Message
|
|
|
The message that lead to this being called. |
id |
string
|
|
|
The id of the guild this was triggered from. |
silent |
boolean
|
<optional>
|
false
|
Disable replying to message. |
- Source:
-
-
<private, inner> reply(msg, titleKey, bodyKey [, rep])
-
Reply to msg with locale strings.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
Message to reply to. |
titleKey |
string
|
<nullable>
|
String key for the title, or null for default. |
bodyKey |
string
|
|
String key for the body message. |
rep |
string
|
<optional>
<repeatable>
|
Placeholder replacements for the body only. |
- Source:
-
Returns:
Message send promise from
Discord.
-
Type
-
Promise.<Discord~Message>
-
<private, inner> resetGame(msg, id)
-
Reset data that the user specifies.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> setupHelp()
-
Set all help messages once we know what prefix to use.
- Source:
-
-
<private, inner> showGameInfo(msg, id)
-
Send all of the game data about the current server to the chat.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> showOpts(msg, options)
-
Format the options for the games and show them to the user.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
options |
object
|
The options to format. |
- Source:
-
-
<private, inner> startAutoplay(msg, id [, game])
-
Start autoplaying.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to start autoplay on. |
- Source:
-
-
<private, inner> startGame(msg, id)
-
Start the games in the channel this was called from.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> swapTeamUsers(msg, id [, game])
-
Swap two users from one team to the other.
Parameters:
Name |
Type |
Argument |
Description |
msg |
Discord~Message
|
|
The message that lead to this being called. |
id |
string
|
|
The id of the guild this was triggered from. |
game |
HungryGames~GuildGame
|
<optional>
|
The game object to modify. |
- Source:
-
-
<private, inner> toggleOpt(msg, id)
-
Change an option to a value that the user specifies.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
id |
string
|
The id of the guild this was triggered from. |
- Source:
-
-
<private, inner> updateBattles()
-
Parse all battles from file.
- Source:
-
-
<private, inner> updateEvents()
-
Parse all default events from file.
- Source:
-
-
<private, inner> useWebsiteForCustom(msg)
-
Tell users to use the website to manage custom events.
Parameters:
Name |
Type |
Description |
msg |
Discord~Message
|
The message that lead to this being called. |
- Source:
-