aoijs / aoi.js

aoi.js - The most advanced string-based package to create a Discord Bot fast and powerful.
https://aoi.js.org
Apache License 2.0
329 stars 130 forks source link

Bug: $getLeaderboardInfo returns the wrong position #624

Closed RayEve2007 closed 1 month ago

RayEve2007 commented 1 month ago

Bug Type

Function

Bugged Function

module.exports = [{
    name: "$alwaysExecute",
    $if: "old",
    code: `
    $if[$getGlobalUserVar[ServerEXP;$authorID]>=$getGlobalUserVar[ServerEXPRequired;$authorID]]
    $channelSendMessage[$channelID;{newEmbed: {description: > $username[$authorID] has reached \` Level $getGlobalUserVar[ServerLevel;$authorID] \`
> <:ReplyMessage:1209311268113227847>・None.}{color: Green}}]
    $setGlobalUserVar[ServerEXPRequired;$sum[$getGlobalUserVar[ServerEXPRequired;$authorID];$multi[5;$random[100;205]]]]
    $setGlobalUserVar[ServerEXP;$sum[$getGlobalUserVar[ServerEXP;$authorID];$random[10;25]]]
    $setGlobalUserVar[ServerLevel;$sum[$getGlobalUserVar[ServerLevel;$authorID];1]]
    $else
    $setGlobalUserVar[ServerEXP;$sum[$getGlobalUserVar[ServerEXP;$authorID];$random[10;25]]]
    $endif
`
}, {
    name: "rank",
    code: `
    $title[1;$findUser[$message[1]'s Rank Level]
    $djsEval[
    (async () => {
    const canvafy = require("canvafy");

    const rank = await new canvafy.Rank()
    .setAvatar("$replaceText[$userAvatar[$get[UserID]];.webm;.png]")
    .setBackground("image", "https://wallpapercave.com/wp/wp8594981.jpg")
    .setUsername("$username[$get[UserID]]")
    .setDisplayUsername("$userDisplayName[$get[UserID]]")
    .setOverlayOpacity(0.8)
    .setBorder("#FCFFF7")
    .setStatus("$userStatus[$guildID;$get[UserID]]")
    .setStatusIcon("$get[StatusEmojiColor]")
    .setBarColor("$get[StatusColor]")
    .setLevel($getGlobalUserVar[ServerLevel;$get[UserID]])
    .setLevelColor({ text: "#ffffff", number: "$get[StatusColor]" })
    .setRank($getLeaderboardInfo[ServerEXP;$get[UserID];global;top])
    .setRankColor({ text: "#ffffff", number: "$get[StatusColor]" })
    .setCurrentXp($getGlobalUserVar[ServerEXP;$get[UserID]], "#0f0f0f")
    .setRequiredXp($getGlobalUserVar[ServerEXPRequired;$get[UserID]], "#0f0f0f")
    .build();

    message.reply({
      files: [{
        attachment: rank,
        name: \`rankcard.png\`
      }]
    });
})()]

  $let[StatusColor;$replaceText[$replaceText[$replaceText[$replaceText[$replaceText[$userStatus[$guildID;$get[UserID]];online;#3ba55c];idle;#faa61a];dnd;#ed4245];stream;#593695];offline;#747f8e]]
  $let[StatusEmojiColor;$replaceText[$replaceText[$replaceText[$replaceText[$replaceText[$userStatus[$guildID;$get[UserID]];online;https://cdn3.emoji.gg/emojis/5251-online-status.png];idle;https://cdn3.emoji.gg/emojis/5505-idle-status.png];dnd;https://cdn3.emoji.gg/emojis/5163-dnd-status.png];stream;https://cdn3.emoji.gg/emojis/4944_Streaming.png];offline;https://cdn3.emoji.gg/emojis/2179-offline-status.png]]
  $let[UserID;$findUser[$message[1];true]]
`
}]

Version of aoi.js

v6.7.1

Version of Node.js

v21.4.0 (Current)

Excepted Output

The code that i've tried must be run as expected but unfortunately there was a problem with getting the current position. It supposed to be rank 1 but unfortunately it was added into 2 after leveling up AKA after 1k EXP, then i tried to run $globalUserLeaderboard function, it gives me the same result (2nd instead of 1st). I have also tested it with the previous version of aoi.js and aoi.db and they still gave me the same wrong position on that function.

Also, The second image are two users but the position was not updating although it was global var and they are really do the opposite thing.

Screenshot 2024-07-05 190256 Screenshot 2024-07-05 193532

Things I have done

Relevant log output

None

Code of Conduct

Faf4a commented 1 month ago

@RayEve2007 this was fixed a long time ago, please update via npm i aoi.js@latest!

RayEve2007 commented 1 month ago

Hmm, it isn't working. I already updated to the latest version of aoi.js and aoi.db, and i did the latest aoi.db setup correctly as well, and it seems to have still returned the same result. i also deleted the node_modules and database folders, but none of them worked.

RayEve2007 commented 1 month ago

Screenshot 2024-07-06 092504 @Faf4a this is also my setup

Update: $findUser also made it not synchronized with the $authorID function but it returns my ID from $findUser func. Screenshot 2024-07-06 095409