'discord js permissions to execute command positions

      if (
    !message.member.roles.cache.some(
      (role) =>
        role.id === doc1.lady.cargo1 ||
        role.id === doc1.lady.cargo2 ||
        role.id === doc1.lady.cargo3 ||
        role.id === doc1.lady.cargo4 ||
        role.id === doc1.lady.cargo5 ||
        role.id === doc1.lady.cargo6
    )
  )
    return message.reply(
      `${message.author}, você não tem permissão para executar esse comando`
    );

db = cargo1 : "951689717139791922"

even though I have one of the positions mentioned, it turns out that I am without permission



Solution 1:[1]

You can try this, it should work.

const filter = [doc1.lady.cargo1, doc1.lady.cargo2, doc1.lady.cargo3, doc1.lady.cargo4, doc1.lady.cargo5, doc1.lady.cargo6];

if (message.member.roles.cache.filter(r => !filter.includes(r.id)).size == 0)
    return message.reply(
      `${message.author}, você não tem permissão para executar esse comando`
    );

Also instead of define each time the value with +1

You can make this

const filter = ['id1', 'id2', 'id3'];
if (message.member.roles.cache.filter(r => !filter.includes(r.id)).size == 0)
    return message.reply(
      `${message.author}, você não tem permissão para executar esse comando`
    );

Solution 2:[2]

Use Collection#hasAny()

if (!message.member.roles.cache.hasAny(...Object.values(doc1.lady))) return message.reply(`...`)

.hasAny() takes any rest parameter, like .hasAny(roleId1, roleId2, roleId3) or even .hasAny(...arrayOfRoleIds)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 MrMythical