public static async Task LevelsClient_VoiceStateUpdated(DiscordClient sender, VoiceStateUpdateEventArgs voiceStateUpdateEventArgs) { if (voiceStateUpdateEventArgs.User.IsBot) { return; } var oldChannel = voiceStateUpdateEventArgs.Before; var newChannel = voiceStateUpdateEventArgs.After; var now = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm"); if (oldChannel == null && newChannel != null) { Level.Logger.LogDebug($"{voiceStateUpdateEventArgs.User.Id} has joined VC {voiceStateUpdateEventArgs.Channel.Name}[{voiceStateUpdateEventArgs.Channel.Id}]"); await DatabaseActions.SetUserInCall(voiceStateUpdateEventArgs.User.Id.ToString(), now, true); return; } if (oldChannel != null && newChannel.Channel == null) { Level.Logger.LogDebug($"{voiceStateUpdateEventArgs.User.Id} is no longer in a voice channel"); var user = await DatabaseActions.GetUserExp(voiceStateUpdateEventArgs.User.Id, true); await DatabaseActions.SetUserInCall(voiceStateUpdateEventArgs.User.Id.ToString(), now, false); var diff = Convert.ToInt32((DateTime.Parse(now) - DateTime.Parse(user.Rows[0]["voice_last_join"].ToString() !)).TotalMinutes); decimal expToAdd = diff * LevelOptions.ExpPerVoiceMin; await DatabaseActions.GiveExp(voiceStateUpdateEventArgs.User.Id.ToString(), true, expToAdd); return; } Level.Logger.LogDebug($"{voiceStateUpdateEventArgs.User.Id} is still in VC, doing nothing"); return; }