Beispiel #1
0
        public async Task Preview(ISocketMessageChannel channel)
        {
            AudioService audioService = (AudioService)Program._services.GetService(typeof(AudioService));
            AudioModule  am           = new AudioModule(audioService, (SocketCommandContext)audioService.Context);

            try { await am.Music1(); }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            EmbedBuilder e = new EmbedBuilder();

            ch = channel;
            int    id         = 1;
            int    SimpleID   = 0;
            int    MultipleID = 0;
            string stock      = string.Empty;

            foreach (var q in questions)
            {
                if (q.type == QType.text)
                {
                    // problème sûr à 100% avec async await
                    e.Title = "Aperçu du QCM : " + name;
                    e.Color = Color.DarkBlue;
                    var eb = (EmbedBuilder)q.content;
                    e.AddField("Question " + id, q.name + " | " + q.type + " | " + eb.Title);
                    //if (q.type == QType.text)
                    //await channel.SendMessageAsync("", false,(EmbedBuilder) q.content);
                }
                else if (q.type == QType.image)
                {
                    Console.WriteLine();
                    // Images multiples
                    List <EmbedBuilder> eb = (List <EmbedBuilder>)q.content;
                    if (q.imageQuestion == ImageQuestion.CorrespondingImageMultiple)
                    {
                        e.AddField("Multiple IMG " + id, q.name + " | " + ebListMultiple[MultipleID].Title);
                        MultipleID++;
                    }
                    // Image unique
                    else
                    {
                        e.AddField("Unique IMG " + id, ebListSimple[SimpleID].Description + " | " + ebListSimple[SimpleID].Title);
                        SimpleID++;
                    }
                }
                else
                {
                    e.AddField("Type non géré par le système de prévisualisation: ", q.type);
                }
                id++;
            }
            await channel.SendMessageAsync("", false, e);

            foreach (var field in e.Fields)
            {
                Console.WriteLine(field.Name + " : " + field.Value);
            }
        }