Beispiel #1
0
        public async Task <RestUserMessage> PrintStreams(ISocketMessageChannel channel)
        {
            Dictionary <string, List <string> > streams = new Dictionary <string, List <string> >();

            foreach (Stream stream in database.GetStreams())
            {
                if (!streams.ContainsKey(stream.Category.Title))
                {
                    streams.Add(stream.Category.Title, new List <string>());
                }

                streams[stream.Category.Title].Add($"{stream.Id}: [{stream.Title}]({stream.WebsiteUrl})");
            }

            List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>();

            foreach (var kvp in streams)
            {
                EmbedFieldBuilder builder = new EmbedFieldBuilder()
                {
                    Name = kvp.Key
                };
                StringBuilder sb = new StringBuilder();
                kvp.Value.ForEach(f => sb.AppendLine(f));
                fields.Add(builder.WithValue(sb.ToString()));
            }

            return(await channel.SendEmbedMessageAsync("Stream Player", "Please choose a stream to play:", Colors.BLACK, null, fields));
        }