#Parsing all embeds

1 messages · Page 1 of 1 (latest)

potent valley
#

yes?

#

are u having issues or asking someone to code it for u

ocean gull
#

i have issue like
I getting all embeds by var original = button.Message.Embeds.First();
and after i build other embed
and updating button x.Embeds = new[] { original, embed };
But question is how can i add new embed to embeds

potent valley
#

sorry mate im confused

#

are u asking how do u edit a message?

ocean gull
#

i will show example

potent valley
#

kk

ocean gull
#

like here is original embed

#

after clicking button Gather it will create new embed and add to this message with parameter x.Embeds = new[] { original, embed };

#

like this

#

and i wanna if next who clicked this message will add to end of embeds

potent valley
#

ModifyAsync(x => x.Embeds = new Embed[] { (Embed)original, newEmbed.Build() });

#

do u mean something like that

ocean gull
#

let me check

#

hmm that seems the same

#

but i wanna after other click there will be originalEmbed, embed that someone clicked and new embed who clicked, and this can be maximum 9 embeds + original

potent valley
#

sadly im confused then

lean aurora
#

Well
Are you using Iteraction Framework?

ocean gull
#

no

#

or what you mean about interaction framework?

lean aurora
#

InteractionService

#

Do you have
[SlashCommand()] attribute somewhere in code?

ocean gull
#

no

lean aurora
#

Ok

#

So

#

If I understand what you wanna do correctly

ocean gull
#

i wanna add new embed after original embed everytime someone pressing the button

lean aurora
#

i think something like this might work
var List<Embed> embeds = interaction.Message.Embeds get the list of existing embeds

Check if it has <10 embeds - if(embeds.Length <10)

Then just embeds.Add() new embed to it
And then update the message with interaction.UpdateAsync(x => x.Embeds = embeds)

(interaction it a component interaction you get as a parameter in ButtonExecuted event)

ocean gull
#

thank you i will try

#

cannot convert "System.Collections.Generic.List<Discord.Embed>" to "Discord.Optional<Discord.Embed[]>".

lean aurora
#

Ahhh
Yup, forgot about that

#

One sec

ocean gull
#

sure, thank you

lean aurora
#

Ah, ye
x.Embeds = embeds.ToArray()

#

This should solve fix error

ocean gull
#

let me check

#
System.InvalidCastException: Unable to cast object of type 'System.Collections.Immutable.ImmutableArray`1[Discord.Embed]' to type 'System.Collections.Generic.List`1[Discord.Embed]'.
#

on this line List<Embed> embeds = (List<Embed>)button.Message.Embeds;

#

its fixed

#

var embeds = button.Message.Embeds.ToList();

#

after i use embeds.Add(new embed) and update it by using x.Embeds = embeds.ToArray();

lean aurora
#

Ah
Yup
That too
Sorry, wrote that on discord
My in-brain compiler didn't catch that issue