apply permission overwrites from parent channel
This commit is contained in:
parent
0c3c1b5582
commit
73562b3570
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
ChannelType,
|
ChannelType,
|
||||||
Events,
|
Events,
|
||||||
PermissionFlagsBits,
|
|
||||||
GuildMember,
|
GuildMember,
|
||||||
GuildChannelManager,
|
GuildChannelManager,
|
||||||
GuildChannel,
|
GuildChannel,
|
||||||
@ -9,22 +8,6 @@ import {
|
|||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
import { VoiceChannel } from '../../database.js';
|
import { VoiceChannel } from '../../database.js';
|
||||||
|
|
||||||
const vcPermissionOverwrites = [
|
|
||||||
PermissionFlagsBits.ReadMessageHistory,
|
|
||||||
PermissionFlagsBits.PrioritySpeaker,
|
|
||||||
PermissionFlagsBits.ManageMessages,
|
|
||||||
PermissionFlagsBits.ManageChannels,
|
|
||||||
PermissionFlagsBits.DeafenMembers,
|
|
||||||
PermissionFlagsBits.SendMessages,
|
|
||||||
PermissionFlagsBits.ViewChannel,
|
|
||||||
PermissionFlagsBits.MuteMembers,
|
|
||||||
PermissionFlagsBits.MoveMembers,
|
|
||||||
PermissionFlagsBits.Connect,
|
|
||||||
PermissionFlagsBits.Stream,
|
|
||||||
PermissionFlagsBits.UseVAD,
|
|
||||||
PermissionFlagsBits.Speak
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that either creates a new custom channel or gets an existing one registered in the database.
|
* Function that either creates a new custom channel or gets an existing one registered in the database.
|
||||||
* @param {GuildMember} member The member that caused this event.
|
* @param {GuildMember} member The member that caused this event.
|
||||||
@ -46,16 +29,13 @@ const getChannel = async (member, guildChs, channel) => {
|
|||||||
// Create private channel with all permissions
|
// Create private channel with all permissions
|
||||||
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
|
||||||
|
const vcPermOver = channel.parent.permissionOverwrites.cache.get(member.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: [
|
permissionOverwrites: [vcPermOver]
|
||||||
{
|
|
||||||
id: member.id,
|
|
||||||
allow: vcPermissionOverwrites
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Save newly created channel
|
// Save newly created channel
|
||||||
|
Loading…
Reference in New Issue
Block a user