Finished channels

This commit is contained in:
hydrabolt
2015-11-20 20:44:09 +00:00
parent d26702f48f
commit 19fb8e6dfd
10 changed files with 127 additions and 14 deletions

28
docs/docs_pmchannel.rst Normal file
View File

@@ -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.

View File

@@ -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.

28
docs/docs_textchannel.rst Normal file
View File

@@ -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.

View File

@@ -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.
------

View File

@@ -24,6 +24,10 @@ Contents:
:caption: Channel Documentation
docs_channel
docs_pmchannel
docs_serverchannel
docs_textchannel
docs_voicechannel
.. toctree::
:maxdepth: 2

View File

@@ -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

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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));

View File

@@ -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);
}