Example #1
0
        internal static RestVoiceRegion Create(BaseDiscordClient client, Model model)
        {
            RestVoiceRegion entity = new RestVoiceRegion(client, model.Id);

            entity.Update(model);
            return(entity);
        }
Example #2
0
        //Voice Regions
        public static async Task <IReadOnlyCollection <RestVoiceRegion> > GetVoiceRegionsAsync(IGuild guild, BaseDiscordClient client,
                                                                                               RequestOptions options)
        {
            var models = await client.ApiClient.GetGuildVoiceRegionsAsync(guild.Id, options).ConfigureAwait(false);

            return(models.Select(x => RestVoiceRegion.Create(client, x)).ToImmutableArray());
        }
Example #3
0
        public static async Task <RestVoiceRegion> GetVoiceRegionAsync(BaseDiscordClient client,
                                                                       string id, RequestOptions options)
        {
            var models = await client.ApiClient.GetVoiceRegionsAsync(options).ConfigureAwait(false);

            return(models.Select(x => RestVoiceRegion.Create(client, x)).FirstOrDefault(x => x.Id == id));
        }
Example #4
0
 /// <summary>
 /// Converts an existing <see cref="RestVoiceRegion"/> to an abstracted <see cref="IRestVoiceRegion"/> value.
 /// </summary>
 /// <param name="restVoiceRegion">The existing <see cref="RestVoiceRegion"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restVoiceRegion"/>.</exception>
 /// <returns>An <see cref="IRestVoiceRegion"/> that abstracts <paramref name="restVoiceRegion"/>.</returns>
 public static IRestVoiceRegion Abstract(this RestVoiceRegion restVoiceRegion)
 => new RestVoiceRegionAbstraction(restVoiceRegion);
Example #5
0
 /// <inheritdoc cref="RestVoiceRegion.ToString" />
 public override string ToString()
 => RestVoiceRegion.ToString();
Example #6
0
 /// <summary>
 /// Constructs a new <see cref="RestVoiceRegionAbstraction"/> around an existing <see cref="Rest.RestVoiceRegion"/>.
 /// </summary>
 /// <param name="restVoiceRegion">The value to use for <see cref="Rest.RestVoiceRegion"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restVoiceRegion"/>.</exception>
 public RestVoiceRegionAbstraction(RestVoiceRegion restVoiceRegion)
 {
     RestVoiceRegion = restVoiceRegion ?? throw new ArgumentNullException(nameof(restVoiceRegion));
 }
Example #7
0
        public static async Task <IReadOnlyCollection <RestVoiceRegion> > GetVoiceRegionsAsync(BaseDiscordClient client)
        {
            var models = await client.ApiClient.GetVoiceRegionsAsync().ConfigureAwait(false);

            return(models.Select(x => RestVoiceRegion.Create(client, x)).ToImmutableArray());
        }