Skip to content
Advertisement

How to use a SQL Result in Discord.JS SelectMenus?

I am trying to add Options to a SelectMenu from a SQL request. My code is the following:

My Console is giving me the following output:

There are no Errors. Still Discord doesn’t add it. It looks like this:

Discord View of the Select Menu

I have no clue, what i did wrong. Please help me out. Thanks in advance

Advertisement

Answer

When you fetch the data from sql, your code doesn’t wait for it. It instead continues on, and the callback function you provided in the query will only be executed once the query was completed. This is why you have the option of 2 Test but you don’t have the result options. One way to fix it would be to move all the code after the result into the callback function, then they would only be executed once the query was completed

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement