From 902631d7724da806c579aca111e76b5d59eacd17 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Mon, 22 Feb 2021 21:49:07 -0700 Subject: [PATCH] random stuff and bugs --- events/message.js | 2 +- responses/wubzy.js | 47 ++++++++++++++++++++++++++++++++++++++++--- util/lxp/cacheloop.js | 4 ++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/events/message.js b/events/message.js index 22bce82..4167901 100644 --- a/events/message.js +++ b/events/message.js @@ -29,7 +29,7 @@ module.exports = async (client, message) => { if ([`<@${client.user.id}>`, `<@!${client.user.id}>`].includes(msg)) { return message.channel.send(new Discord.MessageEmbed() .setTitle(["Yep, that's me!", "^^ Hiya!", "Oh, hi there!", "Sure, what's up?", "How can I help!", "Natsuki is busy, but I can take a message for you!", "Teehee that's me!", "You were looking for Natsuki Tivastl, right?", "Sure! What's up?", "Pong!"][Math.floor(Math.random() * 10)]) - .setDescription("My prefix here is `" + prefix + "`. Use `" + prefix + "help` to see what commands you can use.") + .setDescription(`My prefix here is \`${prefix}\`. Use \`${prefix}help\` to see what commands you can use.`) .setColor('c375f0')); } diff --git a/responses/wubzy.js b/responses/wubzy.js index 821432d..2735786 100644 --- a/responses/wubzy.js +++ b/responses/wubzy.js @@ -12,9 +12,9 @@ module.exports = { .addField("Syntax", "``"), async condition (message, msg, args, cmd, prefix, mention, client) {return message.author.id === "330547934951112705"}, async execute(message, msg, args, cmd, prefix, mention, client) { - const inc = m => msg.includes(m); + const inc = (m,s) => s ? s.toLowerCase().includes(m) : msg.includes(m); const is = m => msg.trim() === m; - function incl(ml) {let tm; for (tm of ml) {if (inc(tm)) {return true;}}} + function incl(ml, s) {let tm; for (tm of ml) {if (inc(tm, s)) {return true;}}} if (incl(["thanks natsuki", "thank you natsuki", "ty natsuki"])) { const r = ["Anytime!", "Anything for my creator!", "I hope I was at least a little bit helpful!", @@ -37,7 +37,7 @@ module.exports = { try {sconf = await message.channel.awaitMessages(m => m.author.id === "330547934951112705", {time: 15000, errors: ['time'], max: 1});} catch {message.channel.send("Oh, I guess he already went to bed, huh? I'll just... set his status anyways-"); to = true;} if (sconf) {sconf = sconf.first().content.trim().toLowerCase();} - if (to || ['sure', 'ye', 'mhm'].includes(sconf)) { + if (to || incl(['ye', 'mhm', 'sure'], sconf)) { let w = await UserData.findOne({uid: message.author.id}); w.statusclearmode = 'manual'; w.statusmsg = "Sleeping "; @@ -48,7 +48,48 @@ module.exports = { w.save(); if (!to) {message.channel.send("I set your status for you so you can get some sleep! Message me when you're up - I get lonely when you sleep ;-;");} return; + } else {return message.channel.send("Oh... well, goodnight! Let me know when you're up, this castle gets so lonely when you're asleep");} + } + + if (inc('anime') && incl(['we binging', 'am i watching', 'should i watch', 'to watch', 'we watching', "am i gonna watch", "are we gonna watch"]) && inc("natsuki")) { + async function q() { + let sconf; + const r1 = ["Hmm, you could", "You could always", "How about you", "You can", "Tough question. Maybe", "Glad you asked! You should", "Oh I know the perfect one:"]; + const r2 = ["rebinge Arifureta", "watch ~~tits the anime~~ DxD :wink:", "do Fairy Tail", "sob to Violet Evergarden again", "see Tokyo Ghoul for the millionth time", "watch ReZero", "finally start Attack on Titan Season 4", + "watch quintessential quintuplets", "have your heart wrenched out by Senko-San again", "finish Bleach", "finish Akame ga Kill", "start Guren Lagann", "finish Darling in the Franxx again", + "watch Akashic Records again", "finish Rent-a-Girlfriend", "rebinge Kabaneri and question reality", "rewatch Code Geass", "do a thing called getting the hell off anime and doing something productive with your life!"]; + message.channel.send(`${r1[Math.floor(Math.random() * r1.length)]} ${r2[Math.floor(Math.random() * r2.length)]}`); + try {sconf = await message.channel.awaitMessages(m => m.author.id === "330547934951112705", {time: 15000, errors: ['time'], max: 1});} + catch {message.channel.send("Oh, I guess he liked the idea that much and just left..."); return 2;} + sconf = sconf.first().content.trim().toLowerCase(); + if (incl(["bet", "i like", "yes", "sure", "fine", "alright", "ok"], sconf)) { + const r3 = ["Glad you liked the idea!", "Smart move!", "Hehe I'm good at reccomendations, aren't I?", "Yay I love it when Wubby likes my suggestions"]; + message.channel.send(`${r3[Math.floor(Math.random() * r3.length)]} Want me to set your status?`); + return 1; + } else { + const r3 = ["Oh, my bad.", "Sorry bout that. Lemme try again", "Bad idea? Yeah I didn't think it was that good of an idea anyways.", "Uhhhh- pfff I was just joking anyways"]; + message.channel.send(r3[Math.floor(Math.random() * r3.length)]); + return await q(); + } } + let res = await q(); + if (res === 2) {return;} + let to = false; let sconf; + try {sconf = await message.channel.awaitMessages(m => m.author.id === "330547934951112705", {time: 15000, errors: ['time'], max: 1});} + catch {message.channel.send("Guess my recommendations are just that good that he left... Don't mind me while I set his status anyways"); to = true;} + if (sconf) {sconf = sconf.first().content.trim().toLowerCase();} + if (to || incl(['ye', 'mhm', 'sure'], sconf)) { + let w = await UserData.findOne({uid: message.author.id}); + w.statusclearmode = 'manual'; + w.statusmsg = "Watching anime (that I personally recommended him because I'm cool so leave poor Wubzy be!)"; + w.statussetat = new Date(); + let tempDate = new Date(); + w.statusclearat = tempDate.setHours(tempDate.getHours() + 12); + w.statustype = 'dnd'; + w.save(); + if (!to) {message.channel.send("I set your status for you so you can get some binging in! Let me know if your anime is any good, I've been looking for a good watch myself.");} + return; + } else {return message.channel.send("Watching anime in incognito are we? I gotcha :p");} } } }; \ No newline at end of file diff --git a/util/lxp/cacheloop.js b/util/lxp/cacheloop.js index 4c2ac14..a3f1ed2 100644 --- a/util/lxp/cacheloop.js +++ b/util/lxp/cacheloop.js @@ -2,18 +2,18 @@ const LXP = require('../../models/localxp'); module.exports = async (client) => { let cd = new Date().getTime(); - await client.misc.cache.lxp.enabled.forEach(gxp => { + await Object.keys(client.misc.cache.lxp.xp).forEach(gxp => { LXP.findOne({gid: gxp}).then(xp => { if (!xp) {return;} Object.keys(client.misc.cache.lxp.xp[gxp]).forEach(user => { xp.xp[user] = [client.misc.cache.lxp.xp[gxp][user].xp, client.misc.cache.lxp.xp[gxp][user].level]; xp.markModified(`xp.${user}`); - xp.save(); if (cd - client.misc.cache.lxp.xp[gxp][user].lastXP > 600000) { delete client.misc.cache.lxp.xp[gxp][user]; if (!Object.keys(client.misc.cache.lxp.xp[gxp]).length) {delete client.misc.cache.lxp.xp[gxp];} } }); + xp.save(); }) }) }; \ No newline at end of file