2022-01-04 03:39:53 +00:00
|
|
|
const osu = require("osu-packet"),
|
|
|
|
consoleHelper = require("../../consoleHelper.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
|
|
|
|
if (global.StreamsHandler.isUserInStream(channelName, CurrentUser.uuid))
|
|
|
|
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);
|
|
|
|
if (!global.StreamsHandler.isUserInStream(channelName, CurrentUser.uuid))
|
|
|
|
global.StreamsHandler.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
|
|
|
}
|