private void Client_OnJoinedChannel(object sender, OnJoinedChannelArgs e) { logger.Log("Hey guys! I am a bot connected via TwitchLib!"); Task.Factory.StartNew(() => { logger.Log($"Loading subscriber badges for channel {e.Channel}"); var userList = twitchAPI.V5.Users.GetUserByNameAsync(e.Channel).Result; string userId = userList.Matches[0].Id; ChannelDisplayBadges channelDisplayBadges = twitchAPI.V5.Badges.GetSubscriberBadgesForChannelAsync(userId).Result; this.badgeConverter.ConvertChannelBadges(e.Channel, channelDisplayBadges); }); //client.SendMessage(e.Channel, "Hey guys! I am a bot connected via TwitchLib!"); }
public void ConvertChannelBadges(string channel, ChannelDisplayBadges channelDisplayBadges) { if (channelDisplayBadges == null) { return; } if (channelDisplayBadges?.Sets?.Subscriber?.Versions != null) { foreach (KeyValuePair <string, BadgeContent> versionBadgeContent in channelDisplayBadges.Sets.Subscriber.Versions) { this.badgeCache.AddBadge($"{channel}_subscriber_{versionBadgeContent.Key}", versionBadgeContent.Value.Title, versionBadgeContent.Value.Image_Url_1x); } } if (channelDisplayBadges?.Sets?.Bits?.Versions != null) { foreach (KeyValuePair <string, BadgeContent> versionBadgeContent in channelDisplayBadges.Sets.Bits.Versions) { this.badgeCache.AddBadge($"{channel}_bits_{versionBadgeContent.Key}", versionBadgeContent.Value.Title, versionBadgeContent.Value.Image_Url_1x); } } }