public static async Task <RestDMChannel> CreateDMChannelAsync(IUser user, BaseDiscordClient client, RequestOptions options) { CreateDMChannelParams args = new CreateDMChannelParams(user.Id); return(RestDMChannel.Create(client, await client.ApiClient.CreateDMChannelAsync(args, options).ConfigureAwait(false))); }
public static async Task <IReadOnlyCollection <RestDMChannel> > GetDMChannelsAsync(BaseDiscordClient client, RequestOptions options) { var models = await client.ApiClient.GetMyPrivateChannelsAsync(options).ConfigureAwait(false); return(models .Where(x => x.Type == ChannelType.DM) .Select(x => RestDMChannel.Create(client, x)).ToImmutableArray()); }
/// <exception cref="InvalidOperationException">Unexpected channel type.</exception> internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Model model) { switch (model.Type) { case ChannelType.DM: return(RestDMChannel.Create(discord, model)); case ChannelType.Group: return(RestGroupChannel.Create(discord, model)); default: throw new InvalidOperationException($"Unexpected channel type: {model.Type}"); } }
public static async Task <IReadOnlyCollection <IPrivateChannel> > GetPrivateChannelsAsync(BaseDiscordClient client) { var models = await client.ApiClient.GetMyPrivateChannelsAsync().ConfigureAwait(false); return(models.Select(x => RestDMChannel.Create(client, x)).ToImmutableArray()); }