Discord.js: GuildAuditLogsEntry does not have createdAt or createdTimestamp properties

Created on 12 May 2017  Â·  8Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:

According to https://discord.js.org/#/docs/main/stable/class/GuildAuditLogsEntry there are two properties available: createdAt and createdTimestamp. However, neither of these actually exist in the GuildAuditLogsEntry object.

Include a reproducible code sample here, if possible:

bot.on("guildMemberRemove", (member) => {
    member.guild.fetchAuditLogs({ limit: 1 }).then(logs => {
        var logArray = Array.from(logs.entries.values());
        var entry = logArray[0];
        console.log(entry);
    }).catch(console.error);
});

Further details:

  • discord.js version: 11.1.0
  • node.js version: 7.9.0
  • Operating system: Raspbian 4.9.24-v7+
  • Priority this issue should have – please be realistic and elaborate if possible: Low
invalid

Most helpful comment

Then is Array.from() removing them? Because I'm using the console.log in that code as an example for you guys. When I actually try to access those values elsewhere, I get errors because they return undefined.

EDIT: Here, try this then:

bot.on("guildMemberRemove", (member) => {
    member.guild.fetchAuditLogs({ limit: 1 }).then(logs => {
        var logArray = Array.from(logs.entries.values());
        var entry = logArray[0];
        member.guild.channels.find("name", "general").send(entry.createdTimestamp).catch(console.error);
    }).catch(console.error);
});

This gives me undefined errors because entry.createdTimestamp does not exist.

All 8 comments

They are getters so they will not be listed when the object is serialized. I assure you that they exist however.

Then is Array.from() removing them? Because I'm using the console.log in that code as an example for you guys. When I actually try to access those values elsewhere, I get errors because they return undefined.

EDIT: Here, try this then:

bot.on("guildMemberRemove", (member) => {
    member.guild.fetchAuditLogs({ limit: 1 }).then(logs => {
        var logArray = Array.from(logs.entries.values());
        var entry = logArray[0];
        member.guild.channels.find("name", "general").send(entry.createdTimestamp).catch(console.error);
    }).catch(console.error);
});

This gives me undefined errors because entry.createdTimestamp does not exist.

message.guild.fetchAuditLogs({ limit: 1 }).then(logs => {
  message.channel.send(logs.entries.first().createdTimestamp)
});

works fine for me

P.S. i would filter the audit logs by member.user to prevent race conditions

Both GuildAuditLogsEntry properties createdAt and createdTimestamp are undefined for me, all others are defined. I notice they are the only two GuildAuditLogsEntry properties that are marked READ-ONLY but that should not matter. If anyone knows what I am doing wrong, please advise. I am using the following versions:

node.js: 6.10.3
discord.js 11.1.0
Ubuntu: 14.04.5 LTS

Code:

client.on('guildMemberRemove', member => {

    let guild = member.guild;

    member.guild.fetchAuditLogs({
        limit: 1
    }).then(logs => {

        var logArray = Array.from(logs.entries.values());

        console.log("createdTimestamp: " + logArray[0].createdTimestamp);
        console.log("createdAt: " + logArray[0].createdAt);

        // try alternative way

        console.log("createdTimestamp: " + logs.entries.first().createdTimestamp);
        console.log("createdAt: " + logs.entries.first().createdAt);

    }).catch(console.error);

});

Console Output:

createdTimestamp: undefined
createdAt: undefined
createdTimestamp: undefined
createdAt: undefined

I checked my GuildAuditLogs.js file and it did not contain those properties. I was using 11.1.0, which was the latest available using npm update discord.js. I tried npm update hydrabolt/discord.js to get master from Github and it installed 12.0.0 and the GuildAuditLogs.js now has those properties and so no longer returns undefined.

Confirmed, this is fixed at the moment in 12.0.0-dev after doing npm i hydrabolt/discord.js. Thanks @MorningSleeper!

createdAt()

@Xeron1 This was already resolved in my last reply posted _a year and a half ago._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smchase picture smchase  Â·  3Comments

iCrawl picture iCrawl  Â·  3Comments

BrandonCookeDev picture BrandonCookeDev  Â·  3Comments

Dmitry221060 picture Dmitry221060  Â·  3Comments

Acaretia picture Acaretia  Â·  3Comments