// Make the channel function makeChannel(message, player1, player2) { // Get the two users based on their ID. var user = message.guild.members.cache.get(player1); var user2 = message.guild.members.cache.get(player2); // If the games array is not equal to 0, add to it. if (games != 0) { games.push(games.length++); } else { // Otherwise, game[0] is equal to [0]. games.push(0); } // Create the channels, disallowing everyone to view the channel, read the message history, and send messages. message.guild.channels.create("game-" + games.length, { permissionOverwrites: [ { id: message.guild.roles.everyone, //To make it be seen by a certain role, user an ID instead deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] //Deny permissions }, { // But allow the two users to view the channel, send messages, and read the message history. id: user.id, allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] }, { id: user2.id, allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] } ], }); // Create the Game x VC message.guild.channels.create("Game " + games.length, { type: 'GUILD_VOICE', permissionOverwrites: [ { id: message.guild.roles.everyone, //To make it be seen by a certain role, user an ID instead deny: ['VIEW_CHANNEL', 'CONNECT', 'SPEAK'] //Deny permissions }, { id: user.id, allow: ['VIEW_CHANNEL', 'CONNECT', 'SPEAK'] }, { id: user2.id, allow: ['VIEW_CHANNEL', 'CONNECT', 'SPEAK'] } ], }); // Move the users to that VC. setTimeout(function() { user.voice.setChannel("Game "+ games.length); user2.voice.setChannel("Game "+ games.length); }, 1000); }