internal static RestVoiceRegion Create(BaseDiscordClient client, Model model) { RestVoiceRegion entity = new RestVoiceRegion(client, model.Id); entity.Update(model); return(entity); }
//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()); }
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)); }
/// <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);
/// <inheritdoc cref="RestVoiceRegion.ToString" /> public override string ToString() => RestVoiceRegion.ToString();
/// <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)); }
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()); }