import sql from "../sql"; export default bot => { bot._trigger.set("rape", new bot.trigger({ call: /^(\.|\/)rape/i, help: { text: "Rapes a nick and eventually charge for it", usage: "[b].rape[/b] [i]()[/i]" }, f: e => { const nick = e.args[0] || e.user.nick; const rand = Math.round(Math.random()); if(rand !== 1) e.replyAction(`rapes [b]${nick}[/b].`) else { const fine = ~~(Math.random() * 500) + 1; const fined = [e.user.nick, nick][rand]; const reason = ["raping", "being too lewd and getting raped"][rand]; sql.any("insert into nxy_users (nick, fines) values (lower($1), $2) on conflict (nick) do update set fines = nxy_users.fines + excluded.fines returning fines", [fined, fine]) .then(rows => { e.replyAction(`fines [b]${nick}[/b] [b]$${fine}[/b] for ${reason}. You owe: [b]$${rows[0].fines}[/b].`); }) .catch(err => { console.log(err); }); } } })); bot._trigger.set("owe", new bot.trigger({ call: /^(\.|\/)owe/i, help: { text: "Shows how much a nick owes", usage: "[b].owe[/b] [i]()[/i]" }, f: e => { const nick = e.args[0] || e.user.nick; sql.any("select fines from nxy_users where lower(nick) = lower($1) limit 1", [nick]) .then(rows => { if(!rows[0]) return e.reply("user not found"); let fines = 0; if(rows[0].fines > 0) fines = rows[0].fines; e.reply(`[b]${nick}[/b] owes: [b]$${fines}[/b].`); }) .catch(err => { return e.reply("user not found"); }); } })); };