Пример #1
0
        private Task Client_VoiceStateUpdated(VoiceStateUpdateEventArgs e)
        {
            if (e == null)
            {
                //for some reason it returns null event args sometimes?
                return(Task.CompletedTask);
            }

            // Ignore bots joining
            if (e.User == null || e.User.IsBot)
            {
                return(Task.CompletedTask);
            }
            try
            {
                lock (LockObject)
                {
                    if (e.After.Channel != null && (e.Before == null || e.Before.Channel == null))
                    {
                        IntroQueueElement introQueueElement = new IntroQueueElement
                        {
                            NewUser       = e.User,
                            ChannelToJoin = e.After.Channel,
                            GuildToJoin   = e.After.Guild
                        };

                        introQueue.Add(introQueueElement);

                        e.Client.DebugLogger.LogMessage(LogLevel.Debug, "NoiseBot", string.Format("{0} joined channel {1}", e.User, e.After.Channel.Name), DateTime.Now);
                    }
                    else if (e.After.Channel == null && e.Before.Channel != null)
                    {
                        e.Client.DebugLogger.LogMessage(LogLevel.Debug, "NoiseBot", string.Format("{0} left channel {1}", e.User.Username, e.Before.Channel.Name), DateTime.Now);
                    }
                }
            }
            catch (Exception ex)
            {
                e.Client.DebugLogger.LogMessage(LogLevel.Critical, "ExampleBot", string.Format("{0}", ex), DateTime.Now);
            }
            return(Task.CompletedTask);
        }
Пример #2
0
        private void IntroMethodThread()
        {
            while (isDoingIntros)
            {
                IntroQueueElement introQueueElement = introQueue.Take();
                if (isDoingIntros)
                {
                    CustomIntroModel introModel = CustomIntroFile.Instance.GetIntroForUsername(introQueueElement.NewUser.Username);
                    string           filepath;
                    if (introModel != null)
                    {
                        Program.Client.DebugLogger.Info(string.Format("Playing {0} for {1}", introModel.Filepath, introQueueElement.NewUser.Username));
                        filepath = introModel.Filepath;
                    }
                    else
                    {
                        Program.Client.DebugLogger.Warn(string.Format("No intro was found for {0}. Using default", introQueueElement.NewUser.Username));
                        filepath = @"AudioFiles\fuckyou.mp3";
                    }

                    AudioController.Instance.AddAudioToQueue(filepath, introQueueElement.ChannelToJoin, introQueueElement.GuildToJoin);
                }
            }
        }