From e24cc98fec4ad4b4b5934efe948a3a688e366b81 Mon Sep 17 00:00:00 2001 From: Bradley Bickford Date: Sat, 11 Nov 2023 20:09:03 -0500 Subject: [PATCH] Fixed some syncronization issues (I think) --- breadbot.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/breadbot.js b/breadbot.js index e514108..667f780 100644 --- a/breadbot.js +++ b/breadbot.js @@ -88,19 +88,20 @@ client.on(Events.GuildCreate, async guild => { } }) +// There is what too much async/await mess in here. Needs to be reworked client.on(Events.MessageCreate, async message => { console.log("Message Create Fired") - sqlutil.isChannelRegistered(message.channelId).then(channel_check => { + sqlutil.isChannelRegistered(message.channelId).then(async channel_check => { if(!channel_check) { console.log(`Registering Channel ${message.channel.guild.name} - ${message.channel.name}`) - sqlutil.registerChannel(message.channel.id, message.channel.guildId, message.channel.name) + await sqlutil.registerChannel(message.channel.id, message.channel.guildId, message.channel.name) } - sqlutil.isUserRegistered(message.author.id).then(user_check => { + sqlutil.isUserRegistered(message.author.id).then(async user_check => { if(!user_check) { console.log(`Registering User ${messsage.author.username}`) - sqlutil.registerUser(message.author.id, message.author.username, message.author.displayName) + await sqlutil.registerUser(message.author.id, message.author.username, message.author.displayName) } console.log(`Registering message from ${message.channel.guild.name} - ${message.channel.name} - ${message.author.username}`)