diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 245a17a09..8dc22316f 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -1,10 +1,14 @@ 'use strict'; class Channel { - constructor(client, data) { + constructor(client, data, guild) { this.client = client; this.typingMap = {}; this.typingTimeouts = []; + if (guild) { + this.guild = guild; + } + if (data) { this.setup(data); } diff --git a/src/structures/PermissionOverwrites.js b/src/structures/PermissionOverwrites.js new file mode 100644 index 000000000..717c94d46 --- /dev/null +++ b/src/structures/PermissionOverwrites.js @@ -0,0 +1,19 @@ +'use strict'; + +class PermissionOverwrites { + constructor(serverChannel, data) { + this.channel = serverChannel; + if (data) { + this.setup(data); + } + } + + setup(data) { + this.type = data.type; + this.id = data.id; + this.denyData = data.deny; + this.allowData = data.allow; + } +} + +module.exports = PermissionOverwrites; diff --git a/src/structures/ServerChannel.js b/src/structures/ServerChannel.js index 58053250a..9be3bd58a 100644 --- a/src/structures/ServerChannel.js +++ b/src/structures/ServerChannel.js @@ -1,11 +1,11 @@ 'use strict'; const Channel = require('./Channel'); +const PermissionOverwrites = require('./PermissionOverwrites'); class ServerChannel extends Channel{ constructor(guild, data) { - super(guild.client, data); - this.guild = guild; + super(guild.client, data, guild); } setup(data) { @@ -13,9 +13,15 @@ class ServerChannel extends Channel{ this.type = data.type; this.topic = data.topic; this.position = data.position; - this.permissionOverwrites = data.permission_overwrites; this.name = data.name; this.lastMessageID = data.last_message_id; + + if (data.permission_overwrites) { + this.permissionOverwrites = []; + for (let overwrite of data.permission_overwrites) { + this.permissionOverwrites.push(new PermissionOverwrites(this, overwrite)); + } + } } toString() { diff --git a/test/random.js b/test/random.js index d47034116..22a216aa4 100644 --- a/test/random.js +++ b/test/random.js @@ -57,12 +57,12 @@ client.on('voiceStateUpdate', (oldMember, newMember) => { console.log('voiceState', oldMember.user.username, oldMember.voiceChannel + '', newMember.voiceChannel + ''); }); -client.on('typingStart', (channel, user) => { +client.on('typingStart.', (channel, user) => { if (user.username === 'hydrabolt') console.log(user.username, 'started typing in', channel.name); }); -client.on('typingStop', (channel, user, data) => { +client.on('typingStop.', (channel, user, data) => { if (user.username === 'hydrabolt') console.log(user.username, 'stopped typing in', channel.name, 'after', data.elapsedTime + 'ms'); });