Rantanen / node-mumble

Mumble client in Node.js
MIT License
155 stars 48 forks source link

[QUESTION] How do I rename a channel? #75

Closed theLine closed 8 years ago

theLine commented 8 years ago

I'd like to rename a channel. Basically I'm doing this:

var channel = connection.channelById(22);
channel.update({
    name: 'new Channel Name',
    linksAdd: null,
    linksRemove: null,
    parent: null,
});

But for some reason the channel won't update its name.

P.S.: I nulled the other properties because I got the following error:

TypeError: Cannot call method '_addChild' of undefined
    at EventEmitter.Channel._checkParent (path/to/node-mumble/lib/Channel.js:2
    at EventEmitter.Channel.update (path/to/node-mumble/lib/Channel.js:120:14)
Rantanen commented 8 years ago

update() is an internal function. It should really have been called _update(), but you can deduce that also from the fact that it hasn't been documented.

That function updates the local Channel instance based on data coming from the server - it won't alter the server state.

There is no convenience method for renaming the channel, but I believe following would work.

client.connection.sendMessage( 'ChannelState', {
  channel_id: channel.id,
  name: 'new name'
});
theLine commented 8 years ago

Thanks for your quick response!

This worked as you said. =)