diff --git a/server/Packets/SendPrivateMessage.js b/server/Packets/SendPrivateMessage.js index b469eae..a5932f3 100644 --- a/server/Packets/SendPrivateMessage.js +++ b/server/Packets/SendPrivateMessage.js @@ -3,6 +3,9 @@ const osu = require("osu-packet"), module.exports = function(CurrentUser, CurrentPacket) { const osuPacketWriter = new osu.Bancho.Writer; + const userSentTo = getUserByUsername(CurrentPacket.data.target); + + if (userSentTo == null) return; osuPacketWriter.SendMessage({ sendingClient: CurrentUser.username, @@ -11,8 +14,6 @@ module.exports = function(CurrentUser, CurrentPacket) { senderId: CurrentUser.id }); - const userSentTo = getUserByUsername(CurrentPacket.data.target); - // Write chat message to stream asociated with chat channel return userSentTo.addActionToQueue(osuPacketWriter.toBuffer); } \ No newline at end of file