public async Task Run()
        {
            IEnumerable <ChannelHostModel> channels = this.Channels.ToList();
            HostingOrderEnum hostOrder = EnumHelper.GetEnumValueFromString <HostingOrderEnum>(this.HostingOrder);
            AgeRatingEnum    ageRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(this.AgeRating);

            PrivatePopulatedUserModel currentUser = await this.connection.Users.GetCurrentUser();

            if (currentUser != null && !currentUser.channel.online)
            {
                bool keepCurrentHost = false;
                if (currentUser.channel.hosteeId != null)
                {
                    ExpandedChannelModel channel = await this.connection.Channels.GetChannel(currentUser.channel.hosteeId.GetValueOrDefault());

                    if (channel != null)
                    {
                        AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channel.audience);
                        if (channelAgeRating <= ageRating)
                        {
                            keepCurrentHost       = true;
                            this.CurrentlyHosting = new ChannelHostModel()
                            {
                                ID   = channel.userId,
                                Name = channel.user.username,
                            };
                        }
                    }
                }

                if (!keepCurrentHost)
                {
                    this.CurrentlyHosting = null;
                }

                if (this.CurrentlyHosting != null)
                {
                    await this.UpdateChannel(this.CurrentlyHosting);
                }

                if (this.IsAutoHostingEnabled && (this.CurrentlyHosting == null || !this.CurrentlyHosting.IsOnline))
                {
                    if (hostOrder == HostingOrderEnum.Random)
                    {
                        channels = channels.OrderBy(c => Guid.NewGuid());
                    }

                    foreach (ChannelHostModel channel in channels)
                    {
                        if (channel.IsEnabled)
                        {
                            ChannelModel channelModel = await this.UpdateChannel(channel);

                            AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channelModel.audience);
                            if (channelModel != null && channel.IsOnline && channelAgeRating <= ageRating)
                            {
                                ChannelModel updatedChannel = await this.connection.Channels.SetHostChannel(currentUser.channel, channelModel);

                                if (updatedChannel.hosteeId.GetValueOrDefault() == channelModel.id)
                                {
                                    this.CurrentlyHosting = channel;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            await this.SaveData();
        }
        public async Task Run()
        {
            IEnumerable <ChannelHostModel> channels = this.Channels.ToList();
            HostingOrderEnum hostOrder = this.settings.HostingOrder;
            AgeRatingEnum    ageRating = this.settings.AgeRating;

            PrivatePopulatedUserModel currentUser = await this.connection.Users.GetCurrentUser();

            if (currentUser != null && !currentUser.channel.online)
            {
                bool keepCurrentHost = false;
                if (currentUser.channel.hosteeId != null)
                {
                    ExpandedChannelModel channel = await this.connection.Channels.GetChannel(currentUser.channel.hosteeId.GetValueOrDefault());

                    if (channel != null)
                    {
                        AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channel.audience);
                        if (channelAgeRating <= ageRating)
                        {
                            keepCurrentHost       = true;
                            this.CurrentlyHosting = new ChannelHostModel()
                            {
                                ID   = channel.userId,
                                Name = channel.token,
                            };
                        }
                    }
                }

                if (!keepCurrentHost)
                {
                    this.CurrentlyHosting = null;
                }

                if (this.CurrentlyHosting != null)
                {
                    await this.UpdateChannel(this.CurrentlyHosting);

                    this.totalMinutesHosted++;
                }

                if (this.IsAutoHostingEnabled && (this.CurrentlyHosting == null || !this.CurrentlyHosting.IsOnline || (this.settings.MaxHostLength > 0 && this.totalMinutesHosted >= this.settings.MaxHostLength)))
                {
                    Base.Util.Logger.Log("Attempting to find new host...");

                    if (hostOrder == HostingOrderEnum.Random)
                    {
                        if (this.CurrentlyHosting != null)
                        {
                            channels = channels.Where(c => !c.ID.Equals(this.CurrentlyHosting.ID));
                        }
                        channels = channels.OrderBy(c => Guid.NewGuid());
                    }

                    foreach (ChannelHostModel channel in channels)
                    {
                        if (channel.IsEnabled)
                        {
                            ChannelModel channelModel = await this.UpdateChannel(channel);

                            AgeRatingEnum channelAgeRating = EnumHelper.GetEnumValueFromString <AgeRatingEnum>(channelModel.audience);
                            if (channelModel != null && channel.IsOnline && channelAgeRating <= ageRating)
                            {
                                if (this.CurrentlyHosting != null && channelModel.id.Equals(this.CurrentlyHosting.ID))
                                {
                                    this.totalMinutesHosted = 0;
                                    break;
                                }
                                else
                                {
                                    ChannelModel updatedChannel = await this.connection.Channels.SetHostChannel(currentUser.channel, channelModel);

                                    if (updatedChannel.hosteeId.GetValueOrDefault() == channelModel.id)
                                    {
                                        Base.Util.Logger.Log("Now hosting " + channelModel.token);

                                        await this.SaveData();

                                        this.CurrentlyHosting   = channel;
                                        this.totalMinutesHosted = 0;

                                        if (!string.IsNullOrEmpty(this.WhisperMessage))
                                        {
                                            ChatClient chatClient = ChatClient.CreateFromChannel(connection, channelModel).Result;
                                            if (chatClient.Connect().Result&& chatClient.Authenticate().Result)
                                            {
                                                await Task.Delay(3000);

                                                await chatClient.Whisper(channelModel.token, this.WhisperMessage);

                                                await Task.Delay(3000);
                                            }
                                            await chatClient.Disconnect();
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                this.totalMinutesHosted = 0;
            }
        }