Skip to content
Cory Shaw edited this page Dec 3, 2016 · 14 revisions

Methods


connect

Connect to a room using its slug. (the part after https://dubtrack.fm/join/)

bot.connect(slug);

Arguments

slug string The room slug to connect to


disconnect

Disconnect from the currently connected room.

bot.disconnect();


reconnect

Reconnect to the currently connected room.

bot.reconnect();


sendChat

Send a message in the chat.

Note: Message will be split into multiple messages if over 255 chars.

bot.sendChat(message, callback);

Arguments

message string The message to send

callback requestCallback An optional callback to execute after the request (requests if the message is splitted) completes


getChatHistory

Get the last 512 chat message events.

bot.getChatHistory();

Returns
[
    {
        message: 'test',
        time: 1445428545192,
        type: 'chat-message',
        user: {userObject},
        id: '5609c755970e920300a44e88-1445428545192'
    },
    {...}
]

getRoomMeta

Get the room metadata.

bot.getRoomMeta();

Returns

{roomObject}


getQueue

Get the room queue.

bot.getQueue();

Returns
[
    {
        id: '5609c279425d2903003faec4',
        uid: '56003aba621a9e03003165b8',
        media: {mediaObject},
        user: {userObject}
    }
]

getQueuePosition

Get the position of a user in the queue.

bot.getQueuePosition(id);

Arguments

id string The id of the user to get the position of

Returns

number


queueMedia

Add media to the bot's queue.

bot.queueMedia(type, fkid, callback);

Arguments

type string The media type (currently 'soundcloud' or 'youtube')

fkid string The media id

callback requestCallback An optional callback to execute after the request completes


queuePlaylist

Add a playlist to the bot's queue.

bot.queuePlaylist(playlistid, callback);

Arguments

playlistid string The id of the playlist to queue

callback requestCallback An optional callback to execute after the request completes


clearQueue

Clear the bot's queue.

bot.clearQueue(callback);

Arguments

callback requestCallback An optional callback to execute after the request completes


pauseQueue

Pause or unpause the bot's queue.

bot.pauseQueue(pause, callback);

Arguments

pause boolean The value to set

callback requestCallback An optional callback to execute after the request completes


moderateSkip

Skip the currently playing song.

bot.moderateSkip(callback);

Arguments

callback requestCallback An optional callback to execute after the request completes


moderateDeleteChat

Delete a chat message.

bot.moderateDeleteChat(id, callback);

Arguments

id string The id of the message to delete

callback requestCallback An optional callback to execute after the request completes


moderateBanUser

Ban a user from the room.

bot.moderateBanUser(id, time, callback);

Arguments

id string The id of the user to ban

time number An optional duration in minutes (defaults to 0 for forever)

callback requestCallback An optional callback to execute after the request completes


moderateUnbanUser

Unban a user from the room.

bot.moderateUnbanUser(id, callback);

Arguments

id string The id of the user to unban

callback requestCallback An optional callback to execute after the request completes


moderateKickUser

Kick a user from the room.

bot.moderateKickUser(id, msg, callback);

Arguments

id string The id of the user to kick

msg string An optional kick message

callback requestCallback An optional callback to execute after the request completes


moderateMuteUser

Mute a user.

bot.moderateMuteUser(id, callback);

Arguments

id string The id of the user to mute

callback requestCallback An optional callback to execute after the request completes


moderateUnmuteUser

Unmute a user.

bot.moderateUnmuteUser(id, callback);

Arguments

id string The id of the user to unmute

callback requestCallback An optional callback to execute after the request completes


moderateMoveDJ

Move a DJ in the queue

bot.moderateMoveDJ(id, position, callback);

Arguments

id string The id of the user to move

position int Position in the queue for the user to be moved to

callback requestCallback An optional callback to execute after the request completes


moderateRemoveDJ

Remove DJ from the queue.

bot.moderateRemoveDJ(id, callback);

Arguments

id string The id of the user to remove

callback requestCallback An optional callback to execute after the request completes


moderateRemoveSong

Remove a song from the queue.

bot.moderateRemoveSong(id, callback);

Arguments

id string The id of the user that queued the song

callback requestCallback An optional callback to execute after the request completes


moderatePauseDJ

Pause a DJ's queue.

bot.moderatePauseDJ(id, callback);

Arguments

id string The id of the user to pause

callback requestCallback An optional callback to execute after the request completes


moderateSetRole

Set user role.

bot.moderateSetRole(id, role, callback);

Arguments

id string The id of the user

role string The id or type of the role

callback requestCallback An optional callback to execute after the request completes


moderateUnsetRole

Unset user role.

bot.moderateUnsetRole(id, role, callback);

Arguments

id string The id of the user

role string The id or type of the role

callback requestCallback An optional callback to execute after the request completes


moderateLockQueue

Lock or unlock the queue.

bot.moderateLockQueue(locked, callback);

Arguments

locked boolean Queue lock state

callback requestCallback An optional callback to execute after the request completes


updub

Updub the currently playing song.

bot.updub(callback);

Arguments

callback requestCallback An optional callback to execute after the request completes


downdub

Downdub the currently playing song.

bot.downdub(callback);

Arguments

callback requestCallback An optional callback to execute after the request completes


getMedia

Get the currently playing mediaObject.

bot.getMedia();

Returns

{mediaObject} or undefined


getScore

Get the current room score.

bot.getScore();

Returns

{updubs: 5, grabs: 1, downdubs: 0} or undefined


getPlayID

Get the current play ID.

Useful for checking against id in roomPlaylistUpdate to verify the same media is playing in an async database callback.

bot.getPlayID();

Returns

string or undefined


getTimeRemaining

Get the time remaining of the current media in milliseconds.

bot.getTimeRemaining();

Returns

number or undefined


getTimeElapsed

Get the time elapsed of the current media in milliseconds.

bot.getTimeElapsed();

Returns

number or undefined


getUser

Get a user by their ID.

bot.getUser(id);

Arguments

id string The id of the user to get

Returns

{userObject} or undefined


getUserByName

Get a user by their username.

bot.getUserByName(username, ignoreCase);

Arguments

username string The username of the user to get

ignoreCase boolean Ignore case when comparing usernames

Returns

{userObject} or undefined


getSelf

Get the bot.

bot.getSelf();

Returns

{userObject}


getCreator

Get the creator of the room.

bot.getCreator();

Returns

{userObject} or undefined


getDJ

Get the current DJ.

bot.getDJ();

Returns

{userObject} or undefined


getUsers

Get users in the room.

bot.getUsers();

Returns
[
  {userObject},
  {...}
]

getStaff

Get staff in the room.

bot.getStaff();

Returns
[
  {userObject},
  {...}
]

isCreator

Check if the user is the room creator.

bot.isCreator({userObject});

Arguments

object userObject The user to check

Returns

boolean


isOwner

Check if the user is a room owner.

bot.isOwner({userObject});

Arguments

object userObject The user to check

Returns

boolean


isManager

Check if the user is a room manager.

bot.isManager({userObject});

Arguments

object userObject The user to check

Returns

boolean


isMod

Check if the user is a room mod.

bot.isMod({userObject});

Arguments

object userObject The user to check

Returns

boolean


isVIP

Check if the user is a room VIP.

bot.isVIP({userObject});

Arguments

object userObject The user to check

Returns

boolean


isResidentDJ

Check if the user is a room resident DJ.

bot.isResidentDJ({userObject});

Arguments

object userObject The user to check

Returns

boolean


isStaff

Check if the user is member of the room staff.

bot.isStaff({userObject});

Arguments

object userObject The user to check

Returns

boolean


hasPermission

Check if the user has a given permission.

bot.hasPermission({userObject}, permission);

Arguments

object userObject The user to check

permission string The the permission to check for

Returns

boolean