Example #1
0
        internal static SocketGroupChannel Create(DiscordSocketClient discord, ClientState state, Model model)
        {
            var entity = new SocketGroupChannel(discord, model.Id);

            entity.Update(state, model);
            return(entity);
        }
Example #2
0
        internal static SocketGroupUser Create(SocketGroupChannel channel, ClientState state, Model model)
        {
            var entity = new SocketGroupUser(channel, channel.Discord.GetOrCreateUser(state, model));

            entity.Update(state, model);
            return(entity);
        }
Example #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."),
     });
Example #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}");
            }
        }
Example #6
0
 /// <inheritdoc />
 public IAsyncEnumerable <IReadOnlyCollection <IMessage> > GetMessagesAsync(IMessage fromMessage, Direction dir, int limit = 100, RequestOptions options = null)
 => SocketGroupChannel.GetMessagesAsync(fromMessage, dir, limit, options)
 .Select(x => x
         .Select(MessageAbstractionExtensions.Abstract)
         .ToArray());
Example #7
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketGroupChannel.SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions));
Example #8
0
 /// <summary>
 /// Constructs a new <see cref="SocketGroupChannelAbstraction"/> around an existing <see cref="WebSocket.SocketGroupChannel"/>.
 /// </summary>
 /// <param name="socketGroupChannel">The value to use for <see cref="WebSocket.SocketGroupChannel"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketGroupChannel"/>.</exception>
 public SocketGroupChannelAbstraction(SocketGroupChannel socketGroupChannel)
     : base(socketGroupChannel)
 {
 }
Example #9
0
 /// <inheritdoc cref="SocketGroupChannel.ToString" />
 public override string ToString()
 => SocketGroupChannel.ToString();
Example #10
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketGroupChannel.SendMessageAsync(text, isTTS, embed, options));
Example #11
0
 /// <inheritdoc />
 public Task LeaveAsync(RequestOptions options = null)
 => SocketGroupChannel.LeaveAsync(options);
Example #12
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null)
 => SocketGroupChannel.DeleteMessageAsync(messageId, options);
Example #13
0
 internal SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser globalUser)
     : base(channel.Discord, globalUser.Id)
 {
     Channel    = channel;
     GlobalUser = globalUser;
 }
Example #14
0
 public SocketGroupUser(SocketGroupChannel channel, SocketGlobalUser user)
     : base(channel, user)
 {
 }
Example #15
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestMessage> > GetPinnedMessagesAsync(RequestOptions options = null)
 => (await SocketGroupChannel.GetPinnedMessagesAsync(options))
 .Select(RestMessageAbstractionExtensions.Abstract)
 .ToArray();
Example #16
0
 /// <inheritdoc />
 new public ISocketGroupUser GetUser(ulong id)
 => SocketGroupChannel.GetUser(id)
 ?.Abstract();
Example #17
0
 /// <inheritdoc />
 public Task DeleteMessageAsync(IMessage message, RequestOptions options = null)
 => SocketGroupChannel.DeleteMessageAsync(message, options);
Example #18
0
 /// <inheritdoc />
 public async Task <IRestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false)
 => RestUserMessageAbstractionExtensions.Abstract(
     await SocketGroupChannel.SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler));
Example #19
0
 /// <inheritdoc />
 public IDisposable EnterTypingState(RequestOptions options = null)
 => SocketGroupChannel.EnterTypingState(options);
Example #20
0
 /// <inheritdoc />
 public Task TriggerTypingAsync(RequestOptions options = null)
 => SocketGroupChannel.TriggerTypingAsync(options);
Example #21
0
 /// <inheritdoc />
 public ISocketMessage GetCachedMessage(ulong id)
 => SocketGroupChannel.GetCachedMessage(id)
 ?.Abstract();
Example #22
0
 /// <summary>
 /// Converts an existing <see cref="SocketGroupChannel"/> to an abstracted <see cref="ISocketGroupChannel"/> value.
 /// </summary>
 /// <param name="socketGroupChannel">The existing <see cref="SocketGroupChannel"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketGroupChannel"/>.</exception>
 /// <returns>An <see cref="ISocketGroupChannel"/> that abstracts <paramref name="socketGroupChannel"/>.</returns>
 public static ISocketGroupChannel Abstract(this SocketGroupChannel socketGroupChannel)
 => new SocketGroupChannelAbstraction(socketGroupChannel);
Example #23
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(int limit = 100)
 => SocketGroupChannel.GetCachedMessages(limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Example #24
0
 /// <inheritdoc />
 public Task <IAudioClient> ConnectAsync()
 => SocketGroupChannel.ConnectAsync();
Example #25
0
 /// <inheritdoc />
 public IReadOnlyCollection <ISocketMessage> GetCachedMessages(IMessage fromMessage, Direction dir, int limit = 100)
 => SocketGroupChannel.GetCachedMessages(fromMessage, dir, limit)
 .Select(SocketMessageAbstractionExtensions.Abstract)
 .ToArray();
Example #26
0
 /// <inheritdoc />
 public async Task <IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
 => (await SocketGroupChannel.GetMessageAsync(id, options))
 .Abstract();
Example #27
0
 /// <inheritdoc />
 public async Task <IUserMessage> ModifyMessageAsync(ulong messageId, Action <MessageProperties> func, RequestOptions options = null)
 => (await SocketGroupChannel.ModifyMessageAsync(messageId, func, options))
 ?.Abstract();