0

How do I get the id of the voice channel I just created (if possible by name) and put it in a variable? Ex:

var channelvoice = ('Name '+count); // name + var
client.channels.get(fun).clone(`${channelvoice}`, true, true, 'Needed a clone') // fun is a name of a channel.
            .then(clone => clone.setParent('629745940953678742'))
            .then(clone => clone.setPosition(1))
            .catch(console.error);
var idvoicechannel = client.channels.get(`${channelvoice}`).id; // <--
JohnisonF
  • 47
  • 3
  • 8
  • 1
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – slothiful Oct 11 '19 at 22:23
  • @slothiful Could you sum it all up to what I want? :p – JohnisonF Oct 12 '19 at 03:31
  • 1
    My answer [here](https://stackoverflow.com/a/56726990/11321804) may be more understandable and relevant. The only major difference is that you're using a different method so you'll get a different value returned from the initial promise. The real problem in your code is the scope of the cloned channel variable if you continue to use `then()` methods. – slothiful Oct 12 '19 at 13:36

0 Answers0