OutwalkStudios / discord-backup

a module for backing up and restoring discord servers.
MIT License
12 stars 10 forks source link

Automod rules are being loaded incorrectly #44

Open SjogrenDev opened 4 weeks ago

SjogrenDev commented 4 weeks ago

DiscordAPIError[50035]: Invalid Form Body 0[AUTO_MODERATION_MAX_RULES_OF_TYPE_EXCEEDED]: Maximum number of rules with trigger type 5 is 1 at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1128:23) at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:959:14) at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22) at async AutoModerationRuleManager.create (/home/container/node_modules/discord.js/src/managers/AutoModerationRuleManager.js:122:18)

jleeson commented 3 weeks ago

@SjogrenDev would you mind providing the config you are passing to the backup.load function?

SjogrenDev commented 3 weeks ago

@SjogrenDev would you mind providing the config you are passing to the backup.load function?

I'm not passing any special settings.

jleeson commented 3 weeks ago

The error you are receiving is because discord only allows one auto mod rule with type equal to 5, the backup then should only have one of those in the first place, the only instance where this error should occur is if clearing the guild is disabled. Thats why I asked for the options you used in case it was being disabled.

If you are not passing any options to the load function, is there any other relevant data you can provide to help determine the cause of this issue?

NorkzYT commented 2 weeks ago

@SjogrenDev

Please send in the code you used and any other info that will help in resolving this issue since the error you gave is not fully helpful by itself.

jleeson commented 1 week ago

Without more information about the backup being used and the options being passed to the load function, there is not much I can do to help resolve the problem. The error message appears to be a result of auto mod rules already existing on the server being restored. The automod rules should be getting cleared before hand but without more information to reproduce, there is nothing actionable.

If this continues being a problem and more information is provided, I am happy to work on a solution for it but in the meantime I am closing this issue.

SjogrenDev commented 1 week ago

My load config, let me know if you need other info.

const res = await Backup.load(foundBackup, interaction.guild, { maxMessagesPerChannel: messages, clearGuildBeforeRestore: true, speed: 250, }).catch((err) => err);

SjogrenDev commented 1 week ago

Automod rules of my dev server:

"autoModerationRules": [ { "name": "Block Mention Spam", "eventType": 1, "triggerType": 5, "triggerMetadata": { "keywordFilter": [], "regexPatterns": [], "presets": [], "allowList": [], "mentionTotalLimit": 20, "mentionRaidProtectionEnabled": true }, "actions": [ { "type": 1, "metadata": { "durationSeconds": null, "channelId": null, "customMessage": null } } ], "enabled": true, "exemptRoles": [], "exemptChannels": [] } ],

SjogrenDev commented 1 week ago

It's a default rule of community servers, that can't be deleted.

"Error occurred while deleting automod rules: Mention Spam AutoMod rule cannot be deleted from community servers"

jleeson commented 1 week ago

This gives me the information I needed, Thank you. I will have a fix for this soon.