Issues editing automod

I'm currently trying to edit my automod rule to have a timeout duration, when I try adding a timeout duration, it is sending this
"actions": [
{
"type": 1,
"metadata": {
"durationSeconds": null,
"channelId": null,
"customMessage": null
}
},
{
"type": 2,
"metadata": {
"durationSeconds": null,
"channelId": "1156640178811711570",
"customMessage": null
}
},
{
"type": 3,
"metadata": {
"durationSeconds": 3600
}
}
]
"actions": [
{
"type": 1,
"metadata": {
"durationSeconds": null,
"channelId": null,
"customMessage": null
}
},
{
"type": 2,
"metadata": {
"durationSeconds": null,
"channelId": "1156640178811711570",
"customMessage": null
}
},
{
"type": 3,
"metadata": {
"durationSeconds": 3600
}
}
]
(split)
3 Replies
rad
radOP4mo ago
And i'm not really sure why, here is my code that deals with editing it, the code that goes below this is for managing the database
const autoModManager = interaction.guild?.autoModerationRules;
if (!autoModManager) return;

for (const module of serverRecord.modules) {
try {
const rule = await autoModManager.fetch(module.id);
console.log('Current Rule actions:', rule.actions);

let actionUpdated = false;
const newActions = rule.actions.map((action) => {
if (action.type === AutoModerationActionType.Timeout) {
actionUpdated = true;
return {
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
};
}
return action;
});

if (!actionUpdated) {
newActions.push({
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
});
}

const editOptions: AutoModerationRuleEditOptions = { actions: newActions };

console.log('Sending the following edit options to Discord:', JSON.stringify(editOptions, null, 2));

await rule.edit(editOptions);
const autoModManager = interaction.guild?.autoModerationRules;
if (!autoModManager) return;

for (const module of serverRecord.modules) {
try {
const rule = await autoModManager.fetch(module.id);
console.log('Current Rule actions:', rule.actions);

let actionUpdated = false;
const newActions = rule.actions.map((action) => {
if (action.type === AutoModerationActionType.Timeout) {
actionUpdated = true;
return {
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
};
}
return action;
});

if (!actionUpdated) {
newActions.push({
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
});
}

const editOptions: AutoModerationRuleEditOptions = { actions: newActions };

console.log('Sending the following edit options to Discord:', JSON.stringify(editOptions, null, 2));

await rule.edit(editOptions);
d.js toolkit
d.js toolkit4mo 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! - Marked as resolved by OP
rad
radOP4mo ago
for (const module of serverRecord.modules) {
try {
const rule = await autoModManager.fetch(module.id);
const newActions = [
{
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
},
];
for (const module of serverRecord.modules) {
try {
const rule = await autoModManager.fetch(module.id);
const newActions = [
{
type: AutoModerationActionType.Timeout,
metadata: { durationSeconds: duration },
},
];
If I leave it like this, without the splitting, it'll just turn off block messages and alert, and only turn on timeout duration yk
Want results from more Discord servers?
Add your server