Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
Map number counting
let adminMap = new Map()
async function orionCheck(interaction, adminMap) {
    const guild = await client.guilds.fetch(General.SERVER.ID)
    const members = await guild.members.fetch()
    var memberList = [];
    members.forEach(member => memberList.push(member.user.id));
    for (let i = 0; i < memberList.length; i++) {
        if (members.get(memberList[i]).roles.highest.permissions.has("ADMINISTRATOR")) adminMap.set(members.get(memberList[i]).user.id, {BPM: 0, KPM: 0}) //console.log(members.get(memberList[i]).user.id)
    }

    var orionObjects = {
        banObject: ["API/Orion Objects/OrionData.json", "Ban", "BPM", adminMap.get(interaction.user.id).BPM],
        kickObject: ["API/Orion Objects/Kickbject.syrex", "Kick", "KPM", adminMap.get(interaction.user.id).KPM]
    }
    var objectPick = orionObjects.unknown;

    if (interaction.commandName == 'ping' && General.SERVER.CHANNELS.LOGS !== "") {
        objectPick = orionObjects.banObject;
        if (client.orion == undefined) {
            client.orion = adminMap;
            console.log(client.orion.get(interaction.user.id), "client.orion made")
        } else {
            client.orion.set(client.orion.get(interaction.user.id).BPM, client.orion.get(interaction.user.id).BPM++)
            console.log(client.orion.get(interaction.user.id))
            //console.log(client.orion)
        }
    } else return; //ping and topic cmds are used as placeholder for ban and kick
    if (interaction.commandName == 'topic' && General.SERVER.CHANNELS.LOGS !== "") {

    } else return;
}

client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;
    orionCheck(interaction, adminMap);
});

this is code for every time a command is executed, it adds 1 to your specific user on a map which is what the map is there for. the client.orion is set to the map so that it remembers it each time the command is executed and makes the map globally executable. the if statement is checking if the client.orion was already made and if its undefined it makes it. pretty simple. but the problem is, for some reason on startup, you execute the command. it makes the client.orion then you execute it again and it does the else statement since now client.orion already exists and it adds one to the array. but when you execute it a third time, it stays at one as shown

https://i.imgur.com/Uve78bx.png

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This isn't a solution to your particular problem (but maybe it can provide some clues on what I was referring to in comments.)

On a Map object, set takes two parameters, the key and the value.

You have this line in your else block:

client.orion.set((interaction.user.id).BPM, client.orion.get(interaction.user.id).BPM++)

Notice that the "key" is undefined because (interaction.user.id).BPM doesn't exist.

You should have this line instead:

client.orion.set(interaction.user.id, client.orion.get(interaction.user.id).BPM++)

I thought it was strange when tested your code both ways (as undefined, and as defined) and got the same results. But whats really going on is that the set() is doing no work when the key passed to it is undefined. Instead the code in the value parameter is doing work (even though set() is not):

client.orion.get(interaction.user.id).BPM++

ALSO:

Your value parameter to set() has a logical error in that it's supposed to be an object. You are passing a integer to it. You didn't encounter what unexpected results this will create because so far your set() isn't doing work due to the undefined key.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda