diff --git a/src/inc/trigger/useless_nxy.js b/src/inc/trigger/useless_nxy.js index 966f6e2..28bf831 100644 --- a/src/inc/trigger/useless_nxy.js +++ b/src/inc/trigger/useless_nxy.js @@ -20,32 +20,22 @@ module.exports = bot => { bot._trigger.set("kiss", new bot.trigger({ call: /^(\.|\/)kiss/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`(づ。◕‿‿◕。)づ" [color=red]。。・゜゜・。。・゜❤[/color] [b]${args.join(" ").trim()}[/b] [color=red]❤[/color]`); + e.reply(`(づ。◕‿‿◕。)づ" [color=red]。。・゜゜・。。・゜❤[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]❤[/color]`); } })); bot._trigger.set("hug", new bot.trigger({ call: /^(\.|\/)hug/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`[color=red]♡❤♡♥[/color] [b]${args.join(" ").trim()}[/b] [color=red]♥♡❤♡♥[/color]`); + e.reply(`[color=red]♡❤♡♥[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]♥♡❤♡♥[/color]`); } })); bot._trigger.set("kill", new bot.trigger({ call: /^(\.|\/)kill/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(data.kill_templates[~~(Math.random() * data.kill_templates.length)] - .replace("{user}", `[b]${args[0]}[/b]`) + .replace("{user}", `[b]${e.args[0] || e.user.nick}[/b]`) .replace("{limbs}", data.kill_parts.limbs[~~(Math.random() * data.kill_parts.limbs.length)]) .replace("{gun}", data.kill_parts.gun[~~(Math.random() * data.kill_parts.gun.length)]) .replace("{weapon_stab}", data.kill_parts.weapon_stab[~~(Math.random() * data.kill_parts.weapon_stab.length)]) @@ -62,12 +52,8 @@ module.exports = bot => { bot._trigger.set("yiff", new bot.trigger({ call: /^(\.|\/)yiff/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(data.yiff[~~(Math.random() * data.yiff.length)] - .split("{user}").join(`[b]${args[0]}[/b]`) + .split("{user}").join(`[b]${e.args[0] || e.user.nick}[/b]`) .split("{yiffer}").join(`[b]${e.user.nick}[/b]`) .split("{nick}").join(`[b]${e.self.me.nickname}[/b]`) .split("{channel}").join(`${e.channel}`) @@ -78,50 +64,36 @@ module.exports = bot => { bot._trigger.set("bier", new bot.trigger({ call: /^(\.|\/)bier/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`schenkt ein kühles Blondes an [b]${args[0]}[/b] aus.`); + e.replyAction(`schenkt ein kühles Blondes an [b]${e.args[0] || e.user.nick}[/b] aus.`); } })); bot._trigger.set("fucken", new bot.trigger({ call: /^(\.|\/)fucken/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`fuckt [b]${args[0]}[/b] und tötet [b]${args[0]}[/b] anschließend.`); + const user = e.args[0] || e.user.nick; + e.replyAction(`fuckt [b]${user}[/b] und tötet [b]${user}[/b] anschließend.`); } })); bot._trigger.set("hack", new bot.trigger({ call: /^(\.|\/)hack/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`hacking ${args[0]}...`); + e.reply(`hacking ${e.args[0] || e.user.nick}...`); } })); bot._trigger.set("spit", new bot.trigger({ call: /^(\.|\/)spit/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`spits on [b]${args[0]}[/b] like a dirty whore.`); + e.replyAction(`spits on [b]${e.args[0] || e.user.nick}[/b] like a dirty whore.`); } })); bot._trigger.set("assume", new bot.trigger({ call: /^(\.|\/)assume/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`Assuming [b]${args[0]}'s[/b] gender... it's a ${data.genders[~~(Math.random() * data.genders.length)]}.`); + e.reply(`Assuming [b]${e.args[0] || e.user.nick}'s[/b] gender... it's a ${data.genders[~~(Math.random() * data.genders.length)]}.`); } })); @@ -178,11 +150,8 @@ module.exports = bot => { bot._trigger.set("slap", new bot.trigger({ call: /^(\.|\/)slap/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; e.replyAction(data.slap[~~(Math.random() * data.slap.length)] - .replace("{user}", `[b]${args[0]}[/b]`) + .replace("{user}", `[b]${e.args[0] || e.user.nick}[/b]`) ); } })); diff --git a/src/inc/trigger/useless_uwe.js b/src/inc/trigger/useless_uwe.js index 1f87bf6..d917608 100644 --- a/src/inc/trigger/useless_uwe.js +++ b/src/inc/trigger/useless_uwe.js @@ -13,39 +13,31 @@ const data = { }; Object.keys(data).forEach(cur => { - sql.exec(`select \`data\` from \`useless\` where \`trigger\` = '${cur}' limit 1`, (err, row) => { - data[cur] = JSON.parse(row[0].data); - }); + sql.exec("select `data` from `useless` where `trigger` = ? limit 1", [cur]) + .then(rows => { + data[cur] = JSON.parse(rows[0].data); + }); }); module.exports = bot => { bot._trigger.set("abschieben", new bot.trigger({ call: /^(\.|\/)abschieben/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`schiebt [b]${args[0]}[/b] ${data.abschieben[~~(Math.random() * data.abschieben.length)]} ab.`); + e.replyAction(`schiebt [b]${e.args[0] || e.user.nick}[/b] ${data.abschieben[~~(Math.random() * data.abschieben.length)]} ab.`); } })); bot._trigger.set("butterkaese", new bot.trigger({ call: /^(\.|\/)butterkäse/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${args[0]}[/b] ein.`); + e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${e.args[0] || e.user.nick}[/b] ein.`); } })); bot._trigger.set("notschlachten", new bot.trigger({ call: /^(\.|\/)notschlachten/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`notschlachtet [b]${args[0]}[/b] und entsorgt die Leiche im Biomüll`); + e.replyAction(`notschlachtet [b]${e.args[0] || e.user.nick}[/b] und entsorgt die Leiche im Biomüll`); } })); @@ -59,11 +51,8 @@ module.exports = bot => { bot._trigger.set("kaffee", new bot.trigger({ call: /^(\.|\/)kaffee/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; e.replyAction(data.kaffee[~~(Math.random() * data.kaffee.length)] - .replace("{user}", `[b]${args[0]}[/b]`) + .replace("{user}", `[b]${e.args[0] || e.user.nick}[/b]`) ); } })); @@ -71,11 +60,8 @@ module.exports = bot => { bot._trigger.set("tee", new bot.trigger({ call: /^(\.|\/)tee/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; e.replyAction(data.tee[~~(Math.random() * data.tee.length)] - .replace("{user}", `[b]${args[0]}[/b]`) + .replace("{user}", `[b]${e.args[0] || e.user.nick}[/b]`) ); } })); @@ -83,48 +69,35 @@ module.exports = bot => { bot._trigger.set("uwe_quotes", new bot.trigger({ call: /^(\.|\/)(boll|firecooler|kinski|stoll)$/i, f: e => { - let args = e.message.trim().substring(1); - e.reply(data[`quotes_${args}`][~~(Math.random() * data[`quotes_${args}`].length)]); + e.reply(data[`quotes_${e.cmd}`][~~(Math.random() * data[`quotes_${e.cmd}`].length)]); } })); bot._trigger.set("wusel", new bot.trigger({ call: /^(\.|\/)wusel/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`wuselt [b]${args[0]}[/b] über den Haufen.`); + e.replyAction(`wuselt [b]${e.args[0] || e.user.nick}[/b] über den Haufen.`); } })); bot._trigger.set("mett", new bot.trigger({ call: /^(\.|\/)mett/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`Jamba Mettscanner: [b]${args[0]}[/b] ist zu ${~~(Math.random() * 100 + 1)}% Mett.`); + e.reply(`Jamba Mettscanner: [b]${e.args[0] || e.user.nick}[/b] ist zu ${~~(Math.random() * 100 + 1)}% Mett.`); } })); bot._trigger.set("rotenburg", new bot.trigger({ call: /^(\.|\/)rotenburg/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`verarbeitet [b]${args[0]}[/b] zu Hackfleisch.`); + e.replyAction(`verarbeitet [b]${e.args[0] || e.user.nick}[/b] zu Hackfleisch.`); } })); bot._trigger.set("pee", new bot.trigger({ call: /^(\.|\/)pee/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`pisst in [b]${args[0]}[/b]s Gesicht.`); + e.replyAction(`pisst in [b]${e.args[0] || e.user.nick}[/b]s Gesicht.`); } })); @@ -145,20 +118,14 @@ module.exports = bot => { bot._trigger.set("haram", new bot.trigger({ call: /^(\.|\/)haram/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`[b]${args[0]}[/b] ist ${(~~(Math.random() * 2) ? "haram" : "nicht haram")}.`); + e.reply(`[b]${e.args[0] || e.user.nick}[/b] ist ${(~~(Math.random() * 2) ? "haram" : "nicht haram")}.`); } })); bot._trigger.set("sacklutscher", new bot.trigger({ call: /^(\.|\/)lutschsack/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`[b]${e.user.nick}[/b] legt Rosen aus und lutscht den Sack von [b]${args[0]}[/b]`); + e.reply(`[b]${e.user.nick}[/b] legt Rosen aus und lutscht den Sack von [b]${e.args[0] || e.user.nick}[/b]`); } })); @@ -186,20 +153,14 @@ module.exports = bot => { bot._trigger.set("wasser", new bot.trigger({ call: /^(\.|\/)wasser/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`kippt [b]${args[0]}[/b] einen Eimer Wasser über den Kopf.`); + e.replyAction(`kippt [b]${e.args[0] || e.user.nick}[/b] einen Eimer Wasser über den Kopf.`); } })); bot._trigger.set("normie", new bot.trigger({ call: /^(\.|\/)normie/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.reply(`Jamba Normiescanner: [b]${args[0]}[/b] ist zu ${~~(Math.random() * 100 + 1)}% ein Normie.`); + e.reply(`Jamba Normiescanner: [b]${e.args[0] || e.user.nick}[/b] ist zu ${~~(Math.random() * 100 + 1)}% ein Normie.`); } })); @@ -220,60 +181,42 @@ module.exports = bot => { bot._trigger.set("meditieren", new bot.trigger({ call: /^(\.|\/)meditieren/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`meditiert zusammen mit [b]${args[0]}[/b] Metta.`); + e.replyAction(`meditiert zusammen mit [b]${e.args[0] || e.user.nick}[/b] Metta.`); } })); bot._trigger.set("duden", new bot.trigger({ call: /^(\.|\/)duden/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`drischt mit einem großen Duden auf [b]${args[0]}[/b] ein.`); + e.replyAction(`drischt mit einem großen Duden auf [b]${e.args[0] || e.user.nick}[/b] ein.`); } })); bot._trigger.set("kscht", new bot.trigger({ call: /^(\.|\/)kscht/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`jagt [b]${args[0]}[/b] durch den Raum.`); + e.replyAction(`jagt [b]${e.args[0] || e.user.nick}[/b] durch den Raum.`); } })); bot._trigger.set("bullenpisse", new bot.trigger({ call: /^(\.|\/)bullenpisse/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`zapft ein Fläschchen feinsten Bullenurin, verarbeitet diesen zu Red-Bull und serviert ihn [b]${args[0]}[/b] in Form einer Pfanddose.`); + e.replyAction(`zapft ein Fläschchen feinsten Bullenurin, verarbeitet diesen zu Red-Bull und serviert ihn [b]${e.args[0] || e.user.nick}[/b] in Form einer Pfanddose.`); } })); bot._trigger.set("lungenkrebs", new bot.trigger({ call: /^(\.|\/)lungenkrebs/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`dreht [b]${args[0]}[/b] einen prall gefüllten Sargnagel mit feinstem Schwarzer Krauser.`); + e.replyAction(`dreht [b]${e.args[0] || e.user.nick}[/b] einen prall gefüllten Sargnagel mit feinstem Schwarzer Krauser.`); } })); bot._trigger.set("irpg", new bot.trigger({ call: /^(\.|\/)irpg/i, f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - + const user = e.args[0] || e.user.nick; rp("http://idlerpg.rizon.net/players.php").then(top => { let prank = 0 , i = 1; @@ -281,7 +224,7 @@ module.exports = bot => { let playerlist = dom.window.document.querySelectorAll("ol > li"); let player = null; for(let p of playerlist) { - if (p.innerHTML.includes(`player=${args[0]}">`)) { + if (p.innerHTML.includes(`player=${user}">`)) { prank = i; player = p; break; @@ -290,10 +233,10 @@ module.exports = bot => { } if(player !== null) { const [, plevel, pclass, puntil] = player.innerHTML.match(/.*, the level (.*?) (.*?)\. Next level in (.*?)\./); - e.reply(`([i]${prank} / ${playerlist.length}[/i]) [b]${args[0]}[/b], the [b]${pclass}[/b]: level: ${plevel}, next level in ${puntil}.`); + e.reply(`([i]${prank} / ${playerlist.length}[/i]) [b]${user}[/b], the [b]${pclass}[/b]: level: ${plevel}, next level in ${puntil}.`); } else - e.reply(`player [b]${args[0]}[/b] was not found`); + e.reply(`player [b]${user}[/b] was not found`); }); }