Changing the clients username will trigger a userupdate

This commit is contained in:
hydrabolt
2015-08-20 19:33:32 +01:00
parent be787e0951
commit 68db1f6ac0
4 changed files with 31 additions and 3 deletions

View File

@@ -251,7 +251,7 @@ Commands[ "avatar" ] = {
}
Commands["setusername"] = {
oplevel : 2,
oplevel : 3,
fn : function( bot, params, message ){
var name = getKey( params, "name", "Boris Johnson" );

View File

@@ -38,6 +38,23 @@ hydrabot.on( "ready", function() {
console.timeEnd("hydrabotbenchmark");
} );
hydrabot.on("userupdate", function(ol, ne){
var serversInvolved = hydrabot.getServers().deepFilter(["members", "id"], ol.id);
console.log(serversInvolved);
for(server of serversInvolved.contents){
console.log("gra", server);
hydrabot.sendMessage(server.getDefaultChannel(), "Just sayin', "+ol.username+" changed their name to "+ne.username+". I know. Disgraceful.", function(err){
console.log(err);
}, {
selfDestruct: 5000
});
}
});
// When the bot gets disconnected, exit.
hydrabot.on( "disconnected", function( obj ) {
// Say we couldn't connect and then exit