module

Library: Chat Commands

Endorsements
0
Installs
6.02%
Comments
0
Latest version1.3.3
Minimum Core0.6.2
Compatible Core0.7.9
Last updated2 months ago
Created6 months ago
Authors
Languages
Systems All systems
Project source Project URL

LIBRARY: This module is just a dependency for other modules and provides little functionality on its own.

 

Allows for easy registration of custom chat commands such as /command.

The library will handle multiple commands in a single string - if any are marked shouldDisplayToChat, then a single chat message is created with all commands stripped.

 

Example Usage

Hooks.on("chatCommandsReady"function(chatCommands) {

  // (GM Only) This Command will display the text after the command as well as invoke the method
  chatCommands.registerCommand(chatCommands.createCommandFromData({
    commandKey: "/displaytochat",
    invokeOnCommand: (chatlogmessageTextchatdata=> {
      console.log("Invoked /displaytochat");
      console.log(messageText);
    },
    shouldDisplayToChat: true,
    iconClass: "fa-sticky-note",
    description: "Display to chat",
    gmOnly: true
  }));


  // This will eat the command, displaying nothing to chat, as well as invoke the method
  chatCommands.registerCommand(chatCommands.createCommandFromData({
    commandKey: "/dontdisplaytochat",
    invokeOnCommand: (chatlogmessageTextchatdata=> {
      console.log("Invoked /dontdisplaytochat");
      console.log(messageText);
    },
    shouldDisplayToChat: false,
    iconClass: "fa-sticky-note",
    description: "Don't display to chat"
  }));


  // This uses the optional createdMessageType option to make the created message "Out of Character"
  chatCommands.registerCommand(chatCommands.createCommandFromData({
    commandKey: "/outofcharacter",
    invokeOnCommand: (chatlogmessageTextchatdata=> {
      console.log("Invoked /outofcharacter");
      console.log(messageText);
    },
    shouldDisplayToChat: true,
    createdMessageType: 1,
    iconClass: "fa-sticky-note",
    description: "Posts message OOC"
  }));


  // This modifies the text that will end up in the created message
  var command = chatCommands.createCommandFromData({
    commandKey: "/toupper",
    invokeOnCommand: (chatlogmessageTextchatdata=> {
      console.log("Invoked /toupper");
      messageText = messageText.toUpperCase();
      console.log(messageText);
      return messageText;
    },
    shouldDisplayToChat: true,
    iconClass: "fa-sticky-note",
    description: "Uppercases text"
  });

  chatCommands.registerCommand(command);

  // Actually, deregister it
  chatCommands.deregisterCommand(command);
});
 
 
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x