Added channelUpdate listener

This commit is contained in:
hydrabolt
2015-09-27 17:54:03 +01:00
parent 16d2410450
commit c32f600a6a
3 changed files with 41 additions and 1 deletions

View File

@@ -1105,6 +1105,23 @@ var Client = (function () {
break;
case "CHANNEL_UPDATE":
var channelInCache = self.getChannel("id", data.id),
serverInCache = self.getServer("id", data.guild_id);
if (channelInCache && serverInCache) {
var newChann = new Channel(data, serverInCache);
newChann.messages = channelInCache.messages;
self.trigger("channelUpdate", channelInCache, newChann);
self.channelCache[self.channelCache.indexOf(channelInCache)] = newChann;
}
break;
default:
self.debug("received unknown packet");
self.trigger("unknown", dat);

View File

@@ -1009,6 +1009,23 @@ class Client {
}
break;
case "CHANNEL_UPDATE":
var channelInCache = self.getChannel("id", data.id),
serverInCache = self.getServer("id", data.guild_id);
if(channelInCache && serverInCache){
var newChann = new Channel(data, serverInCache);
newChann.messages = channelInCache.messages;
self.trigger("channelUpdate", channelInCache, newChann);
self.channelCache[ self.channelCache.indexOf(channelInCache) ] = newChann;
}
break;
default:
self.debug("received unknown packet");

View File

@@ -32,7 +32,7 @@ mybot.on("ready", function () {
console.log("im ready");
for(var chann of mybot.channels){
mybot.setTopic(chann, "HELLO I AM A BOT BOOP BOOP");
mybot.setTopic(chann, "THINGS");
}
});
@@ -44,6 +44,12 @@ mybot.on("unknown", function(info){
console.log("warning!", info);
})
mybot.on("channelUpdate", function(oldChan, newChan){
console.log(oldChan.topic + " vs " + newChan.topic);
});
function dump(msg) {
console.log(msg);
}