mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
add PermissionOverwrites class in preparation for permission evaluation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
19
src/structures/PermissionOverwrites.js
Normal file
19
src/structures/PermissionOverwrites.js
Normal file
@@ -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;
|
||||
@@ -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() {
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user