diff options
-rw-r--r-- | discord.js | 138 | ||||
-rw-r--r-- | handler.js | 6 | ||||
-rw-r--r-- | index.js | 5 | ||||
-rw-r--r-- | matrix.js | 10 |
4 files changed, 148 insertions, 11 deletions
@@ -7,6 +7,16 @@ function startDiscord() { console.log(`Logged in as ${client.user.tag}!`); }); + function send(channel, text) { + channel.send({ + embeds: [ + { + description: text + } + ] + }) + } + client.on('messageCreate', (msg) => { if (!msg.guild || msg.author.bot) return; @@ -27,17 +37,139 @@ function startDiscord() { source: "discord", message: msg, channel: msg.channel, - client + client, + discordSend: send }); } catch (e) { - msg.channel.send("β Hmm, something isn't quite right! I was trying to process your message and something wrong happened. I think you need to report this so it can be fixed!\n\n```plaintext\n" + e.stack + "\n```"); + send(msg.channel, "β Hmm, something isn't quite right! I was trying to process your message and something wrong happened. I think you need to report this so it can be fixed!\n\n```plaintext\n" + e.stack + "\n```"); } } else if (message.includes("<@" + client.user.id + ">")) { - msg.channel.send("π Hello! I think you forgot my prefix is `.`, use `.help` to get help."); + send(msg.channel, "π Hello! I think you forgot my prefix is `.`, use `.help` to get help."); } else { if (!lastMessages[msg.channel.id]) lastMessages[msg.channel.id] = []; lastMessages[msg.channel.id].unshift(message); lastMessages[msg.channel.id] = lastMessages[msg.channel.id].splice(0, 5); + + let text = msg.content.toLowerCase().trim(); + + if (message.author.id === "186730180872634368" || message.author.id === "189069518016872448" || message.author.id === "493845599469174794") { + let worth = 1 / (score['score'] / 100); + if (worth < 0.1) worth = 0.1; + + if (score['score'] === 0) { + score['score'] = 0.01; + } + + if (text.includes("....")) { + score['score'] -= text.replace(/[^.]/gm, "").length * worth; + } + + if (text.replace(/[^.]/gm, "").length === text.length) { + score['score'] -= text.replace(/[^.]/gm, "").length * 5 * worth; + } + + if (text.includes(".c.")) { + score['score'] += 5 * worth; + } + + if (text.includes("neigh")) { + score['score'] += 5 * worth; + } + + if (text.includes("-c-")) { + score['score'] += 5 * worth; + } + + if (text.includes("bye")) { + score['score'] -= 50 * worth; + } + + if (text.endsWith(".")) { + score['score'] -= 10 * worth; + } + + if (text.match(/^\*(.*)\*$/gm)) { + score['score'] += 2 * worth; + } + + if (text.includes("β€")) { + score['score'] += text.replace(/[^β€]/gm, "").length * 3 * worth; + } + + if (text.includes("hehe")) { + score['score'] += 2 * worth; + } + + if (text.includes("pff")) { + score['score'] += 2 * worth; + } + + if (text.includes("mhm!")) { + score['score'] += 1 * worth; + } + + if (text.includes("cutie")) { + score['score'] += 5 * worth; + } + + if (text.includes("silly")) { + score['score'] += 5 * worth; + } + + if (text.includes("sweetie")) { + score['score'] += 2 * worth; + } + + if (text.includes("sis")) { + score['score'] += 2 * worth; + } + + if (text.includes("nini")) { + score['score'] += 2 * worth; + } + + if (text.includes("good night")) { + score['score'] += 2 * worth; + } + + if (text.includes("hehehehe")) { + score['score'] += 4 * worth; + } + + if (text.includes("hehehe")) { + score['score'] += 3 * worth; + } + + if (text.includes("woo!")) { + score['score'] += 3 * worth; + } + + if (text.includes("yay!")) { + score['score'] += 3 * worth; + } + + if (text.includes("/s")) { + score['score'] += 3 * worth; + } + + if (text.includes("love you")) { + score['score'] += 5 * worth; + } + + if (text.includes("love u")) { + score['score'] += 5 * worth; + } + + if (text.includes("^c^")) { + score['score'] += 3 * worth; + } + + if (Math.floor(score['percentage']) < Math.floor(score['score'] / 12.5)) { + send(msg.channel, "π Congrats! Your love score is now at " + Math.floor(score['score'] / 12.5) + "%, keep it up!"); + } + + score['percentage'] = score['score'] / 12.5; + } } }); @@ -75,7 +75,7 @@ module.exports = (config) => { if (config['source'] === "matrix") { matrixSend(config['room'].roomId, "π« Sorry, you do not have any knowledge credits left, run `.usage` for more details."); } else if (config['source'] === "discord") { - config['channel'].send("π« Sorry, you do not have any knowledge credits left for now, run `.usage` for more details."); + config['discordSend'](config['channel'], "π« Sorry, you do not have any knowledge credits left for now, run `.usage` for more details."); } return; } else { @@ -95,7 +95,7 @@ module.exports = (config) => { if (config['source'] === "matrix") { matrixSend(config['room'].roomId, "π« Sorry, you do not have any knowledge credits left, run `.usage` for more details."); } else if (config['source'] === "discord") { - config['channel'].send("π« Sorry, you do not have any knowledge credits left for now, run `.usage` for more details."); + config['discordSend'](config['channel'], "π« Sorry, you do not have any knowledge credits left for now, run `.usage` for more details."); } return; } else { @@ -110,7 +110,7 @@ module.exports = (config) => { if (config['source'] === "matrix") { matrixSend(config['room'].roomId, "π« `." + command + "` is not a valid command."); } else if (config['source'] === "discord") { - config['channel'].send("π« `." + command + "` is not a valid command."); + config['discordSend'](config['channel'], "π« `." + command + "` is not a valid command."); } } }
\ No newline at end of file @@ -14,6 +14,10 @@ try { global.aliases = {}; +process.on('uncaughtException', (e) => { + console.error(e); +}); + try { global.ratelimits = JSON.parse(fs.readFileSync("cache/ratelimits.json").toString()); } catch (e) { @@ -41,6 +45,7 @@ setInterval(() => { if (worth < 0.1) worth = 0.1; if (score['score'] > 0) score['score'] -= worth; + score['percentage'] = score['score'] / 12.5; }, 1800000); setInterval(() => { @@ -85,7 +85,7 @@ function startMatrix() { let text = event.event.content.body.toLowerCase(); - if (event.event.sender === "@cloudburst:equestria.dev" || event.event.sender === "@raindrops:equestria.dev") { + if (event.event.sender === "@cloudburst:equestria.dev" || event.event.sender === "@raindrops:equestria.dev" || event.event.sender === "@stargrove:equestria.dev") { let worth = 1 / (score['score'] / 100); if (worth < 0.1) worth = 0.1; @@ -197,11 +197,11 @@ function startMatrix() { score['score'] += 3 * worth; } - if (Math.floor(score['percentage']) < Math.floor(score['score'] / 20)) { - matrixSend(room.roomId, "π Congrats! Your love score is now at " + Math.floor(score['score'] / 20) + "%, keep it up!"); + if (Math.floor(score['percentage']) < Math.floor(score['score'] / 12.5)) { + matrixSend(room.roomId, "π Congrats! Your love score is now at " + Math.floor(score['score'] / 12.5) + "%, keep it up!"); } - score['percentage'] = score['score'] / 20; + score['percentage'] = score['score'] / 12.5; } } } @@ -217,7 +217,7 @@ function startMatrix() { })(); } catch (e) { setTimeout(() => { - startDiscord(); + startMatrix(); }, 300000); } } |