0

I need to set the bank database for all server members as 10000 and here is my code

client.on('message', async message => {

  if (message.content === '#bank') {

    var guild = client.guilds.cache.get('644523866638647316');

    await db.set(`bank_${guild.member}`, 10000)

  }

})
theusaf
  • 1,781
  • 1
  • 9
  • 19
  • 1
    Hello, some extra information would be nice, such as what database library you are using **IE** the `db` variable, thanks! – abisammy Aug 24 '21 at 18:26

1 Answers1

0

A Guild contains a members property, which is a GuildMemberManager. You can loop through each member in this group using the following:

guild.members.cache.each((member) => {
  // you might want to use member.id, rather than just member here
  db.set(`bank_${member}`, 10000);
});
theusaf
  • 1,781
  • 1
  • 9
  • 19