commands

NodeBB provider module User class

Author: Accalia
License: MIT

commands.bindCommands(forum) ⇒ Commands

Create a Commands class and bind it to a forum instance.

Kind: static method of commands
Returns: Commands - A Commands class bound to the provided forum instance

Param Type Description
forum Provider A forum Provider instance to bind to constructed Commands class

bindCommands~handlers

Command Handlers

Kind: inner constant of bindCommands
Default: {"help":""}

bindCommands~helpTopics

Extended help topics

Kind: inner constant of bindCommands

commands~Command

Command Class. Represents a single command within a post

Kind: inner class of commands

new Command(definition, parent)

Create a Command from a defintiton

Param Type Description
definition object Parsed Command defintition
parent Commands Commands instnace that created this Command

command.line : string

Full Command line definition

Kind: instance property of Command
Access: public

command.command : string

Command name

Kind: instance property of Command
Access: public

command.mention : boolean

Is Command a mention command?

Kind: instance property of Command
Access: public

command.args : Array.<string>

Command arguments

Kind: instance property of Command
Access: public

command.parent : Commands

Parent Commands object

Kind: instance property of Command
Access: public

command.replyText : string

Text to post as a reply to the command

Kind: instance property of Command
Access: public

command.executable : boolean

Indicates if this command will execute any handler

Kind: instance property of Command
Access: public

command.execute() ⇒ Promise

Execute the command handler for this command

Kind: instance method of Command
Returns: Promise - Resolves when command has fully executed
Access: public

command.getPost() ⇒ Promise.<Post>

Get Full Post the command refers to

Kind: instance method of Command
Returns: Promise.<Post> - Resolves to retrieved Post
Access: public

command.getTopic() ⇒ Promise.<Topic>

Get Topic command was posted to

Kind: instance method of Command
Returns: Promise.<Topic> - Resolves to retrieved Topic
Access: public

command.getUser() ⇒ Promise.<User>

Get User who posted the command

Kind: instance method of Command
Returns: Promise.<User> - Resolved to retrieved User
Access: public

command.reply(content)

Reply to command with content

Kind: instance method of Command
Access: public

Param Type Description
content string Content to reply with

commands~Commands

Commands class. Represents all commands for a Notification

Kind: inner class of commands
Access: public

new Commands(ids, postBody, handler)

Construct a Commands object from notification

Param Type Description
ids Ids Useful Ids
postBody string Raw Content of post containing commands
handler ReplyHandler Reply handler

commands.ids : Ids

Ids relevant to this Commands object

Kind: instance property of Commands
Access: public

commands.commands : Array.<Command>

Commands contained in this Commands object

Kind: instance property of Commands
Access: public

commands.text : string

Text this Commands object parsed

Kind: instance property of Commands
Access: public

commands.getPost() ⇒ Promise.<Post>

Get the Post this Commands object referrs to

Kind: instance method of Commands
Returns: Promise.<Post> - Resolves to the retrieved Post
Access: public

commands.getTopic() ⇒ Promise.<Topic>

Get the Topic this Commands object referrs to

Kind: instance method of Commands
Returns: Promise.<Topic> - Resolves to the retrieved Topic
Access: public

commands.getUser() ⇒ Promise.<User>

Get the user who sent these commands

Kind: instance method of Commands
Returns: Promise.<User> - Resolved to the retrieved User
Access: public

commands.execute() ⇒ Promise.<Commands>

Execute the commands this object contains

Kind: instance method of Commands
Returns: Promise.<Commands> - Resolves to self when all commands have been processed
Access: public

Commands.get(notification, postBody, handler) ⇒ Promise.<Commands>

Get Commands from a notification

Kind: static method of Commands
Returns: Promise.<Commands> - Resolves to parsed commands
Access: public

Param Type Description
notification Notification Notification to get commands for
postBody string Post Body to parse for commands
handler ReplyHandler Reply function for commands

Commands.add(command, helpText, handler) ⇒ Promise

Add a command to this forum instance

Kind: static method of Commands
Returns: Promise - Resolves when command has been added
Access: public

Param Type Description
command string Command to be added
helpText string Short help text for command
handler CommandHandler Function to handle the command