unable to make changes
i have made a automod command but i cant able to set punishment or logs
npm list discord.js and node node -v version?



console.log checkpoints throughout your code to find out where execution stops.await rule.edit({
actions: [
{
type: 1,
metadata: {
channel: alertChannel,
durationSeconds: durationSeconds,
customMessage: `This message has been blocked due to a blacklisted word. You have been timed out for ${timeoutDuration}.`,
},
},
],
});let durationSeconds;
switch (timeoutDuration) {
case '60s':
durationSeconds = "60 secs";
break;
case '5m':
durationSeconds = "5 mins";
break;
case '10m':
durationSeconds = "10 mins";
break;
case '1h':
durationSeconds = "1 hour";
break;
case '1d':
durationSeconds = "1 day";
break;
case '1w':
durationSeconds = "1 week";
break;
}
const alertChannel = message.mentions.channels.first();
if (!alertChannel) {
return message.channel.send('Please mention a valid alert channel.');
}let durationSeconds;
switch (timeoutDuration) {
case '60s':
durationSeconds = 60;
break;
case '5m':
durationSeconds = 5 * 60;
break;
case '10m':
durationSeconds = 10 * 60;
break;
case '1h':
durationSeconds = 60 * 60;
break;
case '1d':
durationSeconds = 24 * 60 * 60;
break;
case '1w':
durationSeconds = 7 * 24 * 60 * 60;
break;
}await rule.edit({
actions: [
{
type: 1,
metadata: {
channel: logChannel,
durationSeconds: 0, // Set to 0 to disable message blocking
customMessage: `This message has been blocked due to a blacklisted word.`,
},
},
{
type: 2, // Alert channel action
metadata: {
channel: logChannel,
},
},
{
type: 3, // Timeout action
metadata: {
durationSeconds: durationSeconds,
},
},
],
});const logChannel = message.mentions.channels.first() || client_guild.channels.cache.get(value);
if (!logChannel) {
return message.channel.send('Please provide a valid log channel (mention or ID).');
}
const existingActions = rule.actions;
const updatedActions = [
{
type: 1,
metadata: existingActions[0].metadata,
},
{
type: 2, // Alert channel action
metadata: {
channel: logChannel,
},
},
{
type: 3, // Timeout action
metadata: existingActions.find(action => action.type === 3).metadata,
},
];
await rule.edit({
actions: updatedActions,
});TypeError: Cannot read properties of undefined (reading 'metadata')
at Object.execute (/home/container/commands/automod/setpunishment.js:107:74)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) return {
type: 2,
metadata: {
channel: message.mentions.channels.first() || client_guild.channels.cache.get(value),
},
};
} else {
return action; // Keep the action unchanged
}
});