- Client
The main Client object
- Collection ⇐
Map
Hold a bunch of something
- Ban
Represents a ban
- Booth
Represents a rooms booth settings
- ExtendedUser
An user with more information
- Media
Represents a media object
- Message
Represents a single chat message
- MinimalUser
An user with the minimum of information plug gives
- Playback
Represents a Play
- Queue
Represents the queue of a room
- Room
Represents a room
- User
Represents a user.
The main Client object
Kind: global class
Properties
Name | Type | Description |
---|---|---|
ready | Boolean |
Indicates if the client is ready for rest calls. |
room | Room |
The current room |
socketStatus | String |
The current status of the socket connection |
self | ExtendedUser |
The logged-in user |
- Client
- new Client(email, password, [options])
- .connect() ⇒
Promise
- .joinRoom(slug) ⇒
Promise
- .sendChat(content) ⇒
Promise
- .banUser(userID, [time], [reason]) ⇒
Promise
- .unbanUser(userID) ⇒
Promise
- .skipSong([userID], [historyID]) ⇒
Promise
- .deleteMessage(chatID) ⇒
Promise
- .setRole(userID, role) ⇒
Promise
- .removeRole(userID) ⇒
Promise
- "ready"
- "joinedRoom"
- "socketError"
- "socketClose"
- "rawWS"
- "unknown"
- "connect"
- "chat"
- "chatDelete"
- "guestJoin"
- "userJoin"
- "friendJoin"
- "guestLeave"
- "userLeave"
- "advance"
- "queueUpdate"
- "cycleChange"
- "lockChange"
- "vote"
- "grab"
- "floodApi"
- "floodChat"
- "slowMode"
- "earn"
- "gifted"
- "ban"
- "addDj"
- "userBan"
- "moveUser"
- "skip"
- "killSession"
- "error"
- "levelUp"
- "maintenance"
- "maintenanceAlert"
- "plugMessage"
- "plugUpdate"
- "selfSkip"
Create a new Client
Param | Type | Default | Description |
---|---|---|---|
String |
The Email to use for login | ||
password | String |
the password to use | |
[options] | Object |
An object containing additional settings | |
[options.useFriends] | Boolean |
false |
Whether the bot should distinguish between friends or not |
[options.autoConnect] | Boolean |
false |
If the bot should automatically establish a socket connection |
[options.autoReconnect] | Boolean |
false |
If the bot should automatically reopen an errored or closed socket connection |
[options.requestFreeze] | Number |
1000 |
The time all requests are freezed when a ratelimit warning is received. Can not be lower than 1 |
[options.chatFreeze] | Number |
1000 |
The time all chatmessages are freezed when receiving a "floodChat" event |
[options.ignoreRateLimits] | Boolean |
false |
Whether to respect plug.dj's rate limits or not. It's not recommended to use this option except when you are having your own handling for rate limits. |
[options.updateNotification] | Boolean |
false |
Whether you want to notified about (possible) updates. |
Establishes the Websocket Conncetion to plug.dj
Kind: instance method of Client
Joins a room (community)
Kind: instance method of Client
Param | Type | Description |
---|---|---|
slug | String |
the slug to join |
Sends a message in chat
Kind: instance method of Client
Param | Type | Description |
---|---|---|
content | String |
The message content |
Bans an user from the room.
Kind: instance method of Client
Param | Type | Default | Description |
---|---|---|---|
userID | Number |
The id of the user | |
[time] | String |
'd' |
The ban duration, defaults to one day ('h' for one hour, 'd' for a day, 'f' for forever) |
[reason] | Number |
1 |
The ban reason, defaults to 'violating community rules' |
Removes a ban for a user
Kind: instance method of Client
Param | Type | Description |
---|---|---|
userID | Number |
The id of the user |
Skips the current playback. All fields are automatically filled in, however it is recommended to provide at least the userID to prevent wrong skips
Kind: instance method of Client
Param | Type | Description |
---|---|---|
[userID] | Number |
The id of the current dj |
[historyID] | String |
The id of the current playback |
Deletes a chat message
Kind: instance method of Client
Param | Type | Description |
---|---|---|
chatID | String |
Id of the message to be deleted |
Sets an user as staff
Kind: instance method of Client
Param | Type | Description |
---|---|---|
userID | Number |
|
role | Number |
the role, 0 for grey, 1 for res dj, 2 for bouncer, 3 for manager, 4 for co-host, 5 for host |
Shorthand for {Client}.setRole(userID, 0)
Kind: instance method of Client
Param | Type |
---|---|
userID | Number |
Emitted when the client is ready to make rest calls
Kind: event emitted by Client
Emitted when a room was joined and the caches were filled.
Kind: event emitted by Client
Emitted when the socket errors
Kind: event emitted by Client
Emitted when the socket is closed
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
data.code | Number |
The close code. |
data.reason | String |
A human-readable close reason. |
Emits the raw packages.
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
data | Object |
The data received from plug.dj |
Emitted when an unknown package is received from plug. This can indicate an outdated version of plugging-you-in
Kind: event emitted by Client
Emitted when the socket connection is up.
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
room | String |
The room the client is currently in |
Emitted when a chat message is received
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
message | Message |
The received message |
Emitted when a moderator deletes a chat message
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
message | Message |
The deleted message (can be null if message is not cached) |
The | User |
user who deleted the message |
Emitted when a guest joins the room
Kind: event emitted by Client
Emitted when an users joins the room
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The joined user |
Emitted when an users joins the room
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The joined user |
Emitted when a guest leaves the room
Kind: event emitted by Client
Emitted when an user leaves the room.
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The left user |
Emitted when a new song is played
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
playback | Playback |
The current playback |
oldPlayback | Playback |
The playback before. |
Emitted when the waitlist changes
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
queue | Array.<User> |
The new queue as an array of users |
oldQueue | Array.<User> |
The old queue |
Emitted when the cycle-mode gets changed
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The user who changed the cycle mode |
state | Boolean |
The new cycle-mode |
Emitted when the queue gets locked/unlocked/cleared
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The user who took the action |
lock | Boolean |
The new lock-state of the queue |
clear | Boolean |
Wheter the queue got cleared or not |
Emitted when someone votes on a song
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The user who voted |
vote | Number |
The vote, 1 for woot, -1 for meh |
Emitted when an user grabs a song
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The user who grabbed the song |
Emitted when too many api requests are fired. You don't need to handle it if you leave options.requestFreeze
at the default value, however all actions will be stopped for 10 seconds
Kind: event emitted by Client
Emitted when you are sending too many chat messages and plugging-you-in isn't good enough at limiting you. Plugging-you-in will handle this by stopping to send messages entirely for a few seconds
Kind: event emitted by Client
Emitted when chat enters slow mode.
Kind: event emitted by Client
Emitted when the bot earns experience/plug points or levels up
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
earn | Object |
|
earn.xp | Number |
The new amount of xp |
earn.pp | Number |
The new amount of plug points |
earn.level | Number |
The new level |
Emitted when someone gifts plug points to someone
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
sender | User |
The user who sent the gift |
receiver | User |
The user who received the gift |
Emitted when you are banned from a community
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
ban | Ban |
The ban object |
Emitted when a moderator adds someone to the queue. This also fires a queueUpdate-event
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The user who got added |
moderator | User |
The Moderator |
Emitted when a moderator bans someone from the room
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
ban | Ban |
The ban |
moderator | User |
Emitted when a moderator moves someone in the queue. This also fires a queueUpdate-event
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
user | User |
The moved user |
moderator | User |
|
newPosition | Number |
|
oldPosition | Number |
Emitted when a moderator skips a song
Kind: event emitted by Client
Properties
Name | Type |
---|---|
moderator | User |
Emitted when the socket server kills the session
Kind: event emitted by Client
Emitted when the client encounters an error which it cannot handle itself
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
error | String | Error |
The error or an error message. |
err | Error |
An error object |
Emitted when the logged in account levels up
Kind: event emitted by Client
Properties
Name | Type |
---|---|
newLevel | Number |
Emitted when plug.dj goes into maintenance mode
Kind: event emitted by Client
Emitted when plug.dj is about to go into maintenance mode
Kind: event emitted by Client
Properties
Name | Type | Description |
---|---|---|
time | Number |
time til maintenance mode in minutes |
Emitted when plug.dj sends a broadcast
Kind: event emitted by Client
Properties
Name | Type |
---|---|
message | String |
Emitted when plig.dj gets updated.
Kind: event emitted by Client
Emitted when someone skips himself
Kind: event emitted by Client
Properties
Name | Type |
---|---|
user | User |
Hold a bunch of something
Kind: global class
Extends: Map
Properties
Name | Type | Description |
---|---|---|
baseObject | Class |
The base class for all items |
limit | Number |
Max number of items to hold |
- Collection ⇐
Map
- new Collection(baseObject, [limit])
- .add(obj, extra, replace) ⇒
Class
- .find(func) ⇒
Class
- .random() ⇒
Class
- .filter(func) ⇒
Array.<Class>
- .map(func) ⇒
Array
- .update(obj, extra, replace) ⇒
Class
- .remove(obj) ⇒
Class
Construct a Collection
Param | Type | Description |
---|---|---|
baseObject | Class |
The base class for all items |
[limit] | Number |
Max number of items to hold |
Add an object
Kind: instance method of Collection
Returns: Class
- The existing or newly created object
Param | Type | Description |
---|---|---|
obj | Object |
The object data |
obj.id | String |
The ID of the object |
extra | Class |
An extra parameter the constructor may need |
replace | Boolean |
Whether to replace an existing object with the same ID |
Return the first object to make the function evaluate true
Kind: instance method of Collection
Returns: Class
- The first matching object, or undefined if no match
Param | Type | Description |
---|---|---|
func | function |
A function that takes an object and returns true if it matches |
Get a random object from the Collection
Kind: instance method of Collection
Returns: Class
- The random object, or undefined if there is no match
Return all the objects that make the function evaluate true
Kind: instance method of Collection
Returns: Array.<Class>
- An array containing all the objects that matched
Param | Type | Description |
---|---|---|
func | function |
A function that takes an object and returns true if it matches |
Return an array with the results of applying the given function to each element
Kind: instance method of Collection
Returns: Array
- An array containing the results
Param | Type | Description |
---|---|---|
func | function |
A function that takes an object and returns something |
Update an object
Kind: instance method of Collection
Returns: Class
- The updated object
Param | Type | Description |
---|---|---|
obj | Object |
The updated object data |
obj.id | String |
The ID of the object |
extra | Class |
An extra parameter the constructor may need |
replace | Boolean |
Whether to replace an existing object with the same ID |
Remove an object
Kind: instance method of Collection
Returns: Class
- The removed object, or null if nothing was removed
Param | Type | Description |
---|---|---|
obj | Object |
The object |
obj.id | String |
The ID of the object |
Represents a ban
Kind: global class
Properties
Name | Type | Description |
---|---|---|
duration | String |
The ban duration ('h' for one hour, 'd' for a day, 'f' for forever) |
Removes this ban.
Kind: instance method of Ban
Represents a rooms booth settings
Kind: global class
Properties
Name | Type | Description |
---|---|---|
isLocked | Boolean |
Whether the queue is lock or unlocked |
shouldCycle | Boolean |
Whether the queue cycles or not |
- Booth
- .unlock() ⇒
Promise
- .lock() ⇒
Promise
- .clear() ⇒
Promise
- .enableCycle() ⇒
Promise
- .disableCycle() ⇒
Promise
- .unlock() ⇒
Unlocks the queue
Kind: instance method of Booth
Locks the queue
Kind: instance method of Booth
Clears and locks the queue
Kind: instance method of Booth
Enables queue cycling
Kind: instance method of Booth
Disables queue cycling
Kind: instance method of Booth
An user with more information
Kind: global class
Properties
Name | Type | Description |
---|---|---|
settings | Object |
An object containing settings |
plugPoints | Number |
The current amount of plug points the user has |
xp | Number |
The current number of experience points the user has |
ignores | Array.<MinimalUser> |
An array of users the current user ignores |
Represents a media object
Kind: global class
Properties
Name | Type | Description |
---|---|---|
id | Number |
The unique id used by plug |
cid | String |
The id used by the source. This is only unique if used together with 'format' |
format | Number |
The format of the media. 1 is YouTube, 2 is SoundCloud |
author | String |
The media author |
title | String |
The media title |
duration | Number |
The media duration |
image | String |
A link to a cover image. |
name | String |
The concatenated name of the media |
uniqueId | String |
An unique id for the media |
Represents a single chat message
Kind: global class
Properties
Name | Type | Description |
---|---|---|
content | String |
The message content. |
user | User |
The user who sent the message. |
time | Date |
The time the message was received. |
mentioned | Boolean |
Indicates if the bot was mentioned |
Deletes this message
Kind: instance method of Message
An user with the minimum of information plug gives
Kind: global class
Properties
Name | Type | Description |
---|---|---|
id | Number |
The id of the user. |
username | String |
The name of the user |
- MinimalUser
- .ban(time, reason) ⇒
Promise
- .unban() ⇒
Promise
- .setRole(role) ⇒
Promise
- .removeRole() ⇒
Promise
- .ban(time, reason) ⇒
Bans the user from the community
Kind: instance method of MinimalUser
Param | Type |
---|---|
time | String |
reason | Number |
Unbans the user from the community
Kind: instance method of MinimalUser
Sets the user as staff
Kind: instance method of MinimalUser
Param | Type | Description |
---|---|---|
role | Number |
the role, 0 for grey, 1 for res dj, 2 for bouncer, 3 for manager, 4 for co-host, 5 for host |
Shorthand for {MinimalUser}.setStaff(0)
Kind: instance method of MinimalUser
Represents a Play
Kind: global class
Properties
Name | Type | Description |
---|---|---|
id | String |
The current history id |
timestamp | String |
The timestamp when the playback started |
media | Media |
The media played |
user | User |
The dj |
Represents the queue of a room
Kind: global class
Properties
Name | Type | Description |
---|---|---|
queue | Array.<User> |
An ordered array of users being in the queue |
- Queue
- .addUser(userID) ⇒
Promise
- .removeUser(userID) ⇒
Promise
- .moveUser(userID, position) ⇒
Promise
- .lock() ⇒
Promise
- .unlock() ⇒
Promise
- .clear() ⇒
Promise
- .addUser(userID) ⇒
Adds an user to the queue
Kind: instance method of Queue
Param | Type | Description |
---|---|---|
userID | Number |
The id of the user to add |
Removes an user from the queue
Kind: instance method of Queue
Param | Type | Description |
---|---|---|
userID | Number |
The id of the user to be removed |
Moves an user in the queue
Kind: instance method of Queue
Param | Type | Description |
---|---|---|
userID | Number |
The user to move |
position | Number |
The new position of the user |
Locks the queue
Kind: instance method of Queue
Unlocks the queue
Kind: instance method of Queue
Clears and locks the queue
Kind: instance method of Queue
Represents a room
Kind: global class
Properties
Name | Type | Description |
---|---|---|
id | Number |
The room id |
slug | String |
The room slug |
name | String |
The room name |
welcomeMessage | String |
The welcome message |
description | String |
The room description |
minChatLevel | Number |
The minimal level required to chat |
Represents a user.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
role | Number |
The role of the user |
globalRole | Number |
The global role of the user (e.g. Brand Ambassador, Admin) |
avatarID | String |
The avatar of the user |
badge | String |
The badge of the user |
subscription | String |
The subscription type of the user |
guest | Boolean |
Whether the user is a guest or not |
joined | Date |
When the user created his/her account |
language | String |
The users language |
blurb | String |
The users profile description |
slug | String |
A flattend and url-friendly version of the username |
level | Number |
The level of the user |
mention | String |
The mention for that user |
- User
- .mute(time, reason) ⇒
Promise
- .move(position) ⇒
Promise
- .add() ⇒
Promise
- .remove() ⇒
Promise
- .mute(time, reason) ⇒
Mutes the user
Kind: instance method of User
Param | Type |
---|---|
time | Number |
reason | String |
Moves the user in the waitlist
Kind: instance method of User
Param | Type |
---|---|
position | Number |
Adds the user to the waitlst
Kind: instance method of User
Removes the user from the waitlist
Kind: instance method of User