Variable use in a function

I need to make a command where you can get an item based on a random generator. For me to dont have to write more than 100 if, I wanted to find a way to adress the database name with a variable. I tried a lot of methods but none of them worked.

await client.userdb.updateOne({
}, { $set: {
“fishes.(variable)”: currentfishes + 1

What I want to do is to make that (variable) is the name of the fish the person will receive, that will be randomized by an earlier part of the code.

Is there any way of making that?

I think that what you want is named computed property name.

It worked! Thank you so much :smiley:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.