Exemple #1
0
        internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, Model model)
        {
            var entity = new SocketDMChannel(discord, model.Id, discord.GetOrCreateTemporaryUser(state, model.Recipients.Value[0]));

            entity.Update(state, model);
            return(entity);
        }
Exemple #2
0
        internal static SocketDMChannel Create(DiscordSocketClient discord, ClientState state, ulong channelId, API.User recipient)
        {
            var entity = new SocketDMChannel(discord, channelId, discord.GetOrCreateTemporaryUser(state, recipient));

            entity.Update(state, recipient);
            return(entity);
        }
 /// <exception cref="InvalidOperationException">Unexpected channel type is created.</exception>
 internal static ISocketPrivateChannel CreatePrivate(DiscordSocketClient discord, ClientState state, Model model)
 {
     return(model.Type switch
     {
         ChannelType.DM => SocketDMChannel.Create(discord, state, model),
         ChannelType.Group => SocketGroupChannel.Create(discord, state, model),
         _ => throw new InvalidOperationException($"Unexpected channel type: {model.Type}"),
     });
 /// <exception cref="NotSupportedException">Unexpected <see cref="ISocketMessageChannel"/> type.</exception>
 public static SocketMessage RemoveMessage(ISocketMessageChannel channel, DiscordSocketClient discord,
                                           ulong id)
 {
     return(channel switch
     {
         SocketDMChannel dmChannel => dmChannel.RemoveMessage(id),
         SocketGroupChannel groupChannel => groupChannel.RemoveMessage(id),
         SocketTextChannel textChannel => textChannel.RemoveMessage(id),
         _ => throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type."),
     });
        internal static ISocketPrivateChannel CreatePrivate(DiscordSocketClient discord, ClientState state, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.DM:
                return(SocketDMChannel.Create(discord, state, model));

            case ChannelType.Group:
                return(SocketGroupChannel.Create(discord, state, model));

            default:
                throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
            }
        }
Exemple #6
0
 /// <inheritdoc />
 public IAsyncEnumerable <IReadOnlyCollection <IMessage> > GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
 => SocketDMChannel.GetMessagesAsync(fromMessage, dir, limit, options)
 .Select(x => x
         .Select(MessageAbstractionExtensions.Abstract)
         .ToArray());
Exemple #7
0
 /// <inheritdoc />
 public async Task <IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
 => (await SocketDMChannel.GetMessageAsync(id, options))
 ?.Abstract();
Exemple #8
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
 => SocketDMChannel.GetCachedMessages(fromMessage, dir, limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Exemple #9
0
 /// <summary>
 /// Converts an existing <see cref="SocketDMChannel"/> to an abstracted <see cref="ISocketDMChannel"/> value.
 /// </summary>
 /// <param name="socketDMChannel">The existing <see cref="SocketDMChannel"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketDMChannel"/>.</exception>
 /// <returns>An <see cref="ISocketDMChannel"/> that abstracts <paramref name="socketDMChannel"/>.</returns>
 public static ISocketDMChannel Abstract(this SocketDMChannel socketDMChannel)
 => new SocketDMChannelAbstraction(socketDMChannel);
Exemple #10
0
 /// <inheritdoc />
 public Task TriggerTypingAsync(RequestOptions options = null)
 => SocketDMChannel.TriggerTypingAsync(options);
Exemple #11
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)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketDMChannel.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference));
Exemple #12
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
 => SocketDMChannel.DeleteMessageAsync(messageId, options);
Exemple #13
0
 /// <inheritdoc />
 public Task CloseAsync(RequestOptions options = null)
 => SocketDMChannel.CloseAsync(options);
Exemple #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)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketDMChannel.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions));
Exemple #15
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null)
 => (await SocketDMChannel.GetPinnedMessagesAsync(options))
 .Select(RestMessageAbstractionExtensions.Abstract)
 .ToArray();
Exemple #16
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
 => SocketDMChannel.DeleteMessageAsync(message, options);
Exemple #17
0
 /// <inheritdoc />
 public async Task <IUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null)
 => (await SocketDMChannel.ModifyMessageAsync(messageId, func, options))
 ?.Abstract();
Exemple #18
0
 /// <inheritdoc />
 public IDisposable EnterTypingState(RequestOptions options = null)
 => SocketDMChannel.EnterTypingState(options);
Exemple #19
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)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketDMChannel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference));
Exemple #20
0
 /// <inheritdoc />
 public ISocketMessage GetCachedMessage(ulong id)
 => SocketDMChannel.GetCachedMessage(id)
 ?.Abstract();
Exemple #21
0
 /// <inheritdoc cref="SocketDMChannel.ToString" />
 public override string ToString()
 => SocketDMChannel.ToString();
Exemple #22
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(int limit = 100)
 => SocketDMChannel.GetCachedMessages(limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Exemple #23
0
 /// <summary>
 /// Constructs a new <see cref="SocketDMChannelAbstraction"/> around an existing <see cref="WebSocket.SocketDMChannel"/>.
 /// </summary>
 /// <param name="socketDMChannel">The value to use for <see cref="WebSocket.SocketDMChannel"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketDMChannel"/>.</exception>
 public SocketDMChannelAbstraction(SocketDMChannel socketDMChannel)
     : base(socketDMChannel)
 {
 }
Exemple #24
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketDMChannel.SendFileAsync(stream, filename, text, isTTS, embed, options));