mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
More things
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
5
lib/Util/ArgumentRegulariser.js
Normal file
5
lib/Util/ArgumentRegulariser.js
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
exports.reg = function (c, a) {
|
||||
return [c].concat(Array.prototype.slice.call(a));
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
3
src/Util/ArgumentRegulariser.js
Normal file
3
src/Util/ArgumentRegulariser.js
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.reg = function (c, a) {
|
||||
return [c].concat(Array.prototype.slice.call(a));
|
||||
};
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user