예제 #1
0
        public async Task RemoveAndAddDefaultVC(IGuild guild)
        {
            foreach (IVoiceChannel VC in await guild.GetVoiceChannelsAsync())
            {
                await VC.DeleteAsync();
            }

            int    numberOfUsers            = guild.GetUsersAsync().Result.Count;
            double defaultVoiceChannelCount = Math.Max(Math.Round(numberOfUsers / 10.0), 2.0);

            for (; defaultVoiceChannelCount > 0; defaultVoiceChannelCount--)
            {
                await guild.CreateVoiceChannelAsync("Lobby");
            }

            await guild.CreateVoiceChannelAsync("Watchin");

            IVoiceChannel afkChan = await guild.CreateVoiceChannelAsync("AFK");

            void ChangeAFKChan(GuildProperties properties) => properties.AfkChannel = new Optional <IVoiceChannel>(afkChan);

            Action <GuildProperties> modifyAFK = new Action <GuildProperties>(ChangeAFKChan);

            await guild.ModifyAsync(modifyAFK);

            foreach (IVoiceChannel VC in guild.GetVoiceChannelsAsync().Result)
            {
                await UpdateVC(VC);
            }
        }