Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

[events] command

Alex Pham edited this page Sep 1, 2016 · 6 revisions
Key Type Description
raw Object Raw message object
id Int Message ID
from Object User object
message String Raw message
mentions Array String array of people metioned
muted Bool Mute status of user
message String Message type
command String Message w/o command indicator
args Array String array of command arguments
respond Function Sends a message that mentions the command's sender
respondTimeout Function Sends a message, deletes it after specified time
havePermission Function Returns if user has perm or not (Bool)
isFrom Function Returns true if userid (from arg) is valid for the user

Example

{ raw: 
   {
     cid: '3832143-1472747916733',
     message: '!command',
     sub: 1,
     uid: 111111,
     un: 'username'
   },
  id: '3832143-1472747916733',
  from: 
   User {
     avatarID: 'zoo-s03',
     badge: null,
     blurb: undefined,
     gRole: 0,
     grab: false,
     id: 111111,
     ignores: undefined,
     joined: '2016-09-01 18:43:00.359000',
     language: null,
     level: 17,
     notifications: undefined,
     pp: undefined,
     pw: undefined,
     role: 2,
     slug: null,
     status: 1,
     sub: 1,
     username: 'username',
     vote: 0,
     xp: undefined 
  },
  message: '!command',
  mentions: [],
  muted: false,
  type: 'message',
  command: 'command',
  args: [ '' ],
  respond: [Function],
  respondTimeout: [Function],
  havePermission: [Function],
  isFrom: [Function]
}

Code Example:

bot.on('command:ping', function(data) {
   return data.respond('Pong!')
});

bot.on('command:skip', function(data) {
    if (data.havePermission(PlugAPI.ROOM_ROLE.BOUNCER)) {
        bot.moderateForceSkip(function() {
           data.respond('Skipped the song');
        });
    }
     // OR
     data.havePermission(PlugAPI.ROOM_ROLE.BOUNCER, function() { 
        bot.moderateForceSkip(function() {
           data.respond('Skipped the song');
        });
     });
})
Clone this wiki locally