Members
(constant) decrypt
Utility module to decode sensitive/hidden data for use, such as quiz answers
- Source:
leader
- Source:
- See:
Methods
add()
Example
hosted_page
{ id: 'ABCDEKwUSVyLqzwoIeSvmhz40NV12345',
type: 'checkout_new',
url: 'https://example-test.chargebee.com/pages/v3/VPQ6NKwUSVyLqzwoIeSvmhz40NV0jOyq/',
state: 'created',
embed: false,
created_at: 1612759805,
expires_at: 1612770605,
object: 'hosted_page',
updated_at: 1612759805,
resource_version: 1612759805404
}
(async) addPlayer(member, message)
Add a player to the queue to be added to the game.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
member |
Discord.Member
|
string
|
The member or id of the member to add |
message |
string
|
The message to send if the user is successfully queued. Set to "null" for no message to be sent. |
(async) buyShopItem(userID, itemID, cost)
Buys a shop item
- Source:
Parameters:
Name | Type | Description |
---|---|---|
userID |
string
|
The ID of the user |
itemID |
string
|
The ID of the item |
cost |
string
|
The cost of the item |
Example
dbClient.updateShopItem('gord_board', {cost: 120000, description, 'A board that is not overpriced!'} )
(async) clearCollectors(collectors)
Stop all collectors and reset collector list.
- Deprecated:
- Yes
- Source:
Parameters:
Name | Type | Description |
---|---|---|
collectors |
Array.<Discord.Collector>
|
List of collectors |
(async) configureOptions() → {Object.<String, ConfiguredOption>}
Allow the game leader to set options, and outputs the options to this.options
.
- Source:
Returns:
- Type:
-
Object.<String, ConfiguredOption>
The configured options, with their key as the option friendly name, and value as the configured value.
decrypt(password, data, encodingopt)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string
|
Passkey for the decryption. |
||
data |
string
|
The data to decode |
||
encoding |
string
|
<optional> |
hex |
The encoding type, for example 'hex' |
end(winner, endPhrase)
End a game. This will be called when a player wins or the game is force stopped.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
winner |
object
|
The game winner |
endPhrase |
string
|
The message to be sent at the end of the game. |
forceStop()
Force ends a game. This will be called by the end command.
- Source:
(async, abstract) generateOptions()
Generates option lists, each game implements this method in its own way.
- Source:
generateUIID(user, channel)
Generates a guaranteedâ„¢ unique WebUI identifier.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
user |
String
|
Number
|
The user's ID |
channel |
String
|
Number
|
The game channel's ID |
getPrefix(channel) → {string}
Returns a prefix
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
Channel
|
The channel that the message was sent in |
Returns:
- Type:
-
string
hash()
Creates a token (not a real hash) to reference the id and token
- Source:
(async) hasItem() → {Boolean}
Sees if a user has an item in their inventory.
- Source:
Returns:
- Type:
-
Boolean
(async) init()
Begins a new game. This will be called by the play command.
- Source:
(async) initialize()
Sets up a DatabaseClient for use by connecting to the database instance
- Source:
(async) initialize()
Initializes a new instance of a ShopGenerator
- Source:
join(callback)
Begins the join phase of the game.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
function
|
The callback that is executed when the players are collected. |
(abstract) play()
The method called after user configuration. This will be custom for each game.
- Source:
(async) refreshShopItemCache()
Refreshes shop item cache
- Source:
(async) removePlayer(member, message)
Add a player to the queue to be removed from the game.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
member |
string
|
Discord.Member
|
The member or member id to kick. |
message |
string
|
The message to send if the user is successfully queued. Set to "null" for no message to be sent. |
renderOptionInfo(option)
Display the choices of a game's option.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
option |
GameOption
|
The option to render into text. |
(async) setLeader(member, message)
Sets or changes the game leader during the game.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
member |
Discord.Member
|
string
|
The member or id of the member to add |
message |
string
|
The message to send if the user is successfully queued. Set to "null" for no message to be sent. |
start(game, msg)
Starts a new game
- Source:
Parameters:
Name | Type | Description |
---|---|---|
game |
Game
|
The game to play |
msg |
Discord.Message
|
The Discord message that initiated this game |
titleCase(string)
Converts a string to 'Title Case'
- Source:
Parameters:
Name | Type | Description |
---|---|---|
string |
string
|
String to convert |
Returns:
string
updatePlayers()
Update players who are queued to join or leave the game.
- Source:
(async) updateShopItem(item, props)
Updates a shop item
- Source:
Parameters:
Name | Type | Description |
---|---|---|
item |
string
|
The ID of the item |
props |
object
|
a key-value pairing of the properties to update |
Example
dbClient.updateShopItem('gord_board', {cost: 120000, description, 'A board that is not overpriced!'} )
Type Definitions
ConfiguredOption
An option that has been configured by the game leader and has a set value.
- Source:
Type:
-
String
|Number
|Array.<(String|Number)>
GameMetadata
The metadata for a given game.
Properties:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
id |
String
|
The game's unique identifier. |
||||||
name |
String
|
The name of the game. |
||||||
about |
String
|
A short description about the game. |
||||||
rules |
String
|
This game's rules and instructions. |
||||||
unlockables |
Boolean
|
Whether or not the game has unlockables in the shop. |
||||||
playerCount |
Object
|
The number of players that can join this game. |
||||||
Name | Type | Description |
---|---|---|
min |
number
|
The minimum required number of players. |
max |
number
|
The maximum required number of players. |
- Source:
Type:
-
Object
GameOption
A user-configurable option for a game, modified during a game's init stage.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
friendlyName |
String
|
The user-friendly name of this option. |
|
type |
String
|
The type of option. Must be one of:
|
|
default |
String
|
Number
|
Array.<(String|Number)>
|
The default value for this option. |
|
choices |
Array.<String>
|
<optional> |
An array of choices the user can pick from. Required for checkboxes and radio types. |
note |
String
|
<optional> |
A note displayed during the selection screen |
filter |
function
|
<optional> |
A filter function that validates the user's input message, and only accepts the input if the function returns true. |
- Source:
- See:
Type:
-
Object
GameSettings
An object with configurable game settings. This field is currently unused.
- Source:
Type:
-
Object
handlePlayerWebResponse(data, UI, client)
Callback to handle the data received from the Web UI
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
PlayerWebResponse
|
User input received from the web UI |
UI |
Object
|
The web UI object itself |
client |
Discord.Client
|
The discord client that initiated this request |
PlayerWebResponse
Properties:
Name | Type | Description |
---|---|---|
result |
*
|
The user's result |
- Source:
Type:
-
Object
UserData
Properties:
Name | Type | Description |
---|---|---|
userID |
String
|
The user's ID |
unlockedItems |
Array.<String>
|
The list of unlocked items, categorized by ID |
- Source:
Type:
-
Object
WebUI
- Source:
WebUIOptions
The options for this WebUI.
Properties:
Name | Type | Description |
---|---|---|
type |
String
|
The type of WebUI to generate. |
message |
String
|
The custom message the user sees on the WebUI. |
variables |
Array.<Array.<String>>
|
Array.<Array.<RegExp>>
|
Array of [tag, replacement] pairs to customize webpage content. Accepts RegExp. |
duration |
Number
|
How long to keep the webpage alive, in seconds |
- Source:
Type:
-
Object