Esempio n. 1
0
        private async Task Client_MessageReactionAddedAsync(DiscordClient client, MessageReactionAddEventArgs e)
        {
            if (e.User.IsBot || !await _paginationService.IsPaginationSetAsync(e.Message))
            {
                return;
            }

            var paginationData = await _paginationService.GetPaginationDataForMessageAsync(e.Message);

            if (_allowedPaginationTypes.Contains(paginationData.ContentType))
            {
                var items = await GetLaunchesAsync(paginationData.ContentType, paginationData.Parameter);

                if (items != null)
                {
                    var editedMessage = e.Message;

                    if (await _paginationService.DoActionAsync(editedMessage, e.Emoji, items.Count))
                    {
                        var updatedPaginationData = await _paginationService.GetPaginationDataForMessageAsync(editedMessage);

                        var launchesList = BuildTableWithPagination(items, updatedPaginationData.ContentType, updatedPaginationData.CurrentPage);

                        editedMessage = await editedMessage.ModifyAsync(launchesList);
                    }

                    await _paginationService.DeleteReactionAsync(editedMessage, e.User, e.Emoji);
                }
            }
        }
Esempio n. 2
0
        private async Task ClientOnMessageReactionAddedAsync(DiscordClient client, MessageReactionAddEventArgs e)
        {
            if (e.User.IsBot || !await _paginationService.IsPaginationSetAsync(e.Message))
            {
                return;
            }

            var paginationData = await _paginationService.GetPaginationDataForMessageAsync(e.Message);

            if (_allowedPaginationTypes.Contains(paginationData.ContentType))
            {
                var items = await _cacheService.GetAsync <List <CoreInfo> >(CacheContentType.Cores);

                var editedMessage = e.Message;

                if (await _paginationService.DoActionAsync(editedMessage, e.Emoji, items.Count))
                {
                    var updatedPaginationData = await _paginationService.GetPaginationDataForMessageAsync(editedMessage);

                    var tableWithPagination = BuildTableWithPagination(items, updatedPaginationData.CurrentPage);

                    editedMessage = await editedMessage.ModifyAsync(tableWithPagination);
                }

                await _paginationService.DeleteReactionAsync(editedMessage, e.User, e.Emoji);
            }
        }