示例#1
0
        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)));
        }
示例#2
0
        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());
        }
示例#3
0
        /// <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}");
            }
        }
示例#4
0
        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());
        }