示例#1
0
        public async Task <IUserMessage> SendPaginatedComponentMessageAsync(
            SocketCommandContext context,
            PaginatedMessage pager,
            ICriterion <SocketInteraction> criterion = null)
        {
            var callback = new PaginatedComponentMessageCallback(this, context, pager, criterion);
            var options  = pager.Options;
            var timeout  = options.Timeout ?? DefaultTimeout;

            await callback.DisplayAsync().ConfigureAwait(false);

            var message = callback.Message;

            _ = Task.Delay(timeout).ContinueWith(_ =>
            {
                RemoveInteractionCallback(message.Id);

                if (options.ShouldDeleteOnTimeout)
                {
                    message.DeleteAsync();
                }
            });

            return(message);
        }
 public PaginatedMessageCallback(InteractiveService interactive, MummyContext sourceContext, PaginatedMessage pager, ICriterion <ReactionData> criterion = null)
 {
     Interactive = interactive;
     Context     = sourceContext;
     Criterion   = criterion ?? new EmptyCriterion <ReactionData>();
     _pager      = pager;
     pages       = _pager.Pages.Count;
 }
示例#3
0
        public Task <IUserMessage> PagedReplyAsync(IEnumerable <EmbedBuilder> pages, bool fromSourceUser = true)
        {
            PaginatedMessage pager = new PaginatedMessage
            {
                Pages = pages
            };

            return(PagedReplyAsync(pager, fromSourceUser));
        }
示例#4
0
        public async Task <IUserMessage> SendPaginatedMessageAsync(SocketCommandContext context,
                                                                   PaginatedMessage pager,
                                                                   ICriterion <SocketReaction> criterion = null)
        {
            var callback = new PaginatedMessageCallback(this, context, pager, criterion);
            await callback.DisplayAsync().ConfigureAwait(false);

            return(callback.Message);
        }
示例#5
0
        public Task <IUserMessage> PagedReplyAsync(PaginatedMessage pager, bool fromSourceUser = true)
        {
            Criteria <SocketReaction> criterion = new Criteria <SocketReaction>();

            if (fromSourceUser)
            {
                criterion.AddCriterion(new EnsureReactionFromSourceUserCriterion());
            }
            return(PagedReplyAsync(pager, criterion));
        }
示例#6
0
 public PaginatedMessageCallback(InteractiveService interactive,
                                 SocketCommandContext sourceContext,
                                 PaginatedMessage pager,
                                 ICriterion <SocketReaction> criterion = null)
 {
     Interactive = interactive;
     Context     = sourceContext;
     _criterion  = criterion ?? new EmptyCriterion <SocketReaction>();
     _pager      = pager;
     pages       = _pager.Pages.Count();
 }
 public PaginatedMessageCallback(InteractiveService interactive,
                                 SocketCommandContext sourceContext,
                                 PaginatedMessage pager,
                                 ICriterion <SocketReaction> criterion = null)
 {
     Interactive = interactive;
     Context     = sourceContext;
     _criterion  = criterion ?? new EmptyCriterion <SocketReaction>();
     _pager      = pager;
     pages       = _pager.Pages.Count();
     if (_pager.Pages is IEnumerable <EmbedFieldBuilder> )
     {
         pages = ((_pager.Pages.Count() - 1) / options.FieldsPerPage) + 1;
     }
 }
示例#8
0
        public async Task ListStaticsWithJobFilter([Remainder] string job)
        {
            var reply = new List <string>();

            reply.Add("");
            var files = Directory.GetFiles(Path.Combine(AppContext.BaseDirectory, $"statics/"));

            int i         = 0;
            int pageIndex = 0;

            foreach (var file in files)
            {
                ulong servId = Convert.ToUInt64(Path.GetFileNameWithoutExtension(file));

                var ps = PlayerStatic.Load(servId);
                if (ps.recruiting == true)
                {
                    if (ps.Filters.Contains(job.ToLower()))
                    {
                        if ((i % 10 == 0 && i != 1 && i != 0))
                        {
                            reply.Add($"{ps.PlayerStaticName}\n");
                            i++;
                            pageIndex++;
                        }
                        else
                        {
                            reply[pageIndex] += ps.PlayerStaticName + "\n";
                            i++;
                        }
                    }
                }
            }

            Console.WriteLine($"{files.Count()} files found");


            var message = new Discord.Addons.Interactive.PaginatedMessage();

            message.Title = $"{files.Count()} Statics";
            message.Color = new Color(250, 140, 73);
            message.Pages = reply;
            await PagedReplyAsync(reply);
        }
示例#9
0
        public PaginatedMessageCallback(InteractiveService interactive,
                                        SocketCommandContext sourceContext,
                                        PaginatedMessage pager,
                                        ICriterion <SocketReaction> criterion = null)
        {
            Interactive = interactive;
            Context     = sourceContext;
            Criterion   = criterion ?? new EmptyCriterion <SocketReaction>();
            _pager      = pager;

            pages = _pager.PageCount;
            if (pages == -1)
            {
                try
                {
                    pages = _pager.Fields.Max(x => x.Pages.Count());
                } catch { }
                try
                {
                    pages = pages > _pager.Pages.Count() ? pages : _pager.Pages.Count();
                } catch { }
            }
            _pager.PageCount = pages;
        }
示例#10
0
 public Task <IUserMessage> PagedReplyAsync(PaginatedMessage pager, ICriterion <SocketReaction> criterion)
 {
     return(Interactive.SendPaginatedMessageAsync(Context, pager, criterion));
 }