internal new static RestGroupChannel Create(BaseDiscordClient discord, Model model) { var entity = new RestGroupChannel(discord, model.Id); entity.Update(model); return(entity); }
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()); }
/// <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}"); } }
/// <inheritdoc /> public Task LeaveAsync(RequestOptions options = null) => RestGroupChannel.LeaveAsync(options);
/// <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) { }
/// <inheritdoc /> public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => RestGroupChannel.DeleteMessageAsync(messageId, options);
/// <inheritdoc cref="RestGroupChannel.ToString" /> public override string ToString() => RestGroupChannel.ToString();
/// <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);
/// <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();
/// <inheritdoc /> public Task TriggerTypingAsync(RequestOptions options = null) => RestGroupChannel.TriggerTypingAsync(options);
/// <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();
/// <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();
/// <inheritdoc /> public IRestUser GetUser(ulong id) => RestGroupChannel.GetUser(id) ?.Abstract();
/// <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();
/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null) => (await RestGroupChannel.GetPinnedMessagesAsync(options)) .Select(RestMessageAbstractionExtensions.Abstract) .ToArray();
/// <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());
/// <inheritdoc /> public async Task <IRestMessage> GetMessageAsync(ulong id, RequestOptions options = null) => (await RestGroupChannel.GetMessageAsync(id, options)) ?.Abstract();
/// <inheritdoc /> public IDisposable EnterTypingState(RequestOptions options = null) => RestGroupChannel.EnterTypingState(options);
/// <inheritdoc /> public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) => RestGroupChannel.DeleteMessageAsync(message, options);
/// <inheritdoc /> public async Task <IRestUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null) => (IRestUserMessage)(await RestGroupChannel.ModifyMessageAsync(messageId, func, options)) .Abstract();
/// <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();