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

            entity.Update(model);
            return(entity);
        }
Example #2
0
        public static async Task <IReadOnlyCollection <RestGroupChannel> > GetGroupChannelsAsync(BaseDiscordClient client, RequestOptions options)
        {
            var models = await client.ApiClient.GetMyPrivateChannelsAsync(options).ConfigureAwait(false);

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