#waiting before proceeding

16 messages · Page 1 of 1 (latest)

maiden charm
#

how would i make it so before my code proceeds further, it has to wait for 2 seconds, and only then goes to the next line?

torpid forumBOT
#
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
wary canyon
#

What do you want to make a delay for?

maiden charm
# wary canyon What do you want to make a delay for?

basically i need to extract a value from an embed field, but the embed takes a while to load in, so i want to make it wait like 2 seconds for the embed to load in, and only then take the value from it (because the embed adds a new value, which i need)

#

right now if im not waiting its saying it cant find the field

wary canyon
#

If it's an asynchronous method that is loading the embed, you should resolve the promise properly and then continue with your code

#

Setting an artificial timer does not magically fix promise resolution because it can take longer to resolve, and you would not be able to know ahead of time

maiden charm
# wary canyon If it's an asynchronous method that is loading the embed, you should resolve the...

i mean it is, but this is my embed code;

if (interaction.customId === 'approve') {
  if (interaction.member.roles.cache.hasAny(...allowedIDs)) {
    const originalEmbed = interaction.message.embeds[0];
    const approvedEmbed = new EmbedBuilder()
      .setColor('#2ecc71') // Change the color to green
      .setTitle('Award Request Approved') // Change the title
      .setDescription('The award request has been approved.') // Change the description
      .setFields(originalEmbed.fields) // Copy the fields from the original embed
      .addFields(
          {name: "Update approved by", value: `<@${interaction.member.id}>`},
                )
#

like my code is asynchronous

craggy turtle
#

What is async here? That looks rather synchronous

maiden charm
#

hold on ill send you my entire code so i'm not saying something that's not true lol

#

i-m talking about the approve if loop

maiden charm
#

if i put an await behind new that doesn't really fix it lol