So i was coding like a bot that detects if a channel got deleted, if it did i need the person so i can kick them with the bot. This was the code
client.on('channelDelete', async (channel) => {
// Get the channel ID
const channelDeleteId = channel.id;
// Fetch all channel deletions from the audit log
const auditLogs = await channel.guild.fetchAuditLogs({ type: 'CHANNEL_DELETE' });
// Find the log entry for this specific channel
const channelDeleteEntry = auditLogs.entries.find((entry) => entry.target.id === channelDeleteId);
if (channelDeleteEntry) {
const deleter = channelDeleteEntry.executor;
console.log(`User ${deleter.username} deleted channel ${channel.name} at time ${channelDeleteEntry.createdAt}`);
}
});
I tried asking people in discord and errors still appear, the error is
DiscordAPIError[50035]: Invalid Form Body action_type[NUMBER_TYPE_COERCE]: Value "CHANNEL_DELETE" is not int.
Please help