How to use array from quick.db base Discord.js

Good day. I decided to make a server blacklist, but I ran into a problem that I can’t ban everyone who is in the array

const asn = db.get(`abig_${message.guild.id}`) asn.forEach(element => { console.log(element) })

How can I make it so that I can ban everyone who is in the database?

im not skilled with discord.js (i dont know it), but from my research, you would do asn.ban(); (this is probably only for one user, so i guess you would find a way to get one user at a time and ban them).

someone please correct me if im wrong.

I also thought so, but the bot cannot get an array, and to use it, it writes that “asn.forEach is not a function”

what database are you using? (i could maybe find better answers if i know it)

I am using quick.db

The “forEach is not a function” error occurs when we call the forEach() method on a value that is not of type array, Map , or Set . To solve the error, make sure to only call the forEach method on arrays, Map or Set objects.

i guess you aren’t declaring an array. maybe first get the database info and then put it in an array. and then do the bans? see here if you don’t know how to make arrays.

The array is already in the database, but for some reason I can’t use it

I tried to create an array andassive in a piecemeal way, but without success

To force something into an array (may not work the way you’d think it would) use

Array.from(obj)

Example:

Array.from(document.getElementsByTagName("div")).forEach(el => el.style.backgroundColor = "grey");
1 Like

what type does quick.db return?