Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 /// <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."),
     });
Ejemplo n.º 5
0
        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}");
            }
        }
Ejemplo n.º 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());
Ejemplo n.º 7
0
 /// <inheritdoc />
 public async Task <IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
 => (await SocketDMChannel.GetMessageAsync(id, options))
 ?.Abstract();
Ejemplo n.º 8
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
 => SocketDMChannel.GetCachedMessages(fromMessage, dir, limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Ejemplo n.º 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);
Ejemplo n.º 10
0
 /// <inheritdoc />
 public Task TriggerTypingAsync(RequestOptions options = null)
 => SocketDMChannel.TriggerTypingAsync(options);
Ejemplo n.º 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));
Ejemplo n.º 12
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
 => SocketDMChannel.DeleteMessageAsync(messageId, options);
Ejemplo n.º 13
0
 /// <inheritdoc />
 public Task CloseAsync(RequestOptions options = null)
 => SocketDMChannel.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)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketDMChannel.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions));
Ejemplo n.º 15
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null)
 => (await SocketDMChannel.GetPinnedMessagesAsync(options))
 .Select(RestMessageAbstractionExtensions.Abstract)
 .ToArray();
Ejemplo n.º 16
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
 => SocketDMChannel.DeleteMessageAsync(message, options);
Ejemplo n.º 17
0
 /// <inheritdoc />
 public async Task <IUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null)
 => (await SocketDMChannel.ModifyMessageAsync(messageId, func, options))
 ?.Abstract();
Ejemplo n.º 18
0
 /// <inheritdoc />
 public IDisposable EnterTypingState(RequestOptions options = null)
 => SocketDMChannel.EnterTypingState(options);
Ejemplo n.º 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));
Ejemplo n.º 20
0
 /// <inheritdoc />
 public ISocketMessage GetCachedMessage(ulong id)
 => SocketDMChannel.GetCachedMessage(id)
 ?.Abstract();
Ejemplo n.º 21
0
 /// <inheritdoc cref="SocketDMChannel.ToString" />
 public override string ToString()
 => SocketDMChannel.ToString();
Ejemplo n.º 22
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(int limit = 100)
 => SocketDMChannel.GetCachedMessages(limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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));