2022-01-04 03:39:53 +00:00
|
|
|
const osu = require("osu-packet"),
|
2022-08-26 12:52:00 +01:00
|
|
|
consoleHelper = require("../../consoleHelper.js"),
|
|
|
|
Streams = require("../Streams.js");
|
2021-01-26 12:26:46 +00:00
|
|
|
|
|
|
|
module.exports = function(CurrentUser, channelName = "") {
|
2022-01-04 03:39:53 +00:00
|
|
|
// Make sure the user is not already in the channel
|
2022-08-26 12:52:00 +01:00
|
|
|
if (Streams.isUserInStream(channelName, CurrentUser.uuid))
|
2022-01-04 03:39:53 +00:00
|
|
|
return consoleHelper.printBancho(`Did not add user to channel ${channelName} because they are already in it`);
|
2021-01-26 12:26:46 +00:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
2021-01-26 12:26:46 +00:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
osuPacketWriter.ChannelJoinSuccess(channelName);
|
2022-08-26 12:52:00 +01:00
|
|
|
if (!Streams.isUserInStream(channelName, CurrentUser.uuid))
|
|
|
|
Streams.addUserToStream(channelName, CurrentUser.uuid);
|
2021-01-26 12:26:46 +00:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
|
2021-01-26 12:26:46 +00:00
|
|
|
}
|