setChannelPosition

This commit is contained in:
abalabahaha
2015-12-05 10:15:46 -08:00
parent a89938ed01
commit ccc794229e
3 changed files with 27 additions and 0 deletions

View File

@@ -366,6 +366,12 @@ export default class Client extends EventEmitter {
.then(callback, errCB(callback));
}
//def setChannelPosition
setChannelPosition(channel, position, callback = (/*err*/) => {}) {
return this.internal.setChannelPosition(channel, position)
.then(callback, errCB(callback));
}
//def updateChannel
updateChannel(channel, data, callback = (/*err*/) => {}) {
return this.internal.updateChannel(channel, data)

View File

@@ -877,6 +877,23 @@ export default class InternalClient {
);
}
//def setTopic
setChannelPosition(chann, position = 0) {
return this.resolver.resolveChannel(chann)
.then(channel =>
request
.patch(Endpoints.CHANNEL(channel.id))
.set("authorization", this.token)
.send({
name: channel.name,
position: position,
topic: channel.topic
})
.end()
.then(res => channel.position = res.body.position)
);
}
//def updateChannel
updateChannel(chann, data) {
return this.setChannelNameAndTopic(chann, data.name, data.topic);

View File

@@ -72,4 +72,8 @@ export default class ServerChannel extends Channel{
setName(){
return this.client.setChannelName.apply(this.client, reg(this, arguments));
}
setPosition(){
return this.client.setChannelPosition.apply(this.client, reg(this, arguments));
}
}