Created ChannelPermissions class

This commit is contained in:
hydrabolt
2015-10-03 20:36:32 +01:00
parent 6d36977f94
commit 6b091128cb
4 changed files with 98 additions and 45 deletions

View File

@@ -0,0 +1,7 @@
class ChannelPermissions{
constructor(data){
}
}
module.exports = ChannelPermissions;

View File

@@ -1,3 +1,5 @@
var ChannelPermissions = require("./ChannelPermissions.js");
class Channel {
constructor(data, server) {
@@ -8,14 +10,21 @@ class Channel {
this.id = data.id;
this.messages = [];
this.roles = [];
for (var role of data.permission_overwrites) {
this.roles.push( new ChannelPermissions() );
}
//this.isPrivate = isPrivate; //not sure about the implementation of this...
}
get permissionOverwrites(){
get permissionOverwrites() {
return this.roles;
}
get permissions(){
get permissions() {
return this.roles;
}
@@ -26,42 +35,42 @@ class Channel {
equals(object) {
return (object && object.id === this.id);
}
addMessage(data){
if(this.messages.length > 1000){
this.messages.splice(0,1);
}
if(!this.getMessage("id", data.id)){
this.messages.push(data);
}
return this.getMessage("id", data.id);
}
getMessage(key, value){
for(var message of this.messages){
if(message[key] === value){
return message;
}
}
return null;
}
toString(){
addMessage(data) {
if (this.messages.length > 1000) {
this.messages.splice(0, 1);
}
if (!this.getMessage("id", data.id)) {
this.messages.push(data);
}
return this.getMessage("id", data.id);
}
getMessage(key, value) {
for (var message of this.messages) {
if (message[key] === value) {
return message;
}
}
return null;
}
toString() {
return "<#" + this.id + ">";
}
get isPrivate(){
get isPrivate() {
return false;
}
get users(){
get users() {
return this.server.members;
}
get members(){
get members() {
return this.server.members;
}
}