From 19fb8e6dfd7a1925c7596c080f0b6850b3ef631c Mon Sep 17 00:00:00 2001 From: hydrabolt Date: Fri, 20 Nov 2015 20:44:09 +0000 Subject: [PATCH] Finished channels --- docs/docs_pmchannel.rst | 28 +++++++++++++++++++ docs/docs_serverchannel.rst | 49 ++++++++++++++++++++++++++++++++++ docs/docs_textchannel.rst | 28 +++++++++++++++++++ docs/docs_voicechannel.rst.txt | 10 +++++++ docs/index.rst | 4 +++ docs/vars.rst | 2 ++ lib/Structures/PMChannel.js | 10 +++---- lib/Structures/TextChannel.js | 2 -- src/Structures/PMChannel.js | 6 ++--- src/Structures/TextChannel.js | 2 -- 10 files changed, 127 insertions(+), 14 deletions(-) create mode 100644 docs/docs_pmchannel.rst create mode 100644 docs/docs_serverchannel.rst create mode 100644 docs/docs_textchannel.rst create mode 100644 docs/docs_voicechannel.rst.txt diff --git a/docs/docs_pmchannel.rst b/docs/docs_pmchannel.rst new file mode 100644 index 000000000..e858434b9 --- /dev/null +++ b/docs/docs_pmchannel.rst @@ -0,0 +1,28 @@ +.. include:: ./vars.rst + +PMChannel +========= + +**extends** Channel_ + +A PMChannel is a Private/Direct channel between the Client and another user. + +------ + +Attributes +---------- + +messages +~~~~~~~~ + +A Cache_ of Message_ objects. + +recipient +~~~~~~~~~ + +The User_ that is the recipient of the Channel. + +lastMessage +~~~~~~~~~~~ + +The last Message_ sent in the channel, may be null if no messages have been sent during the time the bound Client_ has been online. \ No newline at end of file diff --git a/docs/docs_serverchannel.rst b/docs/docs_serverchannel.rst new file mode 100644 index 000000000..74d95b4d1 --- /dev/null +++ b/docs/docs_serverchannel.rst @@ -0,0 +1,49 @@ +.. include:: ./vars.rst + +ServerChannel +============= + +A ServerChannel is a Channel_ that belongs to a Server_. + +Attributes +---------- + +name +~~~~ + +`String`, name of the channel. + +type +~~~~ + +`String`, either ``voice`` or ``text``. + +position +~~~~~~~~ + +`Number`, position in the channel list. + +permissionOverwrites +~~~~~~~~~~~~~~~~~~~~ + +Cache_ of all the PermissionOverwrite_ objects affecting the channel. + +server +~~~~~~ + +Server_ the channel belongs to. + +Functions +--------- + +permissionsOf(user) +~~~~~~~~~~~~~~~~~~~ + +**Aliases:** permsOf + +Returns a ChannelPermissions_ object of a user's permissions in that channel. + +mention() +~~~~~~~~~ + +Returns a `string` that can be used in discord messages to mention a channel. ``serverChannel.toString()` defaults to this. \ No newline at end of file diff --git a/docs/docs_textchannel.rst b/docs/docs_textchannel.rst new file mode 100644 index 000000000..4b3e0f864 --- /dev/null +++ b/docs/docs_textchannel.rst @@ -0,0 +1,28 @@ +.. include:: ./vars.rst + +TextChannel +=========== + +**extends** ServerChannel_ + +A text channel of a server. + +------ + +Attributes +---------- + +topic +~~~~~ + +The topic of the channel, a `String`. + +lastMessage +~~~~~~~~~~~ + +Last Message_ sent in the channel. May be null if no messages sent whilst the Client was online. + +messages +~~~~~~~~ + +A Cache_ of Message_ objects. \ No newline at end of file diff --git a/docs/docs_voicechannel.rst.txt b/docs/docs_voicechannel.rst.txt new file mode 100644 index 000000000..86d0177fb --- /dev/null +++ b/docs/docs_voicechannel.rst.txt @@ -0,0 +1,10 @@ +.. include:: ./vars.rst + +VoiceChannel +============ + +**extends** ServerChannel_ + +A voice channel of a server. Currently, the voice channel class has no differences to the ServerChannel class. + +------ \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 03c1218fb..ca1b2c0cf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -24,6 +24,10 @@ Contents: :caption: Channel Documentation docs_channel + docs_pmchannel + docs_serverchannel + docs_textchannel + docs_voicechannel .. toctree:: :maxdepth: 2 diff --git a/docs/vars.rst b/docs/vars.rst index a32e3d844..d611640de 100644 --- a/docs/vars.rst +++ b/docs/vars.rst @@ -3,5 +3,7 @@ .. _User : ./docs_user.html .. _Server : ./docs_server.html .. _Channel : ./docs_channel.html +.. _ServerChannel : ./docs_serverchannel.html +.. _TextChannel : ./docs_textchannel.html .. _Promises : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise .. _EventEmitter : https://nodejs.org/api/events.html#events_class_events_eventemitter \ No newline at end of file diff --git a/lib/Structures/PMChannel.js b/lib/Structures/PMChannel.js index 837c4a378..3f0404241 100644 --- a/lib/Structures/PMChannel.js +++ b/lib/Structures/PMChannel.js @@ -12,17 +12,15 @@ var Equality = require("../Util/Equality.js"); var Cache = require("../Util/Cache.js"); var reg = require("../Util/ArgumentRegulariser.js").reg; -var PMChannel = (function (_Equality) { - _inherits(PMChannel, _Equality); +var PMChannel = (function (_Channel) { + _inherits(PMChannel, _Channel); function PMChannel(data, client) { _classCallCheck(this, PMChannel); - _Equality.call(this); - this.client = client; + _Channel.call(this, data, client); this.type = data.type || "text"; - this.id = data.id; this.lastMessageId = data.last_message_id; this.messages = new Cache("id", 1000); this.recipient = this.client.internal.users.add(new User(data.recipient, this.client)); @@ -50,6 +48,6 @@ var PMChannel = (function (_Equality) { }]); return PMChannel; -})(Equality); +})(Channel); module.exports = PMChannel; \ No newline at end of file diff --git a/lib/Structures/TextChannel.js b/lib/Structures/TextChannel.js index 6e7a8a664..181d20354 100644 --- a/lib/Structures/TextChannel.js +++ b/lib/Structures/TextChannel.js @@ -18,9 +18,7 @@ var TextChannel = (function (_ServerChannel) { _ServerChannel.call(this, data, client, server); - this.name = data.name; this.topic = data.topic; - this.position = data.position; this.lastMessageID = data.last_message_id; this.messages = new Cache("id", client.options.maximumMessages); } diff --git a/src/Structures/PMChannel.js b/src/Structures/PMChannel.js index cb29eb17f..47ee496a6 100644 --- a/src/Structures/PMChannel.js +++ b/src/Structures/PMChannel.js @@ -6,13 +6,11 @@ var Equality = require("../Util/Equality.js"); var Cache = require("../Util/Cache.js"); var reg = require("../Util/ArgumentRegulariser.js").reg; -class PMChannel extends Equality{ +class PMChannel extends Channel{ constructor(data, client){ - super(); - this.client = client; + super(data, client); this.type = data.type || "text"; - this.id = data.id; this.lastMessageId = data.last_message_id; this.messages = new Cache("id", 1000); this.recipient = this.client.internal.users.add(new User(data.recipient, this.client)); diff --git a/src/Structures/TextChannel.js b/src/Structures/TextChannel.js index f9554dd5f..d968748c6 100644 --- a/src/Structures/TextChannel.js +++ b/src/Structures/TextChannel.js @@ -8,9 +8,7 @@ class TextChannel extends ServerChannel{ constructor(data, client, server){ super(data, client, server); - this.name = data.name; this.topic = data.topic; - this.position = data.position; this.lastMessageID = data.last_message_id; this.messages = new Cache("id", client.options.maximumMessages); }