Audit Log Trouble

Hello, I'm having an issue within the Audit Logs and would love some help. I'm not sure what's specifically going on but this is the best I can explain it. 1) I've saved the audit logs to my personal database. 2) I turned the bot off 3) I made a new channel called 'a' 4) I turned the bot back on and collected the new list of entries 5) I compared the new list of entries with the database saved using the .difference() in collections. It logs two different auditlog entries, with two different keys, and one of them has even more information than the previous one. Does anyone know what has caused this, or would you be willing to run my code and tell me if it's happening to you also?
3 Replies
ImMrBloo
ImMrBloo2y ago
const guild = await client.guilds.cache.get('992651008805195907');

const getAuditLog = await guild.fetchAuditLogs();

const entries = await getAuditLog.entries;

// save the entries
const settings = await client.settings.get(guild.id, 'auditLogs');

// if there's no settings return and set the current auditLogs array
if(!settings){return client.settings.set(guild.id, entries, 'auditLogs');}


// get the difference from what's new and what's in the database
const newEntries = entries.difference(settings);
const guild = await client.guilds.cache.get('992651008805195907');

const getAuditLog = await guild.fetchAuditLogs();

const entries = await getAuditLog.entries;

// save the entries
const settings = await client.settings.get(guild.id, 'auditLogs');

// if there's no settings return and set the current auditLogs array
if(!settings){return client.settings.set(guild.id, entries, 'auditLogs');}


// get the difference from what's new and what's in the database
const newEntries = entries.difference(settings);
my code ^^ Hey! I'm currently working on version 14 and I'm having an issue with the GuildAuditLogsEntry. I was wondering if I could get an explanation as to what's specifically going on here?
Collection(2) [Map] {
'993275405274468524' => {
targetType: 'Channel',
actionType: 'Create',
action: 10,
reason: null,
executor: '743378368031883337',
changes: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
id: '993275405274468524',
extra: null,
target: '993275405274468523',
createdTimestamp: 1656885710782
},
'1000855284966760491' => GuildAuditLogsEntry {
targetType: 'Channel',
actionType: 'Create',
action: 10,
reason: null,
executor: User {
id: '411886883983982593',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'ImMrBloo',
discriminator: '2292',
avatar: '4d8c64a8f4fae3b987701e8315013941',
banner: undefined,
accentColor: undefined
},
changes: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
id: '1000855284966760491',
extra: null,
target: TextChannel {
type: 0,
guild: [Guild],
guildId: '992651008805195907',
parentId: '992651008805195908',
permissionOverwrites: [PermissionOverwriteManager],
messages: [MessageManager],
threads: [ThreadManager],
nsfw: false,
id: '1000855284966760490',
name: 'a',
rawPosition: 43,
topic: null,
lastMessageId: null,
rateLimitPerUser: 0
}
}
}
Collection(2) [Map] {
'993275405274468524' => {
targetType: 'Channel',
actionType: 'Create',
action: 10,
reason: null,
executor: '743378368031883337',
changes: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
id: '993275405274468524',
extra: null,
target: '993275405274468523',
createdTimestamp: 1656885710782
},
'1000855284966760491' => GuildAuditLogsEntry {
targetType: 'Channel',
actionType: 'Create',
action: 10,
reason: null,
executor: User {
id: '411886883983982593',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'ImMrBloo',
discriminator: '2292',
avatar: '4d8c64a8f4fae3b987701e8315013941',
banner: undefined,
accentColor: undefined
},
changes: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
id: '1000855284966760491',
extra: null,
target: TextChannel {
type: 0,
guild: [Guild],
guildId: '992651008805195907',
parentId: '992651008805195908',
permissionOverwrites: [PermissionOverwriteManager],
messages: [MessageManager],
threads: [ThreadManager],
nsfw: false,
id: '1000855284966760490',
name: 'a',
rawPosition: 43,
topic: null,
lastMessageId: null,
rateLimitPerUser: 0
}
}
}
'1001003196912779294' => GuildAuditLogsEntry {
targetType: 'Message',
actionType: 'Delete',
action: 72,
reason: null,
executor: User {
id: '411886883983982593',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'ImMrBloo',
discriminator: '2292',
avatar: '4d8c64a8f4fae3b987701e8315013941',
banner: undefined,
accentColor: undefined
},
changes: [],
id: '1001003196912779294',
extra: {
channel: [TextChannel],
count: 1
},
target: ClientUser {
id: '992650146368196660',
bot: true,
system: false,
flags: [UserFlagsBitField],
username: 'Moon18',
discriminator: '0568',
avatar: 'ac83a5815baf8e75dbba79398ee529e4',
banner: undefined,
accentColor: undefined,
verified: true,
mfaEnabled: true
}
}
'1001003196912779294' => GuildAuditLogsEntry {
targetType: 'Message',
actionType: 'Delete',
action: 72,
reason: null,
executor: User {
id: '411886883983982593',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'ImMrBloo',
discriminator: '2292',
avatar: '4d8c64a8f4fae3b987701e8315013941',
banner: undefined,
accentColor: undefined
},
changes: [],
id: '1001003196912779294',
extra: {
channel: [TextChannel],
count: 1
},
target: ClientUser {
id: '992650146368196660',
bot: true,
system: false,
flags: [UserFlagsBitField],
username: 'Moon18',
discriminator: '0568',
avatar: 'ac83a5815baf8e75dbba79398ee529e4',
banner: undefined,
accentColor: undefined,
verified: true,
mfaEnabled: true
}
}
Just wondering what is this called where it says => "GuildAuditLogsEntry" ? as in when searching through the audit log itself what would I need to do to filter for that?
monbrey
monbrey2y ago
Thats just the name of the class Thats how util.inspect shows it Having said that.... i dont know why the others DONT have that They should all be instances of GuildAuditLogsEntry It looks more like its a raw API object actually
ImMrBloo
ImMrBloo2y ago
yeah that's what I was thinking so I'm trying to think if I can just filter for the class name being inside it than I might be able to have all of the proper information. Do you have any idea how that would be done or even the slightest direction to point?