Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require("discord.js");
- const colors = require("colors");
- let db = require("quick.db")
- module.exports = {
- name:"voiceStateUpdate",
- async execute(oldVoice , newVoice , client) {
- let user = newVoice.guild.member(oldVoice.guild.members.cache.find(userID => userID.id === newVoice.id));
- let channel = await db.fetch(`PrivateCahnnel_[${newVoice.guild.id}]`)
- if(channel === null) return console.log("1".red)
- let category = await db.fetch(`PrivateCategory_[${newVoice.guild.id}]`)
- if(category === null) return console.log("2".red)
- if(!oldVoice.channel && newVoice.channel.id === channel){
- if(newVoice.guild.channels.cache.find(Channel => Channel.name === user.user.username)) return user.send(`**You have already a private channel**`)
- newVoice.guild.channels.create(user.user.username,{
- type:"voice",
- parent:category,
- reason:`Private Channel By: ${user.user.username}`,
- permissionOverwrites:[
- {
- id : newVoice.guild.id,
- deny : ["CONNECT"]
- },
- {
- id : user.id,
- allow : ['CONNECT', 'MANAGE_CHANNELS', 'SPEAK', 'STREAM', 'MUTE_MEMBERS', 'MOVE_MEMBERS', 'VIEW_CHANNEL', 'DEAFEN_MEMBERS']
- }
- ]
- }).then(userChannel => {
- user.voice.setChannel(userChannel.id)
- user.send(`**Sucessflly create a private channel ${userChannel}**`)
- })
- let channelC = newVoice.guild.channels.cache.find(Channel => Channel.id === channel);
- channelC.updateOverwrite(user.id ,
- {
- CONNECT:false,
- VIEW_CHANNEL:true
- }
- )
- } else if(!newVoice.channel){
- if(oldVoice.channel && oldVoice.guild.channels.cache.find(Channel => Channel.name === user.user.username)){
- oldVoice.channel.delete();
- let channelC = newVoice.guild.channels.cache.find(Channel => Channel.id === channel);
- channelC.updateOverwrite(user.id ,
- {
- CONNECT:true,
- VIEW_CHANNEL:true
- }
- )
- user.send(`**Sucessflly delete the private channel**`)
- }
- }
- }
- }
- /*
- Code by Me , 9 9 9 </>#9044
- Me Codes Link : https://discord.gg/td3NFBBkGC or https://discord.gg/mecodes
- */
- /*
- Other Link :
- Setup Channel : https://pastebin.com/T4x5uZk8
- Setup Category : https://pastebin.com/JVg29hvZ
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement