plugAPI

5.1.0

PlugAPI

Create instance of PlugAPI.

new PlugAPI(authenticationData: any, callback: Function?)

Extends EventEmitter3

Parameters
authenticationData (any)
callback (Function?) An optional callback utilized in async mode
Example

There are multiple ways to create a bot. Sync vs Async, FB vs guest or email. Please choose only one of the examples to use.

// Sync
// Password
const bot = new PlugAPI({email: 'something@something.com', password: 'hunter2'});

// Facebook
// To login with fb will require logging in via plug and viewing the data sent in to /_/auth/facebook via the network tab of dev tools.

const bot = new PlugAPI({
   facebook: {
      userID: 'xxxxxxxx',
      accessToken: 'xxxxxx'
    }
});

// Guest
const bot = new PlugAPI();
// OR
const bot = new PlugAPI({ guest: true });

// Async

// Password
new PlugAPI({email: 'something@something.com', password: 'hunter2'}, (err, bot) => {
   if (err) throw new Error(err);

});

// Facebook
new PlugAPI({
   facebook: {
      userID: 'xxxxxxxx',
      accessToken: 'xxxxxx'
    }
}, (err, bot) => {
   if (err) throw new Error(err);
});

// Guest
new PlugAPI({ guest: true }, (err, data) => {
    if (err) throw new Error(err);
]});
Static Members
ROOM_ROLE
GLOBAL_ROLES
STATUS
BAN
BAN_REASON
MUTE
MUTE_REASON
WLBAN
WLBAN_REASON
Utils
Instance Members
commandPrefix
multiLine
multiLineLimit
processOwnMessages
deleteCommands
deleteMessageBlocks
deleteAllChat
mutedTriggerNormalEvents
preCommandHandler(obj?)
connect(roomSlug)
changeRoom(slug)
close(reconnecting)
getChatHistory()
getHistory(callback)
getBoothMeta()
getHistoryID()
getMedia()
getRoomMeta()
getRoomScore()
joinBooth(callback)
leaveBooth(callback)
sendChat(msg, timeout?)
getAvatar()
getAvatars(callback)
setAvatar(id, callback)
getAdmins()
getAllStaff(callback)
getAmbassadors()
getAudience()
getDJ()
getDJs()
getHost()
getSelf()
getStaff()
getUser(uid?)
getUsers()
getWaitList()
getWaitListPosition(uid?)
havePermission(uid, permission, isGlobal?)
getTimeElapsed()
getTimeRemaining()
getCommandPrefix()
setCommandPrefix(prefix)
getBaseURL()
setBaseURL(url)
getSocketURL()
setSocketURL(url)
woot(callback?)
meh(callback?)
grab(callback?)
activatePlaylist(pid, callback?)
addSongToPlaylist(pid, sdata, callback?)
removeSongFromPlaylist(pid, mid, callback?)
createPlaylist(name, callback?)
deletePlaylist(pid, callback?)
getActivePlaylist(callback?)
getPlaylist(pid, callback?)
getPlaylists(callback)
getPlaylistMedias(pid, callback)
playlistMoveMedia(pid, ids, beforeID, callback?)
shufflePlaylist(pid, callback?)
moderateAddDJ(uid, callback?)
moderateBanUser(userID, reason?, duration?, callback?)
moderateDeleteChat(cid, callback?)
moderateForceSkip(callback?)
selfSkip(callback?)
moderateMoveDJ(userID, position, callback?)
moderateMuteUser(userID, reason?, duration?, callback?)
moderateRemoveDJ(uid, callback?)
moderateSetRole(userID, roleID, callback?)
moderateWaitListBan(userID, reason?, duration?, callback?)
moderateUnbanUser(uid, callback?)
moderateWaitListUnbanUser(uid, callback?)
moderateUnmuteUser(uid, callback?)
changeRoomName(name, callback?)
changeRoomChatLevel(minChatLevel, callback?)
changeRoomDescription(description, callback?)
changeRoomWelcome(welcome, callback?)
changeDJCycle(shouldCycle, callback?)
getJar(callback?)
setBadge(id, callback?)
getBadge(callback?)
getBadges(callback?)
moderateLockBooth(locked, clear, callback?)
Events
BAN
MODERATE_MUTE
ROOM_WELCOME_UPDATE
ADVANCE
VOTE
KILL_SESSION
GRAB
GIFTED
EARN
DJ_LIST_UPDATE
DJ_LIST_LOCKED
DJ_LIST_CYCLE
MODERATE_WLBAN
COMMAND
CHAT_LEVEL_UPDATE
CHAT_EMOTE
CHAT_DELETE
CHAT_COMMAND
CHAT
MODERATE_SKIP
ROOM_NAME_UPDATE
MODERATE_STAFF
MODERATE_BAN

RESTCallback

Common callback for all API calls

RESTCallback(err: (null | String), data: (null | any))

Type: Function

Parameters
err ((null | String)) Error message on error; otherwise null
data ((null | any)) Data on success; otherwise null

User

Represents a User. Note that some properties are only shown for the bot only and not other users.

new User(data: Object, instance: Room)
Parameters
data (Object) Represents a user.
Name Description
data.avatarID (String | null) (default null) The user's avatar ID.
data.badge (String | null) (default null) The user's badge ID.
data.blurb (String | null) (default undefined) The user's blurb from their profile page.
data.gRole Number (default 0) The user's global role (0 if not a BA / Admin)
data.grab Boolean (default false) If the user has grabbed a song
data.id Number (default -1) The user's ID.
data.ignores Array (default []) An array of users that are ignored. Only shown for the bot user.
data.joined String (default '') The time a user joined plug.dj as as string. Empty if not provided.
data.language String (default null) The user's language.
data.level Number (default 1) The user's level. Only shown for the bot user.
data.notifications Array (default []) The user's notifications. Only shown for the bot user.
data.pp (Number | null) (default undefined) The user's Plug Points. Only shown for the bot user.
data.pw (Boolean | null) (default undefined) Whether the bot user is signed in via password or not.
data.rawun String (default '') The user's username.
data.role Number (default 0) The user's Role. See PlugAPI.ROOM_ROLE for more info.
data.silver Boolean (default false) Whether the user is a silver subscriber or not.
data.slug (String | null) (default null) The user's slug to be used in a profile. https://plug.dj/@/slug (only exists for level > 5)
data.status Number (default 1) The user's status.
data.sub Number (default 0) Whether the user is a gold subscriber or not.
data.username String (default '') The user's username with HTML entities decoded.
data.vote Number (default 0) The user's current vote.
data.xp (Number | null) (default undefined) The user's XP. Only shown for the bot user.
instance (Room) The specific instance of the Room Class.
Static Members
addToWaitList()
removeFromWaitList()
moveInWaitList(pos)