Exemple #1
0
        public async Task GetAlbumAsync(EduardoContext context, string searchAlbum)
        {
            SearchItem searchItem = await GetAsync(() => _spotify.SearchItemsAsync(searchAlbum, SearchType.Album));

            if (searchItem.Albums.Total == 0)
            {
                await context.Channel.SendMessageAsync($"No albums found from search term \"{searchAlbum}\"");
            }

            List <Embed> embeds = new List <Embed>();

            foreach (SimpleAlbum album in searchItem.Albums.Items)
            {
                embeds.Add(new EmbedBuilder()
                           .WithTitle(album.Name)
                           .WithColor(Color.DarkGreen)
                           .WithUrl(album.ExternalUrls["spotify"])
                           .WithImageUrl(album.Images.Count > 0 ? album.Images[0].Url : "")
                           .AddField("Album Type", album.AlbumType)
                           .AddField("Released", album.ReleaseDate)
                           .Build());
            }

            await context.SendMessageOrPaginatedAsync(embeds);
        }
Exemple #2
0
        public async Task GetSongAsync(EduardoContext context, string searchSong)
        {
            SearchItem searchItem = await GetAsync(() => _spotify.SearchItemsAsync(searchSong, SearchType.Track));

            if (searchItem.Tracks.Total == 0)
            {
                await context.Channel.SendMessageAsync($"No songs found from search term \"{searchSong}\"");
            }

            List <Embed> embeds = new List <Embed>();

            foreach (FullTrack track in searchItem.Tracks.Items)
            {
                embeds.Add(new EmbedBuilder()
                           .WithTitle(track.Name)
                           .WithColor(Color.DarkGreen)
                           .WithUrl(track.ExternUrls["spotify"])
                           .WithImageUrl(track.Album.Images.Count > 0 ? track.Album.Images[0].Url : "")
                           .AddField("Duration", TimeSpan.FromMilliseconds(track.DurationMs).ToString(@"mm\:ss"))
                           .AddField("Album", $"{track.Album.Name} - {track.Album.AlbumType}")
                           .AddField("Released", track.Album.ReleaseDate)
                           .AddField("Explcit", track.Explicit ? "Yes": "No")
                           .Build());
            }

            await context.SendMessageOrPaginatedAsync(embeds);
        }
Exemple #3
0
        public async Task GetMatches(EduardoContext context, string username, PubgPlatform platform)
        {
            PubgPlayer player = await GetPlayerFromApiAsync(username, platform);

            if (player == null)
            {
                await context.Channel.SendMessageAsync($"No player found with username \"{username}\"");

                return;
            }

            List <Embed> embeds = new List <Embed>();

            foreach (string matchId in player.MatchIds.Take(_pubgData.MaxMatches))
            {
                PubgMatch match = await GetMatchFromApiAsync(matchId, platform);

                TimeSpan        matchDuration = TimeSpan.FromSeconds(match.Duration);
                PubgRoster      roster        = match.Rosters.FirstOrDefault(r => r.Participants.Any(p => p.Stats.PlayerId == player.Id));
                PubgParticipant participant   = match.Rosters.SelectMany(r => r.Participants).FirstOrDefault(p => p.Stats.PlayerId == player.Id);
                TimeSpan        timeSurvived  = TimeSpan.FromSeconds(participant?.Stats.TimeSurvived ?? 0);

                embeds.Add(new EmbedBuilder()
                           .WithTitle(match.GameMode.ToString())
                           .WithColor(Color.Orange)
                           .AddField("Started", DateTime.Parse(match.CreatedAt), true)
                           .AddField("Duration", $"{matchDuration.Minutes:D2}m {matchDuration.Seconds:D2}s", true)
                           .AddField("Player Count", match.Rosters.Count(), true)
                           .AddField("Placement", roster != null
                        ? $"#{roster.Stats.Rank}"
                        : "Unknown", true)
                           .AddConditionalField("Death Reason", participant?.Stats.DeathType.ToString() ?? "Unknown",
                                                participant != null && participant.Stats.DeathType == PubgParticipantDeathType.Alive, true)
                           .AddField("Kills", participant?.Stats.Kills.ToString() ?? "Unknown", true)
                           .AddField("Damage Dealt", participant != null
                        ? Math.Round(participant.Stats.DamageDealt, 2).ToString(CultureInfo.InvariantCulture)
                        : "Unknown", true)
                           .AddField("Headshot %", participant != null
                        ? participant.Stats.Kills > 0
                            ? (participant.Stats.HeadshotKills / participant.Stats.Kills * 100).ToString()
                            : "0%"
                        : "Unknown", true)
                           .AddField("Time Survived", participant != null
                        ? $"{timeSurvived.Minutes:D2}m {timeSurvived.Seconds:D2}s"
                        : "Unknown", true)
                           .AddField("Distance Travelled", participant != null
                        ? Math.Round(participant.Stats.RideDistance + participant.Stats.WalkDistance, 2).ToString(CultureInfo.InvariantCulture)
                        : "Unknown", true)
                           .AddField("DBNOs", participant?.Stats.DBNOs.ToString() ?? "Unknown", true)
                           .AddField("Heals Used", participant?.Stats.Heals.ToString() ?? "Unknown", true)
                           .AddField("Boosts Used", participant?.Stats.Boosts.ToString() ?? "Unknown", true)
                           .WithFooter($"Match Data for {participant?.Stats.Name ?? "Unknown"} for match {matchId}",
                                       "https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5dt5ZoFC4oMbrTPSSvVHVfyGSakHWV_1680x8400")
                           .Build());
            }

            await context.SendMessageOrPaginatedAsync(embeds);
        }
Exemple #4
0
        public async Task GetPlaylist(EduardoContext context, string searchPlaylist)
        {
            SearchItem searchItem = await GetAsync(() => _spotify.SearchItemsAsync(searchPlaylist, SearchType.Playlist));

            if (searchItem.Playlists.Total == 0)
            {
                await context.Channel.SendMessageAsync($"No playlists found from search term \"{searchPlaylist}\"");
            }

            List <Embed> embeds = new List <Embed>();

            foreach (SimplePlaylist playlist in searchItem.Playlists.Items)
            {
                embeds.Add(new EmbedBuilder()
                           .Build());
            }

            await context.SendMessageOrPaginatedAsync(embeds);
        }
Exemple #5
0
        public async Task ShowPokemonInventoryAsync(EduardoContext context)
        {
            Dictionary <PokemonSummary, int> pokemonInventory = await _pokemonRepository.GetPokemonAsync((long)context.Message.Author.Id,
                                                                                                         (long)((context.Message.Channel as SocketGuildChannel)?.Guild.Id ?? 0));

            if (pokemonInventory.Count > 0)
            {
                List <Embed> pageEmbeds = new List <Embed>();

                for (int i = 0; i < pokemonInventory.Count; i += _pokemonData.MaxPokemonPerPage)
                {
                    List <KeyValuePair <PokemonSummary, int> > pokemonPage = pokemonInventory
                                                                             .Skip(i)
                                                                             .Take(Math.Min(_pokemonData.MaxPokemonPerPage, pokemonInventory.Count - i)).ToList();

                    pageEmbeds.Add(new EmbedBuilder()
                                   .WithColor(new Color(255, 255, 0))
                                   .WithAuthor($"{context.User.Username}'s Pokemon",
                                               context.User.GetAvatarUrl())
                                   .WithFieldsForList(pokemonPage, x => x.Key.Name.UpperFirstChar(), x => x.Value)
                                   .WithFooter($"Page {i / _pokemonData.MaxPokemonPerPage + 1} of {Math.Ceiling(pokemonInventory.Count / (double)_pokemonData.MaxPokemonPerPage)} | Pokemon via pokeapi.co",
                                               @"https://maxcdn.icons8.com/Share/icon/color/Gaming/pokeball1600.png")
                                   .Build());
                }

                await context.SendMessageOrPaginatedAsync(new PaginatedMessage
                {
                    Embeds           = pageEmbeds,
                    Timeout          = TimeSpan.FromSeconds(Constants.PAGINATION_TIMEOUT_SECONDS),
                    TimeoutBehaviour = TimeoutBehaviour.Delete
                });
            }
            else
            {
                await context.Channel.SendMessageAsync($"{context.User.Mention} You don't have any Pokemon! Use `{Constants.CMD_PREFIX}pokemon` to find a wild Pokemon!");
            }
        }
Exemple #6
0
        public async Task GetArtistAsync(EduardoContext context, string searchArtist)
        {
            SearchItem searchItem = await GetAsync(() => _spotify.SearchItemsAsync(searchArtist, SearchType.Artist));

            if (searchItem.Artists.Total == 0)
            {
                await context.Channel.SendMessageAsync($"No artists found from search term \"{searchArtist}\"");
            }

            List <Embed> embeds = new List <Embed>();

            foreach (FullArtist artist in searchItem.Artists.Items)
            {
                embeds.Add(new EmbedBuilder()
                           .WithTitle(artist.Name)
                           .WithColor(Color.DarkGreen)
                           .WithUrl(artist.ExternalUrls["spotify"])
                           .WithImageUrl(artist.Images.Count > 0 ? artist.Images[0].Url : "")
                           .AddField("Followers", artist.Followers.Total)
                           .Build());
            }

            await context.SendMessageOrPaginatedAsync(embeds);
        }