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