Skip to content

Commit

Permalink
Added new 0.7.0 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
explodingcamera committed Jun 27, 2016
1 parent c2189b6 commit d6cf4e8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ npm install mqp-api -S

**Version 0.3.x changes how you connect to a pad, the old way still works for compatibility though!**

**Version 0.7.x changed bans to restrictions, check the docs below!**

Tip: Change your bot permissions in serverconfig.js to have the same as a co-owner if you want to avoid permissions errors. If you don't know the `() =>` syntax, google arrow functions!

The first thing you'll need to do is to create a new Bot. You can get these values by typing `config` into the DevTools console on your Pad (if the serverhost is empty, use your domain).
Expand Down Expand Up @@ -293,13 +295,14 @@ bot.whois(uid, un)

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

## unban() / ban():
## restrictUser(), getUserRestrictions()

Usage:

```javascript
bot.ban(uid, duration, reason);
bot.ban(uid);
restrictUser(uid, duration, reason, type);
getUserRestrictions(uid).then((data) => console.log(data));
unrestrictUser(uid, type);
```

--------------------------------------------------------------------------------
Expand Down
59 changes: 56 additions & 3 deletions src/cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ module.exports = {
});
});
},

/* Removed in 0.7.0
ban: function (uid, duration, reason) {
var _this = this;
this.sendJSON({
Expand Down Expand Up @@ -328,7 +328,7 @@ module.exports = {
});
});
},

*/
whois: function (uid, un) {
var _this = this;
this.sendJSON({
Expand Down Expand Up @@ -417,5 +417,58 @@ module.exports = {
resolve(data);
});
});
}
},

restrictUser: function (uid, duration, reason, type) {
var _this = this;
this.sendJSON({
type: 'restrictUser',
data: {
uid: uid,
duration: duration,
reason: reason,
type: type,
},
});
return new Promise(function (resolve, reject) {
_this.once('restrictUserReceived', function (data) {
if (data.error)
reject('restrictUser error: ' + data.error);
resolve(data);
});
});
},
getUserRestrictions: function (uid) {
var _this = this;
this.sendJSON({
type: 'getUserRestrictions',
data: {
uid: uid,
},
});
return new Promise(function (resolve, reject) {
_this.once('rgetUserRestrictionsReceived', function (data) {
if (data.error)
reject('getUserRestrictions error: ' + data.error);
resolve(data);
});
});
},
unrestrictUser: function (uid, type) {
var _this = this;
this.sendJSON({
type: 'unrestrictUser',
data: {
uid: uid,
type: type,
},
});
return new Promise(function (resolve, reject) {
_this.once('unrestrictUserReceived', function (data) {
if (data.error)
reject('unrestrictUser error: ' + data.error);
resolve(data);
});
});
},
};

0 comments on commit d6cf4e8

Please sign in to comment.