generated from Baipyrus/DiscordJS-Template
get specific permissions from parent element
This commit is contained in:
parent
84f754dd5b
commit
e0c581dcfd
@ -4,7 +4,8 @@ import {
|
|||||||
GuildMember,
|
GuildMember,
|
||||||
GuildChannelManager,
|
GuildChannelManager,
|
||||||
GuildChannel,
|
GuildChannel,
|
||||||
VoiceState
|
VoiceState,
|
||||||
|
PermissionOverwrites
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { VoiceChannel } from '../../database.js';
|
import { VoiceChannel } from '../../database.js';
|
||||||
|
|
||||||
@ -28,12 +29,19 @@ const getChannel = async (member, guildChs, channel) => {
|
|||||||
const name = member.user.username;
|
const name = member.user.username;
|
||||||
const chName = `${name}${name.toLowerCase().endsWith('s') ? "'" : "'s"} channel`;
|
const chName = `${name}${name.toLowerCase().endsWith('s') ? "'" : "'s"} channel`;
|
||||||
// Get permissions from parent
|
// Get permissions from parent
|
||||||
const vcPermOver = channel.parent.permissionOverwrites.cache.get(member.id);
|
/** @type {PermissionOverwrites} */
|
||||||
|
const { allow, deny } = channel.parent.permissionOverwrites.cache.get(member.client.user.id);
|
||||||
const privCh = await guildChs.create({
|
const privCh = await guildChs.create({
|
||||||
name: chName,
|
name: chName,
|
||||||
parent: channel.parent,
|
parent: channel.parent,
|
||||||
type: ChannelType.GuildVoice,
|
type: ChannelType.GuildVoice,
|
||||||
permissionOverwrites: [vcPermOver]
|
permissionOverwrites: [
|
||||||
|
{
|
||||||
|
id: member.id,
|
||||||
|
allow,
|
||||||
|
deny
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save newly created channel
|
// Save newly created channel
|
||||||
|
Loading…
Reference in New Issue
Block a user