diff --git a/src/trigger/level.js b/src/trigger/level.js index 31f2ea7..06eb01b 100644 --- a/src/trigger/level.js +++ b/src/trigger/level.js @@ -14,27 +14,31 @@ module.exports = (bot, lib) => { if( name in e.channel.names ) { bot.whois(name.trim(), e.network, (err, data) => { - var host = data.username+'@'+data.hostname; - if(host in lib.admins) { - if(level <= 0) { - lib.sql.query('delete from `f0ck`.`user` where `id` = ? limit 1', [lib.admins[host].id], () => { - lib.loadUser(); - e.reply('deleted user '+data.nick+' ('+host+')'); - }); + if(data.account !== null) { + var host = data.username+'@'+data.hostname; + if(host in lib.admins) { + if(level <= 0) { + lib.sql.query('delete from `f0ck`.`user` where `id` = ? limit 1', [lib.admins[host].id], () => { + lib.loadUser(); + e.reply('deleted user '+data.nick+' ('+host+')'); + }); + } + else { + lib.sql.query('update `f0ck`.`user` set `level` = ? where `id` = ?', [level, lib.admins[host].id], () => { + lib.loadUser(); + e.reply('changed user '+data.nick+' ('+host+') to level '+level); + }); + } } else { - lib.sql.query('update `f0ck`.`user` set `level` = ? where `id` = ?', [level, lib.admins[host].id], () => { + lib.sql.query('insert into `f0ck`.`user` (`nick`,`vhost`,`level`,`server`) values (?,?,?,?)', [data.nick, host, level, e.network], () => { lib.loadUser(); - e.reply('changed user '+data.nick+' ('+host+') to level '+level); + e.reply('added new user '+data.nick+' ('+host+') with level '+level); }); } } - else { - lib.sql.query('insert into `f0ck`.`user` (`nick`,`vhost`,`level`,`server`) values (?,?,?,?)', [data.nick, host, level, e.network], () => { - lib.loadUser(); - e.reply('added new user '+data.nick+' ('+host+') with level '+level); - }); - } + else + e.reply('user '+data.nick+' isn\'t registered'); }); } else