guildAuditLogEntryCreate

client.on("guildAuditLogEntryCreate", async (log, guild) => {
if(log.action === AuditLogEvent.ChannelCreate) {
console.log(log.target?.id); // error
}
});
client.on("guildAuditLogEntryCreate", async (log, guild) => {
if(log.action === AuditLogEvent.ChannelCreate) {
console.log(log.target?.id); // error
}
});
Property 'id' does not exist on type 'Guild | AnyThreadChannel | Role | User | NonThreadGuildBasedChannel | GuildEmoji | Invite | ... 10 more ... | GuildOnboardingPrompt'.
Property 'id' does not exist on type 'Invite'.
Property 'id' does not exist on type 'Guild | AnyThreadChannel | Role | User | NonThreadGuildBasedChannel | GuildEmoji | Invite | ... 10 more ... | GuildOnboardingPrompt'.
Property 'id' does not exist on type 'Invite'.
6 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
ethan<333
ethan<333OP2mo ago
djs v14.16.2 node v20.14.0
souji
souji2mo ago
that is correct, targets may be invites, which do not have an id something being nullable (which is what you can use optional chaining for) is different from the definition of the key not existing at all in that type
ethan<333
ethan<333OP2mo ago
but since i made it typesafe shouldn't the target type change to something to do with channelcreate so id isnt erroring?
ethan<333
ethan<333OP2mo ago
No description
ethan<333
ethan<333OP2mo ago
ah ok. so how do i silence the error? the proper way thanks
Want results from more Discord servers?
Add your server