private async Task OnUserLeft(DiscordChannel?voiceChannel, AutoVoiceSettings settings) { if (voiceChannel is null) { return; } if (!settings.ContainsChannel(voiceChannel)) { return; } if (voiceChannel.Users.Any()) { await _autoVoiceService.UpdateNameAsync(voiceChannel); return; } // All users left, now we can delete the channel if (settings.RemoveChannel(voiceChannel)) { await voiceChannel.DeleteAsync(); } }
private async Task OnUserJoin(DiscordChannel?voiceChannel, AutoVoiceSettings settings) { if (voiceChannel is null) { return; } if (settings.ContainsChannel(voiceChannel)) { await _autoVoiceService.UpdateNameAsync(voiceChannel); } else if (settings.ChannelCreatorId == voiceChannel.Id) { await _autoVoiceService.UpdateNameAsync(voiceChannel); var newVoiceChannel = await _autoVoiceService.CreateAsync(voiceChannel.Guild, voiceChannel.Parent, settings.Bitrate); settings.AddChannel(newVoiceChannel); } }