Exemplo n.º 1
0
        public async Task Lookup(string channelName)
        {
            var stringBuilder = new StringBuilder();
            var response      = await _mixerManager.GetMixerChannelByChannelName(channelName);

            if (response != null)
            {
                stringBuilder.AppendLine($"Name: {response._User.Username}");
                stringBuilder.AppendLine($"View Count: {response.ViewersTotal}");
                stringBuilder.AppendLine($"Follower Count: {response.NumFollowers}");
            }
            else
            {
                stringBuilder.AppendLine("Sorry, a Mixer channel with that name does not exist.");
            }

            var builder = new EmbedBuilder();

            builder.Description = stringBuilder.ToString();

            await Context.Channel.SendMessageAsync("", false, builder.Build());
        }
Exemplo n.º 2
0
        public async Task List(Platform platform, string groupName)
        {
            var translation = await GetTranslation();

            var guildGroup = await _groupManager.GetGuildGroupByGuildIdAndName(Context.Guild.Id, groupName);

            if (guildGroup == null)
            {
                await Context.Channel.SendMessageAsync($"{translation.GroupCommands.InvalidGroupName} '{Prefix} group list'");
            }

            var guildGroupChannels = await _channelManager.GetChannelsByGuildGroupIdAndPlatform(guildGroup.Id, platform);

            var builder = new EmbedBuilder {
                Description = $"Your list of {platform} creators in the {groupName} group"
            };

            if (guildGroupChannels != null && guildGroupChannels.Count > 0)
            {
                switch (platform)
                {
                case Platform.Twitch:
                    var twitchUsers = new TwitchUserQueryResponse();
                    if (guildGroupChannels.Count == 1)
                    {
                        twitchUsers =
                            await _twitchManager.GetTwitchUserById(guildGroupChannels.FirstOrDefault()?.ChannelId);
                    }
                    else
                    {
                        twitchUsers =
                            await _twitchManager.GetTwitchUsersByIdsDelimitedList($"&id={string.Join("&id=", guildGroupChannels.Select(ggc => ggc.ChannelId))}");
                    }

                    if (twitchUsers != null && twitchUsers.Users.Count > 0)
                    {
                        builder.Fields.Add(new EmbedFieldBuilder
                        {
                            Name     = $"{platform} Creators",
                            Value    = string.Join(", ", twitchUsers.Users.Select(u => u.Login)),
                            IsInline = false
                        });
                    }
                    break;

                case Platform.Mixer:
                    var mixerCreatorList = new List <string>();
                    foreach (var creator in guildGroupChannels)
                    {
                        var mixerUser =
                            await _mixerManager.GetMixerChannelByChannelName(creator.ChannelId);

                        if (mixerUser != null)
                        {
                            mixerCreatorList.Add(mixerUser._User.Username);
                        }
                    }

                    builder.Fields.Add(new EmbedFieldBuilder
                    {
                        Name     = $"{platform} Creators",
                        Value    = string.Join(", ", mixerCreatorList),
                        IsInline = false
                    });
                    break;

                case Platform.YouTube:
                    var youTubeCreatorList = new List <string>();
                    foreach (var creator in guildGroupChannels)
                    {
                        var youtubeChannel =
                            await _youTubeManager.GetYouTubeChannelByChannelId(creator.ChannelId);

                        if (youtubeChannel != null)
                        {
                            youTubeCreatorList.Add(
                                $"{youtubeChannel.Items.FirstOrDefault()?.Snippet.Title} ({creator.ChannelId})");
                        }
                    }

                    builder.Fields.Add(new EmbedFieldBuilder
                    {
                        Name     = $"{platform} Creators",
                        Value    = string.Join(", ", youTubeCreatorList),
                        IsInline = false
                    });
                    break;
                }
            }
            else
            {
                builder.Fields.Add(new EmbedFieldBuilder
                {
                    Name     = $"{platform} Creators",
                    Value    = "Sorry, you have no creators listed.",
                    IsInline = false
                }
                                   );
            }

            await Context.Channel.SendMessageAsync("", false, builder.Build());
        }