From bc8bf518d162793b80c70f2b6546d0b3672235d8 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Tue, 4 Jan 2022 16:37:28 -0700 Subject: [PATCH] wait for client fully started to respond to msgs --- bot.js | 3 ++- events/messageCreate.js | 2 ++ events/ready.js | 2 ++ util/lxp/spawnchest.js | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index 8bba88a..39a24e3 100644 --- a/bot.js +++ b/bot.js @@ -63,7 +63,8 @@ client.misc = { logs: 'normal', lightstartup: false, ignorecmds: [] - } + }, + fullyReady: false }; //const config = require('./config.js'); diff --git a/events/messageCreate.js b/events/messageCreate.js index 414ad27..5af311a 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -12,6 +12,8 @@ const Monners = require('../models/monners'); const channelTypes = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE", "GUILD_TEXT"]; module.exports = async (client, message) => { + if (!client.misc.fullyReady) {return;} + if (message.partial) {await message.fetch();} if (message.channel.partial) {await message.channel.fetch();} diff --git a/events/ready.js b/events/ready.js index 63de9f4..8defbdc 100644 --- a/events/ready.js +++ b/events/ready.js @@ -108,5 +108,7 @@ module.exports = async client => { await botData.save(); + client.misc.fullyReady = true; + require('../console')(client); }; \ No newline at end of file diff --git a/util/lxp/spawnchest.js b/util/lxp/spawnchest.js index 1324066..da54d7f 100644 --- a/util/lxp/spawnchest.js +++ b/util/lxp/spawnchest.js @@ -5,8 +5,8 @@ const Discord = require('discord.js'); module.exports = async (client, member, channel, prefix) => { if (client.misc.cache.chests.timeout.has(member.guild.id) && new Date().getTime() - client.misc.cache.chests.timeout.get(member.guild.id) < (1000 * 60 * 2)) {return;} - //let rand = Math.floor(Math.random() * 100); - //if (rand !== 69) {return;} //decide if it even continues + let rand = Math.floor(Math.random() * 100); + if (rand !== 69 && rand !== 42) {return;} //decide if it even continues let tm = await Monners.findOne({uid: member.id}); let streak = tm && tm.daily ? tm.daily.streak : 0; //get streak for bonus later