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}"); } }
/// <inheritdoc /> public Task TriggerTypingAsync(RequestOptions options = null) => RestDMChannel.TriggerTypingAsync(options);
/// <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();
/// <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();
/// <inheritdoc /> public IRestUser GetUser(ulong id) => RestDMChannel.GetUser(id) ?.Abstract();
/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null) => (await RestDMChannel.GetPinnedMessagesAsync(options)) .Select(RestMessageAbstractionExtensions.Abstract) .ToArray();
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()); }
/// <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) { }
/// <inheritdoc /> public IDisposable EnterTypingState(RequestOptions options = null) => RestDMChannel.EnterTypingState(options);
/// <inheritdoc /> public Task DeleteMessageAsync(IMessage message, RequestOptions options = null) => RestDMChannel.DeleteMessageAsync(message, options);
/// <inheritdoc /> public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => RestDMChannel.DeleteMessageAsync(messageId, options);
/// <inheritdoc /> public Task CloseAsync(RequestOptions options = null) => RestDMChannel.CloseAsync(options);
/// <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();
/// <inheritdoc /> public async Task <IRestUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null) => (IRestUserMessage)(await RestDMChannel.ModifyMessageAsync(messageId, func, options)) ?.Abstract();
/// <inheritdoc cref="RestDMChannel.ToString()" /> public override string ToString() => RestDMChannel.ToString();
/// <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);
/// <inheritdoc /> public async Task <IRestMessage> GetMessageAsync(ulong id, RequestOptions options = null) => (await RestDMChannel.GetMessageAsync(id, options)) ?.Abstract();
/// <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());
/// <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();