Added role shortcuts and to user also

This commit is contained in:
Amish Shah
2015-12-05 16:57:58 +00:00
parent f95822dcb7
commit 5a971ba097
28 changed files with 132 additions and 25 deletions

View File

@@ -5,6 +5,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
var _Constants = require("../Constants"); var _Constants = require("../Constants");
var _UtilArgumentRegulariser = require("../Util/ArgumentRegulariser");
/* /*
example data example data
@@ -135,6 +137,34 @@ var Role = (function () {
return "#" + val; return "#" + val;
}; };
Role.prototype["delete"] = function _delete() {
return this.client.deleteRole.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Role.prototype.edit = function edit() {
return this.client.updateRole.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Role.prototype.update = function update() {
return this.client.updateRole.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
Role.prototype.addMember = function addMember(member, callback) {
return this.client.addMemberToRole.apply(this.client, [member, this, callback]);
};
Role.prototype.addUser = function addUser(member, callback) {
return this.client.addMemberToRole.apply(this.client, [member, this, callback]);
};
Role.prototype.removeMember = function removeMember(member, callback) {
return this.client.removeMemberFromRole.apply(this.client, [member, this, callback]);
};
Role.prototype.removeUser = function removeUser(member, callback) {
return this.client.removeMemberFromRole.apply(this.client, [member, this, callback]);
};
return Role; return Role;
})(); })();

View File

@@ -16,6 +16,8 @@ var _UtilEquality2 = _interopRequireDefault(_UtilEquality);
var _Constants = require("../Constants"); var _Constants = require("../Constants");
var _UtilArgumentRegulariser = require("../Util/ArgumentRegulariser");
var User = (function (_Equality) { var User = (function (_Equality) {
_inherits(User, _Equality); _inherits(User, _Equality);
@@ -52,6 +54,22 @@ var User = (function (_Equality) {
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false; if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false;
}; };
User.prototype.sendMessage = function sendMessage() {
return this.client.sendMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
User.prototype.send = function send() {
return this.client.sendMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
User.prototype.sendTTSMessage = function sendTTSMessage() {
return this.client.sendTTSMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
User.prototype.sendTTS = function sendTTS() {
return this.client.sendTTSMessage.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
};
_createClass(User, [{ _createClass(User, [{
key: "avatarURL", key: "avatarURL",
get: function get() { get: function get() {

View File

@@ -12,6 +12,8 @@ var _ServerChannel2 = require("./ServerChannel");
var _ServerChannel3 = _interopRequireDefault(_ServerChannel2); var _ServerChannel3 = _interopRequireDefault(_ServerChannel2);
var _UtilArgumentRegulariser = require("../Util/ArgumentRegulariser");
var VoiceChannel = (function (_ServerChannel) { var VoiceChannel = (function (_ServerChannel) {
_inherits(VoiceChannel, _ServerChannel); _inherits(VoiceChannel, _ServerChannel);
@@ -21,6 +23,12 @@ var VoiceChannel = (function (_ServerChannel) {
_ServerChannel.call(this, data, client, server); _ServerChannel.call(this, data, client, server);
} }
VoiceChannel.prototype.join = function join() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function () {} : arguments[0];
return this.client.joinVoiceChannel.apply(this.client, [this, callback]);
};
return VoiceChannel; return VoiceChannel;
})(_ServerChannel3["default"]); })(_ServerChannel3["default"]);

View File

@@ -1,5 +1,6 @@
"use strict"; "use strict";
import {Permissions} from "../Constants"; import {Permissions} from "../Constants";
import {reg} from "../Util/ArgumentRegulariser";
/* /*
example data example data
@@ -130,4 +131,32 @@ export default class Role {
} }
return "#"+val; return "#"+val;
} }
delete() {
return this.client.deleteRole.apply(this.client, reg(this, arguments));
}
edit() {
return this.client.updateRole.apply(this.client, reg(this, arguments));
}
update() {
return this.client.updateRole.apply(this.client, reg(this, arguments));
}
addMember(member, callback) {
return this.client.addMemberToRole.apply(this.client, [member, this, callback]);
}
addUser(member, callback) {
return this.client.addMemberToRole.apply(this.client, [member, this, callback]);
}
removeMember(member, callback) {
return this.client.removeMemberFromRole.apply(this.client, [member, this, callback]);
}
removeUser(member, callback) {
return this.client.removeMemberFromRole.apply(this.client, [member, this, callback]);
}
} }

View File

@@ -2,6 +2,7 @@
import Equality from "../Util/Equality"; import Equality from "../Util/Equality";
import {Endpoints} from "../Constants"; import {Endpoints} from "../Constants";
import {reg} from "../Util/ArgumentRegulariser";
export default class User extends Equality{ export default class User extends Equality{
constructor(data, client){ constructor(data, client){
@@ -60,4 +61,20 @@ export default class User extends Equality{
else else
return false; return false;
} }
sendMessage(){
return this.client.sendMessage.apply(this.client, reg(this, arguments));
}
send() {
return this.client.sendMessage.apply(this.client, reg(this, arguments));
}
sendTTSMessage(){
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
}
sendTTS() {
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
}
} }

View File

@@ -1,9 +1,14 @@
"use strict"; "use strict";
import ServerChannel from "./ServerChannel"; import ServerChannel from "./ServerChannel";
import {reg} from "../Util/ArgumentRegulariser";
export default class VoiceChannel extends ServerChannel{ export default class VoiceChannel extends ServerChannel{
constructor(data, client, server){ constructor(data, client, server){
super(data, client, server); super(data, client, server);
} }
join(callback = function () { }) {
return this.client.joinVoiceChannel.apply(this.client, [this, callback]);
}
} }