diff --git a/README.md b/README.md index bd21ac6..c6dab4d 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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); ``` -------------------------------------------------------------------------------- diff --git a/src/cmds.js b/src/cmds.js index 1723a77..acb0a5d 100644 --- a/src/cmds.js +++ b/src/cmds.js @@ -290,7 +290,7 @@ module.exports = { }); }); }, - + /* Removed in 0.7.0 ban: function (uid, duration, reason) { var _this = this; this.sendJSON({ @@ -328,7 +328,7 @@ module.exports = { }); }); }, - + */ whois: function (uid, un) { var _this = this; this.sendJSON({ @@ -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); + }); + }); + }, };