Esempio n. 1
0
        public async Task DoPaginationAsync(IPaginationRequest request)
        {
            await ResetReactionsAsync(request).ConfigureAwait(false);

            this._requests.Add(request);
            try
            {
                var tcs = await request.GetTaskCompletionSourceAsync().ConfigureAwait(false);

                await tcs.Task.ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                this._client.Logger.LogError(InteractivityEvents.InteractivityPaginationError, ex, "Exception occurred while paginating");
            }
            finally
            {
                this._requests.TryRemove(request);
                try
                {
                    await request.DoCleanupAsync().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    this._client.Logger.LogError(InteractivityEvents.InteractivityPaginationError, ex, "Exception occurred while paginating");
                }
            }
        }
Esempio n. 2
0
        async Task PaginateAsync(IPaginationRequest p, DiscordEmoji emoji)
        {
            var emojis = await p.GetEmojisAsync();

            var msg = await p.GetMessageAsync();

            if (emoji == emojis.SkipLeft)
            {
                await p.SkipLeftAsync();
            }
            else if (emoji == emojis.Left)
            {
                await p.PreviousPageAsync();
            }
            else if (emoji == emojis.Right)
            {
                await p.NextPageAsync();
            }
            else if (emoji == emojis.SkipRight)
            {
                await p.SkipRightAsync();
            }
            else if (emoji == emojis.Stop)
            {
                var tcs = await p.GetTaskCompletionSourceAsync();

                tcs.TrySetResult(true);
                return;
            }

            var page = await p.GetPageAsync();

            await msg.ModifyAsync(page.Content, page.Embed);
        }
Esempio n. 3
0
        public async Task DoPaginationAsync(IPaginationRequest request)
        {
            await ResetReactionsAsync(request);

            this._requests.Add(request);
            try
            {
                var tcs = await request.GetTaskCompletionSourceAsync();

                await tcs.Task;
                await request.DoCleanupAsync();
            }
            catch (Exception ex)
            {
                this._client.DebugLogger.LogMessage(LogLevel.Error, "Interactivity",
                                                    $"Something went wrong with exception {ex.GetType().Name}.", DateTime.Now);
            }
            finally
            {
                this._requests.TryRemove(request);
            }
        }
Esempio n. 4
0
        async Task PaginateAsync(IPaginationRequest p, DiscordEmoji emoji)
        {
            var emojis = await p.GetEmojisAsync().ConfigureAwait(false);

            var msg = await p.GetMessageAsync().ConfigureAwait(false);

            if (emoji == emojis.SkipLeft)
            {
                await p.SkipLeftAsync().ConfigureAwait(false);
            }
            else if (emoji == emojis.Left)
            {
                await p.PreviousPageAsync().ConfigureAwait(false);
            }
            else if (emoji == emojis.Right)
            {
                await p.NextPageAsync().ConfigureAwait(false);
            }
            else if (emoji == emojis.SkipRight)
            {
                await p.SkipRightAsync().ConfigureAwait(false);
            }
            else if (emoji == emojis.Stop)
            {
                var tcs = await p.GetTaskCompletionSourceAsync().ConfigureAwait(false);

                tcs.TrySetResult(true);
                return;
            }

            var page = await p.GetPageAsync().ConfigureAwait(false);

            var builder = new DiscordMessageBuilder()
                          .WithContent(page.Content)
                          .WithEmbed(page.Embed);

            await builder.ModifyAsync(msg).ConfigureAwait(false);
        }