Interface: Action

HungryGames~ Action

Base for actions to perform in response to certain things that happen during a hunger games.
Source:

Classes

GiveRoleAction
RunCommandAction
SendAutoplayingMessageAlertAction
SendDayEndMessageAction
SendDayStartMessageAction
SendEventMessageAction
SendMessageAction
SendPlayerRankMessageAction
SendStatusListAction
SendTeamRankMessageAction
SendVictorAction
TakeRoleAction

Members


<static> actionList :Array.<{path: string, pickable: boolean}>

List of available actions.
Type:
  • Array.<{path: string, pickable: boolean}>
Source:

<static> triggerMeta :object.<{order: number, types: Array.<string>, description: string}>

Map of metadata for available triggers, to aid with UIs.
Type:
  • object.<{order: number, types: Array.<string>, description: string}>
Source:

<private, constant> _handler :HungryGames~Action~ActionHandler

Passed handler to fire once triggered.
Type:
Source:

<private> _saveData :object

Data injected into save file that the `create` function uses to restore data. Must be serializable.
Type:
  • object
Default Value:
  • {}
Source:

delay :number

Delay handler call by this many milliseconds after triggered.
Type:
  • number
Default Value:
  • 0
Source:

id :string

The unique ID for this action. Probably globally unique, definitely unique per-trigger in a guild.
Type:
  • string
Source:

serializable

Convert this object to serializable format for saving to file. Injects data from `this._saveData`.
Source:

Methods


<abstract, static> create(client, id, obj)

Create action from save data.
Parameters:
Name Type Description
client Discord~Client Bot client context to get object references.
id string Guild ID this action is for.
obj object The parsed data from file.
Source:
Returns:
The created action.
Type
HungryGames~Action

<static> createID()

Generate an ID for an Action. Does not check for collisions.
Source:
Returns:
Generated ID.
Type
string

<static> from(client, id, obj)

Create an Action object from save data. Looks up action from HungryGames~Action~actionList.
Parameters:
Name Type Description
client Discord~Client Client reference for obtaining discord object references.
id string The Guild ID this action is for.
obj object The object data from save file.
Source:
Returns:
The created action, or null if failed to find the action.
Type
Action

trigger(hg, game [, args])

Trigger the action to be performed.
Parameters:
Name Type Argument Description
hg HungryGames HG context.
game HungryGames~GuildGame Game context.
args * <optional>
<repeatable>
Additional arguments to pass.
Source:

Type Definitions


ActionHandler(hg, game)

Handler function for a generic action.
Parameters:
Name Type Description
hg HungryGames HG context.
game HungryGames~GuildGame Game context.
Source:

ChannelActionHandler(hg, game, channel)

Handler function for a action to be performed on the game channel.
Parameters:
Name Type Description
hg HungryGames HG context.
game HungryGames~GuildGame Game context.
channel Discord~TextChannel Channel context.
Source: