Skip to content

Commit

Permalink
Bugfixes, a lot of new functions + readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
explodingcamera committed May 16, 2016
1 parent 5419e1e commit 489532e
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 30 deletions.
239 changes: 211 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ Returned Object:

--------------------------------------------------------------------------------

## getUser:
## getUser: (Also for getting playlists)

Example:

```javascript
var user = bot.getUser(uid);
var currentUser = bot.getUser();
```

Returned Object:
Expand All @@ -173,6 +174,22 @@ Returned Object:
role: 'owner',
un: 'Username',
uid: 'uid'
// If you get the current User, you also get
activepl: 10,
created: 1462378487408,
playlists: {
3: {
id: 3,
name: "playlist1",
content: {
[
0: {
SongObject
},
]
}
}
}
}
```

Expand Down Expand Up @@ -292,8 +309,8 @@ bot.ban(uid);
Usage:

```javascript
bot.log(logLevel, "Text");
bot.log("silly", "LOL: " + JSON.stringify({
bot.logger.log(logLevel, "Text");
bot.logger.log("silly", "LOL: " + JSON.stringify({
error: {
foo: "bar",
}
Expand All @@ -302,46 +319,212 @@ bot.log("silly", "LOL: " + JSON.stringify({

--------------------------------------------------------------------------------

## getConversations()

Usage:

```javascript
bot.getConversations().then((data) => {
/* Data:
conversations: {
1: {
messages: {
0: {
from: 1,
message: 'Hi',
time: "2016-05-15T20:48:35.081Z",
unread: false,
}
}
}
}
*/
})
```

--------------------------------------------------------------------------------

## getHistory()

Usage:

```javascript
bot.history().then((data) => {
/* Data:
[
{
//Song Object
}
]
*/
})
```

--------------------------------------------------------------------------------

## setLimit()

Usage:

```javascript
bot.setLimit(limit).then(() => {
})
```

There are also:

--------------------------------------------------------------------------------

## broadcast()

Usage:

```javascript
.setLimit(limit);
.broadcast(msg);
.removeDj(uid);
.swap(uid1, uid2);
.move(uid, position);
.vote(voteType);
.getPadBySlug(slug);
bot.broadcast(msg).then(() => {
})
```

--------------------------------------------------------------------------------

## removeDj()

// Don't change these, create new Objects:
.queue // Array of users in Queue
.media // If you can, use the data from advance events instead!
.currentdj
.roles
.roleOrder
.historylimit
.description
.user //also includes Playlists
Usage:

```javascript
bot.removeDj(uid).then(() => {
})
```

## Available Events:
--------------------------------------------------------------------------------

## swap()

Usage:

```javascript
bot.swap(uid1, uid2).then(() => {
})
```

--------------------------------------------------------------------------------

## swap()

Usage:

```javascript
bot.move(uid, position).then(() => {
})
```

--------------------------------------------------------------------------------

## vote()

Usage:

```javascript
bot.vote(type).then(() => {
//Types: like, dislike, grab
})
```

--------------------------------------------------------------------------------

## getPadBySlug()

Usage:

```javascript
bot.getPadBySlug(slug).then(() => {
// You get socketPort
// socketDomain
// useSSL
})
```

--------------------------------------------------------------------------------

## getDJ()

Usage:

```javascript
dj = bot.getDJ();
```

--------------------------------------------------------------------------------

## getMedia()

Usage:

```javascript
media = bot.getMedia();
```

--------------------------------------------------------------------------------

## getRoles()

Usage:

```javascript
roles = bot.getRoles();
```

--------------------------------------------------------------------------------

## getRoleOrder()

Usage:

```javascript
roleorder = bot.getRoleOrder();
```

--------------------------------------------------------------------------------

## getHistoryLimit()

Usage:

```javascript
historylimit = bot.getHistoryLimit();
```

--------------------------------------------------------------------------------

## getPadDiscription()

Usage:

```javascript
description = bot.getPadDiscription();
```

# Available Events:

- rawSocket
- reconnected
- error // Gets passed the error object
- closed
- chat
- chat ```

```
{
{
time: 'a timestamp',
msg: "HEEY",
uid: 12,
cid: 420,
user: { Same as getUser() },
time: 'a timestamp',
msg: "HEEY",
uid: 12,
cid: 420,
user: { Same as getUser() },
}
```

}
```
All of these events get passed the same like the client api:
Expand Down
29 changes: 28 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var app = function (args) {
token: null,
room: args.room || null,
logging: {
logFile: args.logging.logFile || null,
logFile: typeof args.logging.logFile !== 'undefined' ? args.logging.logFile : null,
logLevel: typeof args.logging.logLevel !== 'undefined' ? args.logging.logLevel : 'info',
} || null,
};
Expand Down Expand Up @@ -249,6 +249,33 @@ app.prototype.once = function (type, value) {
return events.once(type, value);
};

app.prototype.getQueue = app.prototype.getDJs = function () {
return this.queue;
}
app.prototype.getDJ = function () {
return this.currentdj;
}

app.prototype.getMedia = function () {
return this.media;
}

app.prototype.getRoles = function () {
return this.roles;
}

app.prototype.getRoleOrder = function () {
return this.roleOrder;
}

app.prototype.getHistoryLimit = function () {
return this.historylimit;
}

app.prototype.getPadDiscription = function () {
return this.description;
}

app.prototype.handleResponse = function (e) {
var _this = this;

Expand Down
28 changes: 27 additions & 1 deletion src/cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
});
});
},

joinQueue: function () {
var _this = this;
this.sendJSON({
Expand Down Expand Up @@ -392,4 +392,30 @@ module.exports = {
});
});
},
getConversations: function (uid) {
var _ this = this;
this.sendJSON({
type: 'getPrivateConversation',
data: {
uid: uid
}
});
return new Promise(function (resolve, reject) {
_this.once('getPrivateConversationReceived', function (data) {
resolve(data);
});
});
},
getHistory: function () {
var _ this = this;
this.sendJSON({
type: 'getHistory',
data: {},
});
return new Promise(function (resolve, reject) {
_this.once('getHistoryReceived', function (data) {
resolve(data);
});
});
}
};

0 comments on commit 489532e

Please sign in to comment.