Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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}");
            }
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public Task TriggerTypingAsync(RequestOptions options = null)
 => RestDMChannel.TriggerTypingAsync(options);
Ejemplo n.º 4
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null)
 => (await RestDMChannel.SendMessageAsync(text, isTTS, embed, options, allowedMentions))
 .Abstract();
Ejemplo n.º 5
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null)
 => (await RestDMChannel.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions))
 .Abstract();
Ejemplo n.º 6
0
 /// <inheritdoc />
 public IRestUser GetUser(ulong id)
 => RestDMChannel.GetUser(id)
 ?.Abstract();
Ejemplo n.º 7
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null)
 => (await RestDMChannel.GetPinnedMessagesAsync(options))
 .Select(RestMessageAbstractionExtensions.Abstract)
 .ToArray();
Ejemplo n.º 8
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());
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructs a new <see cref="RestDMChannelAbstraction"/> around an existing <see cref="Rest.RestDMChannel"/>.
 /// </summary>
 /// <param name="restDMChannel">The value to use for <see cref="Rest.RestDMChannel"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restDMChannel"/>.</exception>
 public RestDMChannelAbstraction(RestDMChannel restDMChannel)
     : base(restDMChannel)
 {
 }
Ejemplo n.º 10
0
 /// <inheritdoc />
 public IDisposable EnterTypingState(RequestOptions options = null)
 => RestDMChannel.EnterTypingState(options);
Ejemplo n.º 11
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
 => RestDMChannel.DeleteMessageAsync(message, options);
Ejemplo n.º 12
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
 => RestDMChannel.DeleteMessageAsync(messageId, options);
Ejemplo n.º 13
0
 /// <inheritdoc />
 public Task CloseAsync(RequestOptions options = null)
 => RestDMChannel.CloseAsync(options);
Ejemplo n.º 14
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null)
 => (await RestDMChannel.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference))
 .Abstract();
Ejemplo n.º 15
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null)
 => (IRestUserMessage)(await RestDMChannel.ModifyMessageAsync(messageId, func, options))
 ?.Abstract();
Ejemplo n.º 16
0
 /// <inheritdoc cref="RestDMChannel.ToString()" />
 public override string ToString()
 => RestDMChannel.ToString();
Ejemplo n.º 17
0
 /// <summary>
 /// Converts an existing <see cref="RestDMChannel"/> to an abstracted <see cref="IRestDMChannel"/> value.
 /// </summary>
 /// <param name="restDMChannel">The existing <see cref="RestDMChannel"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restDMChannel"/>.</exception>
 /// <returns>An <see cref="IRestDMChannel"/> that abstracts <paramref name="restDMChannel"/>.</returns>
 public static IRestDMChannel Abstract(this RestDMChannel restDMChannel)
 => new RestDMChannelAbstraction(restDMChannel);
Ejemplo n.º 18
0
 /// <inheritdoc />
 public async Task <IRestMessage> GetMessageAsync(ulong id, RequestOptions options = null)
 => (await RestDMChannel.GetMessageAsync(id, options))
 ?.Abstract();
Ejemplo n.º 19
0
 /// <inheritdoc />
 public IAsyncEnumerable <IReadOnlyCollection <IRestMessage> > GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
 => RestDMChannel.GetMessagesAsync(fromMessage, dir, limit, options)
 .Select(x => x
         .Select(RestMessageAbstractionExtensions.Abstract)
         .ToArray());
Ejemplo n.º 20
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
 => (await RestDMChannel.SendFileAsync(filePath, text, isTTS, embed, options))
 .Abstract();