Exemplo n.º 1
0
        public async Task GetNowPlaying(EventContext e)
        {
            int platform = -1;

            if (!string.IsNullOrWhiteSpace(e.arguments))
            {
                platform = GetPlatform(e.arguments);
            }

            Dictionary <int, RocketLeaguePlaylist> d = new Dictionary <int, RocketLeaguePlaylist>();

            if (platform == -1)
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (d.ContainsKey(p.Id))
                    {
                        d[p.Id].Population.Players += p.Population.Players;
                    }
                    else
                    {
                        RocketLeaguePlaylist playlist = new RocketLeaguePlaylist();
                        playlist.Id                 = p.Id;
                        playlist.Name               = p.Name;
                        playlist.PlatformId         = p.PlatformId;
                        playlist.Population         = new RocketLeaguePopulation();
                        playlist.Population.Players = p.Population.Players;

                        d.Add(p.Id, playlist);
                    }
                }
            }
            else
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (p.PlatformId == platform)
                    {
                        d.Add(p.Id, p);
                    }
                }
            }

            IDiscordEmbed embed = Utils.Embed;

            embed.Title = "Now Playing!";
            foreach (RocketLeaguePlaylist p in d.Values)
            {
                embed.AddField(f =>
                {
                    f.Name     = api.playlists.Data.Find(z => { return(z.Id == p.Id); }).Name;
                    f.Value    = p.Population.Players.ToString();
                    f.IsInline = true;
                });
            }

            await e.Channel.SendMessage(embed);
        }
Exemplo n.º 2
0
        public void GetNowPlaying(EventContext e)
        {
            int platform = -1;

            if (!string.IsNullOrWhiteSpace(e.arguments))
            {
                platform = GetPlatform(e.arguments);
            }

            Dictionary <int, RocketLeaguePlaylist> d = new Dictionary <int, RocketLeaguePlaylist>();

            if (platform == -1)
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (d.ContainsKey(p.Id))
                    {
                        d[p.Id].Population.Players += p.Population.Players;
                    }
                    else
                    {
                        RocketLeaguePlaylist playlist = new RocketLeaguePlaylist()
                        {
                            Id         = p.Id,
                            Name       = p.Name,
                            PlatformId = p.PlatformId,
                            Population = new RocketLeaguePopulation()
                            {
                                Players = p.Population.Players
                            }
                        };

                        d.Add(p.Id, playlist);
                    }
                }
            }
            else
            {
                foreach (RocketLeaguePlaylist p in api.playlists.Data)
                {
                    if (p.PlatformId == platform)
                    {
                        d.Add(p.Id, p);
                    }
                }
            }

            IDiscordEmbed embed = Utils.Embed;

            embed.Title = "Now Playing!";
            foreach (RocketLeaguePlaylist p in d.Values)
            {
                embed.AddField(api.playlists.Data.Find(z => { return(z.Id == p.Id); }).Name, p.Population.Players.ToString());
            }

            embed.QueueToChannel(e.Channel);
        }