Пример #1
0
        private async Task UserVoiceStateUpdatedAsync(SocketUser user, SocketVoiceState prevState, SocketVoiceState newState)
        {
            if (prevState.VoiceChannel == newState.VoiceChannel)
            {
                if (newState.IsDeafened != prevState.IsDeafened)
                {
                    await Log.LogAsync(user, newState.VoiceChannel, newState.IsDeafened? "Admin Deafened" : "Admin Undeafened");

                    await VoiceEventLog.Log(user, newState.VoiceChannel, newState.IsDeafened? "Admin Deafened" : "Admin Undeafened");
                }
                else if (newState.IsMuted != prevState.IsMuted)
                {
                    await Log.LogAsync(user, newState.VoiceChannel, newState.IsMuted? "Admin Muted" : "Admin Unmuted");

                    await VoiceEventLog.Log(user, newState.VoiceChannel, newState.IsMuted? "Admin Muted" : "Admin Unmuted");
                }
                else if (newState.IsSelfDeafened != prevState.IsSelfDeafened) //It's important that deafened check comes before mute check
                {
                    await Log.LogAsync(user, newState.VoiceChannel, newState.IsSelfDeafened? "Self Deafened" : "Self Undeafened");

                    await VoiceEventLog.Log(user, newState.VoiceChannel, newState.IsSelfDeafened? "Self Deafened" : "Self Undeafened");
                }
                else if (newState.IsSelfMuted != prevState.IsSelfMuted)
                {
                    await Log.LogAsync(user, newState.VoiceChannel, newState.IsSelfMuted? "Self Muted" : "Self Unmuted");

                    await VoiceEventLog.Log(user, newState.VoiceChannel, newState.IsSelfMuted? "Self Muted" : "Self Unmuted");
                }
            }
            else if (prevState.VoiceChannel == null)
            {
                await Log.LogAsync(user, newState.VoiceChannel, "Joined");

                await VoiceEventLog.Log(user, newState.VoiceChannel, "Joined");
            }
            else if (newState.VoiceChannel == null)
            {
                await Log.LogAsync(user, prevState.VoiceChannel, "Left");

                await VoiceEventLog.Log(user, prevState.VoiceChannel, "Left");
            }
            else if (newState.VoiceChannel != prevState.VoiceChannel)
            {
                await Log.LogAsync(user, prevState.VoiceChannel, "Left");

                await VoiceEventLog.Log(user, prevState.VoiceChannel, "Left");

                await Log.LogAsync(user, newState.VoiceChannel, "Joined");

                await VoiceEventLog.Log(user, newState.VoiceChannel, "Joined");
            }
            else
            {
                await Log.LogAsync(user, newState.VoiceChannel, "Unknown");
            }
        }
Пример #2
0
        private async Task ReadyAsync()
        {
            await Log.LogAsync($"{_client.CurrentUser} connected!");

            var db = new ApplicationDataContext();

            foreach (var chan in db.DiscordVoiceChannel)
            {
                var c = _client.GetChannel(chan.Id);
                foreach (var u in c.Users)
                {
                    //TODO make this inteligent and check if they already have an open session
                    await VoiceEventLog.Log(u, c, "Joined");
                }
            }
            db.Dispose();
        }
Пример #3
0
        private async void BotShuttingDown(object sender, EventArgs e)
        {
            Console.WriteLine("Shutting Down");
            var db = new ApplicationDataContext();

            foreach (var chan in db.DiscordVoiceChannel)
            {
                var c = _client.GetChannel(chan.Id);
                foreach (var u in c.Users)
                {
                    await VoiceEventLog.Log(u, c, "Left");
                }
            }
            await db.SaveChangesAsync();

            _client.Dispose();
            MainThread.Cancel();
            Environment.Exit(0);
        }