discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.2k stars 3.96k forks source link

guildMember.premiumSince and guildMember.premiumSinceTimestamp always null #7682

Closed iKingNinja closed 2 years ago

iKingNinja commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

Reading guildMember.premiumSince and guildMember.premiumSinceTimestamp will always return null. I have boosted a server which also reached level 1 so i boosted twice too and those properties are null. There are not much more informations.

Code sample

const members = guild.members.cache;

for (let i of members) {
    if (serverSettings.checkMethod === '1') {
        if (i[1].nickname === username) {
            var isBooster = false;

            i[1].premiumSince ? isBooster = true : isBooster;

            return {
                isBooster: isBooster,
                boosterSince: i[1].premiumSince, //null
                boosterSinceTimeStamp: i[1].premiumSinceTimestamp //null
            };
        }
    }
}

Package version

^13.6.0

Node.js version

v17.5.0

Operating system

Windows

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMembers

I have tested this issue on a development release

No response

ImRodry commented 2 years ago

Can’t reproduce with the given intents, are you sure the member data is up to date and that the member is a booster?

iKingNinja commented 2 years ago

Can’t reproduce with the given partials

There are no partials set in the client object.

are you sure the member data is up to date and that the member is a booster?

Yes i am sure the member is a booster because it's me.

Jiralite commented 2 years ago

I am also not able to reproduce this issue. Looking at your reproducible code sample, it contains code that is not purely discord.js, so I would advise you to do so, just like I did:

import { Client, Constants, Intents } from "discord.js";

const client = new Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MEMBERS
  ]
});

client.once(Constants.Events.CLIENT_READY, async () => {
  const guild = client.guilds.resolve("guild_id");
  const { premiumSince, premiumSinceTimestamp } = await guild.members.fetch("user_id");
  console.log(premiumSince, premiumSinceTimestamp);
});

client.login("token");

I boost a guild this particular bot is in and the relevant information is returned. By the way, the GUILD_MEMBERS intent isn't required for this code sample.

If you are still able to reproduce this issue, I would check again to see if you actually are boosting the guild and request this information from the API without discord.js to see if the returned data matches what you already receive. If this is the case, this is not a discord.js issue.