mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
add PermissionOverwrites class in preparation for permission evaluation
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
class Channel {
|
class Channel {
|
||||||
constructor(client, data) {
|
constructor(client, data, guild) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.typingMap = {};
|
this.typingMap = {};
|
||||||
this.typingTimeouts = [];
|
this.typingTimeouts = [];
|
||||||
|
if (guild) {
|
||||||
|
this.guild = guild;
|
||||||
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
this.setup(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';
|
'use strict';
|
||||||
|
|
||||||
const Channel = require('./Channel');
|
const Channel = require('./Channel');
|
||||||
|
const PermissionOverwrites = require('./PermissionOverwrites');
|
||||||
|
|
||||||
class ServerChannel extends Channel{
|
class ServerChannel extends Channel{
|
||||||
constructor(guild, data) {
|
constructor(guild, data) {
|
||||||
super(guild.client, data);
|
super(guild.client, data, guild);
|
||||||
this.guild = guild;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(data) {
|
setup(data) {
|
||||||
@@ -13,9 +13,15 @@ class ServerChannel extends Channel{
|
|||||||
this.type = data.type;
|
this.type = data.type;
|
||||||
this.topic = data.topic;
|
this.topic = data.topic;
|
||||||
this.position = data.position;
|
this.position = data.position;
|
||||||
this.permissionOverwrites = data.permission_overwrites;
|
|
||||||
this.name = data.name;
|
this.name = data.name;
|
||||||
this.lastMessageID = data.last_message_id;
|
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() {
|
toString() {
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ client.on('voiceStateUpdate', (oldMember, newMember) => {
|
|||||||
console.log('voiceState', oldMember.user.username, oldMember.voiceChannel + '', newMember.voiceChannel + '');
|
console.log('voiceState', oldMember.user.username, oldMember.voiceChannel + '', newMember.voiceChannel + '');
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('typingStart', (channel, user) => {
|
client.on('typingStart.', (channel, user) => {
|
||||||
if (user.username === 'hydrabolt')
|
if (user.username === 'hydrabolt')
|
||||||
console.log(user.username, 'started typing in', channel.name);
|
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')
|
if (user.username === 'hydrabolt')
|
||||||
console.log(user.username, 'stopped typing in', channel.name, 'after', data.elapsedTime + 'ms');
|
console.log(user.username, 'stopped typing in', channel.name, 'after', data.elapsedTime + 'ms');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user