예제 #1
0
        public async Task GetReflink(string exchange = null)
        {
            var exchanges = await _refExchangeRepository.GetRefExchanges(exchange);

            if (exchanges.Count == 0)
            {
                await ReplyAsync($"Could not find any reflinks"); return;
            }

            if (exchanges.Count >= 2)
            {
                var emotes = Context.Guild.Emotes;
                var sent   = await ReplyAsync(null, false, _embedService.CreateReactMessage(exchanges, emotes).Build());

                await sent.AddReactionsAsync(emotes.Join(exchanges, em => em.Id, ex => ex.EmojiId, (em, ex) => em).ToArray());

                return;
            }

            var links = exchanges.SelectMany(x => x.Reflinks);

            var random = new Random();
            var index  = random.Next(links.Count());

            var luckyLink = links.ElementAt(index);

            await ReplyAsync($"<{luckyLink.Link}>");
        }