diff --git a/lib/Structures/Channel.js b/lib/Structures/Channel.js index 5d4fdbafd..e46a28fb7 100644 --- a/lib/Structures/Channel.js +++ b/lib/Structures/Channel.js @@ -7,6 +7,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" var Equality = require("../Util/Equality.js"); var Cache = require("../Util/Cache.js"); var PermissionOverwrite = require("./PermissionOverwrite.js"); +var reg = require("../Util/ArgumentRegulariser.js").reg; var Channel = (function (_Equality) { _inherits(Channel, _Equality); @@ -20,7 +21,15 @@ var Channel = (function (_Equality) { } Channel.prototype["delete"] = function _delete() { - return this.client.deleteChannel.apply(this, arguments); + return this.client.deleteChannel.apply(this.client, reg(this, arguments)); + }; + + Channel.prototype.sendMessage = function sendMessage() { + return this.client.sendMessage.apply(this.client, reg(this, arguments)); + }; + + Channel.prototype.sendTTSMessage = function sendTTSMessage() { + return this.client.sendTTSMessage.apply(this.client, reg(this, arguments)); }; return Channel; diff --git a/lib/Structures/ServerChannel.js b/lib/Structures/ServerChannel.js index 215c31232..7a47cab0b 100644 --- a/lib/Structures/ServerChannel.js +++ b/lib/Structures/ServerChannel.js @@ -101,6 +101,10 @@ var ServerChannel = (function (_Channel) { return this.name; }; + ServerChannel.prototype.setName = function setName() { + return this.client.setChannelName.apply(this.client, reg(this, arguments)); + }; + return ServerChannel; })(Channel); diff --git a/lib/Structures/TextChannel.js b/lib/Structures/TextChannel.js index 897a1b04c..f94554f50 100644 --- a/lib/Structures/TextChannel.js +++ b/lib/Structures/TextChannel.js @@ -8,6 +8,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" var ServerChannel = require("./ServerChannel.js"); var Cache = require("../Util/Cache.js"); +var reg = require("../Util/ArgumentRegulariser.js").reg; var TextChannel = (function (_ServerChannel) { _inherits(TextChannel, _ServerChannel); @@ -26,6 +27,18 @@ var TextChannel = (function (_ServerChannel) { /* warning! may return null */ + TextChannel.prototype.setTopic = function setTopic() { + return this.client.setTopic.apply(this.client, reg(this, arguments)); + }; + + TextChannel.prototype.setNameAndTopic = function setNameAndTopic() { + return this.client.setChannelNameAndTopic.apply(this.client, reg(this, arguments)); + }; + + TextChannel.prototype.update = function update() { + return this.client.updateChannel.apply(this.client, reg(this, arguments)); + }; + _createClass(TextChannel, [{ key: "lastMessage", get: function get() { diff --git a/lib/Util/ArgumentRegulariser.js b/lib/Util/ArgumentRegulariser.js new file mode 100644 index 000000000..9c98ddb39 --- /dev/null +++ b/lib/Util/ArgumentRegulariser.js @@ -0,0 +1,5 @@ +"use strict"; + +exports.reg = function (c, a) { + return [c].concat(Array.prototype.slice.call(a)); +}; \ No newline at end of file diff --git a/src/Structures/Channel.js b/src/Structures/Channel.js index 604c6004d..43897388e 100644 --- a/src/Structures/Channel.js +++ b/src/Structures/Channel.js @@ -3,6 +3,7 @@ var Equality = require("../Util/Equality.js"); var Cache = require("../Util/Cache.js"); var PermissionOverwrite = require("./PermissionOverwrite.js"); +var reg = require("../Util/ArgumentRegulariser.js").reg; class Channel extends Equality{ @@ -13,7 +14,15 @@ class Channel extends Equality{ } delete(){ - return this.client.deleteChannel.apply(this, arguments); + return this.client.deleteChannel.apply(this.client, reg(this, arguments)); + } + + sendMessage(){ + return this.client.sendMessage.apply(this.client, reg(this, arguments)); + } + + sendTTSMessage(){ + return this.client.sendTTSMessage.apply(this.client, reg(this, arguments)); } } diff --git a/src/Structures/ServerChannel.js b/src/Structures/ServerChannel.js index d82bfed87..e5d152f56 100644 --- a/src/Structures/ServerChannel.js +++ b/src/Structures/ServerChannel.js @@ -62,6 +62,10 @@ class ServerChannel extends Channel{ toString(){ return this.name; } + + setName(){ + return this.client.setChannelName.apply(this.client, reg(this, arguments)); + } } module.exports = ServerChannel; \ No newline at end of file diff --git a/src/Structures/TextChannel.js b/src/Structures/TextChannel.js index 1966f0119..6270a44c1 100644 --- a/src/Structures/TextChannel.js +++ b/src/Structures/TextChannel.js @@ -2,6 +2,7 @@ var ServerChannel = require("./ServerChannel.js"); var Cache = require("../Util/Cache.js"); +var reg = require("../Util/ArgumentRegulariser.js").reg; class TextChannel extends ServerChannel{ constructor(data, client, server){ @@ -18,6 +19,18 @@ class TextChannel extends ServerChannel{ get lastMessage(){ return this.messages.get("id", this.lastMessageID); } + + setTopic(){ + return this.client.setTopic.apply(this.client, reg(this, arguments)); + } + + setNameAndTopic(){ + return this.client.setChannelNameAndTopic.apply(this.client, reg(this, arguments)); + } + + update(){ + return this.client.updateChannel.apply(this.client, reg(this, arguments)); + } } module.exports = TextChannel; \ No newline at end of file diff --git a/src/Util/ArgumentRegulariser.js b/src/Util/ArgumentRegulariser.js new file mode 100644 index 000000000..81e683582 --- /dev/null +++ b/src/Util/ArgumentRegulariser.js @@ -0,0 +1,3 @@ +exports.reg = function (c, a) { + return [c].concat(Array.prototype.slice.call(a)); +}; \ No newline at end of file diff --git a/test/bot.1.js b/test/bot.1.js index 31194ceb1..0453a29ac 100644 --- a/test/bot.1.js +++ b/test/bot.1.js @@ -6,6 +6,9 @@ client.on("warn", (m) => console.log("[warn]", m)); var start = Date.now(); client.on("message", m => { + if(m.content === "death"){ + m.channel.delete(); + } if (m.content === "&init") { for (var channel of m.channel.server.channels) { if (channel instanceof Discord.VoiceChannel) {