diff --git a/bot2019.db/000101.ldb b/bot2019.db/000101.ldb deleted file mode 100644 index 692b9b1..0000000 Binary files a/bot2019.db/000101.ldb and /dev/null differ diff --git a/bot2019.db/000103.ldb b/bot2019.db/000103.ldb deleted file mode 100644 index 536b00d..0000000 Binary files a/bot2019.db/000103.ldb and /dev/null differ diff --git a/bot2019.db/000106.ldb b/bot2019.db/000106.ldb deleted file mode 100644 index a906ad8..0000000 Binary files a/bot2019.db/000106.ldb and /dev/null differ diff --git a/bot2019.db/000155.ldb b/bot2019.db/000155.ldb new file mode 100644 index 0000000..f4e240a Binary files /dev/null and b/bot2019.db/000155.ldb differ diff --git a/bot2019.db/000157.ldb b/bot2019.db/000157.ldb new file mode 100644 index 0000000..ba0b067 Binary files /dev/null and b/bot2019.db/000157.ldb differ diff --git a/bot2019.db/000160.ldb b/bot2019.db/000160.ldb new file mode 100644 index 0000000..eea4981 Binary files /dev/null and b/bot2019.db/000160.ldb differ diff --git a/bot2019.db/000161.log b/bot2019.db/000161.log new file mode 100644 index 0000000..3fbcbd6 Binary files /dev/null and b/bot2019.db/000161.log differ diff --git a/bot2019.db/CURRENT b/bot2019.db/CURRENT index 2a5d251..eda0873 100644 --- a/bot2019.db/CURRENT +++ b/bot2019.db/CURRENT @@ -1 +1 @@ -MANIFEST-000105 +MANIFEST-000159 diff --git a/bot2019.db/LOG b/bot2019.db/LOG index cc83281..dfcbd5e 100644 --- a/bot2019.db/LOG +++ b/bot2019.db/LOG @@ -1,5 +1,5 @@ -2021/05/12-13:31:06.024 5b98 Recovering log #104 -2021/05/12-13:31:06.024 5b98 Level-0 table #106: started -2021/05/12-13:31:06.030 5b98 Level-0 table #106: 546 bytes OK -2021/05/12-13:31:06.046 5b98 Delete type=0 #104 -2021/05/12-13:31:06.049 5b98 Delete type=3 #102 +2021/05/13-20:15:39.975 cf4 Recovering log #158 +2021/05/13-20:15:40.183 cf4 Level-0 table #160: started +2021/05/13-20:15:40.220 cf4 Level-0 table #160: 276036 bytes OK +2021/05/13-20:15:40.236 cf4 Delete type=0 #158 +2021/05/13-20:15:40.239 cf4 Delete type=3 #156 diff --git a/bot2019.db/LOG.old b/bot2019.db/LOG.old index a671fc9..1ba9172 100644 --- a/bot2019.db/LOG.old +++ b/bot2019.db/LOG.old @@ -1,5 +1,5 @@ -2021/05/12-13:27:51.851 52b8 Recovering log #100 -2021/05/12-13:27:51.851 52b8 Level-0 table #103: started -2021/05/12-13:27:51.866 52b8 Level-0 table #103: 202 bytes OK -2021/05/12-13:27:51.884 52b8 Delete type=0 #100 -2021/05/12-13:27:51.887 52b8 Delete type=3 #98 +2021/05/12-13:48:11.247 53ec Recovering log #154 +2021/05/12-13:48:11.247 53ec Level-0 table #157: started +2021/05/12-13:48:11.256 53ec Level-0 table #157: 228 bytes OK +2021/05/12-13:48:11.276 53ec Delete type=0 #154 +2021/05/12-13:48:11.279 53ec Delete type=3 #152 diff --git a/bot2019.db/MANIFEST-000105 b/bot2019.db/MANIFEST-000105 deleted file mode 100644 index f60b338..0000000 Binary files a/bot2019.db/MANIFEST-000105 and /dev/null differ diff --git a/bot2019.db/MANIFEST-000159 b/bot2019.db/MANIFEST-000159 new file mode 100644 index 0000000..e6d95f2 Binary files /dev/null and b/bot2019.db/MANIFEST-000159 differ diff --git a/bot2019.db/000107.log b/password.txt similarity index 100% rename from bot2019.db/000107.log rename to password.txt diff --git a/src/Commands.js b/src/Commands.js index d3ac5b6..3d95e37 100644 --- a/src/Commands.js +++ b/src/Commands.js @@ -1,6 +1,7 @@ const DiscordClient = require("./DiscordClient"); const Color = require('./Color'); const crypto = require('crypto'); +const fs = require('fs'); module.exports = (bot) => { bot.addCommand = async (cmd, minargs, func, hidden) => { @@ -18,8 +19,6 @@ module.exports = (bot) => { var newfish = require("./newfish.json"); var pokedex = []; - - var sendChat = DiscordClient.sendChat; var blockHelpUntil = 0; @@ -288,15 +287,21 @@ module.exports = (bot) => { function findParticipantByNameCaseInsensitive(name) { if(!name || name.trim() == "") return undefined; var part = findParticipantByName(name); - // if(!part) { - // name_lc = name.toLowerCase(); - // for(var id in client.ppl) { - // if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase() === name_lc) { - // part = client.ppl[id]; - // break; - // } - // } - // } + if(!part) { + name_lc = name.toLowerCase(); + DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.forEach(p => { + if (p.user.username.toLowerCase() === name_lc) { + part = p.user; + part.name = p.user.name; + part._id = p.user.id; + DiscordClient.client.guilds.cache.get('841331769051578413').roles.cache.forEach(r => { + if (r.name === part._id) { + part.color = r.color; + } + }); + } + }); + } return part; }; @@ -799,7 +804,7 @@ module.exports = (bot) => { var color = "#"+rrggbbrand()+rrggbbrand()+rrggbbrand(); // client.sendArray([{m: "admin message", password: "amogus", // msg: {m: "color", _id: msg.p._id, color: color}}]); - DiscordClient.client.guilds.cache.get("841331769051578413").roles.forEach(r => { + DiscordClient.client.guilds.cache.get("841331769051578413").roles.cache.forEach(r => { if (r.name == msg.p._id) { r.edit({ color: color @@ -981,7 +986,7 @@ module.exports = (bot) => { }); }, false); - bot.addCommand('/grow_fruit', 0, (msg, admin) => { + bot.addCommand('grow_fruit', 0, (msg, admin) => { if (!admin) return; var how_many = ~~args[0]; if(!how_many) how_many = 1; @@ -991,6 +996,81 @@ module.exports = (bot) => { }); }, false); + var TOO_MANY_FISH = 50; + + bot.addCommand('take', 0, msg => { + db.getLocation(msg.p._id, location => { + var target = msg.argcat().toLowerCase().trim(); + if(!target.length) { + sendChat("Take what?"); + return; + } + db.take(location, target, function(entry) { + if(!entry) { + sendChat("Friend "+msg.p.name+": You can't take "+target+" from "+location+"."); + } else { + db.getFish(msg.p._id, function(myfish) { + if(myfish.length >= TOO_MANY_FISH) { + sendChat("Friend "+msg.p.name+" is carrying too much."); + } else { + var fish = entry.key; + fish = fish.substr(fish.indexOf("◍")+1); + myfish.push(fish); + db.putFish(msg.p._id, myfish); + db.del(entry.key); + sendChat("Friend "+msg.p.name+" took the "+fish+"."); + }; + }); + } + }); + }); + }, false); + + bot.addCommand('give', 0, msg => { + var thief = msg.p; + var victim = findParticipantByNameFuzzy(args[0]); + if(!victim) { + sendChat("Friend " +thief.name+" missed"); + return; + } + if(victim._id == thief._id) { + sendChat("Friendly friend " +thief.name+" fudged"); + return; + } + var target_fish = argcat(1); + db.getFish(thief._id, function(thief_fish) { + db.getFish(victim._id, function(victim_fish) { + if(victim_fish.length >= TOO_MANY_FISH) { + sendChat("Friend " +victim.name+" is carrying too much."); + return; + } + if(thief_fish.length > 0) { + var idx = -1; + var arg = target_fish.trim().toLowerCase(); + for(var i = 0; i < thief_fish.length; i++) { + if(arg == "" || thief_fish[i].toLowerCase().indexOf(arg) !== -1) { + idx = i; + break; + } + } + if(idx == -1) { + sendChat("Friend " +thief.name+": You don't have a "+arg+" that you can /give like that."); + return; + } + var thefish = thief_fish[idx]; + thief_fish.splice(idx, 1); + victim_fish.push(thefish); + + sendChat("Our friend " +thief.name+" gave "+victim.name+" his/her "+thefish); + db.putFish(thief._id, thief_fish); + db.putFish(victim._id, victim_fish); + } else { + sendChat("Friend " +thief.name+": You don't have the fish to give."); + } + }); + }); + }, false); + setInterval(function() { db.put("look.outside.◍Sand", "We don't talk about that."); }, 6000); @@ -1016,6 +1096,7 @@ module.exports = (bot) => { DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.forEach(p => { if (p.user.id === user_id) { part = p.user; + part.name = p.user.username; part._id = p.user.id; if(typeof part !== 'undefined') { catchSomething(part);