コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
            }
        }