Woffer12
Woffer12
DIAdiscord.js - Imagine an app
Created by Woffer12 on 1/21/2024 in #djs-questions
Cannot read properties of null when editing a automod rule
Description When attempting to update an automod rule i get an error from discord.js that it can not read properties of null when reading 'autoModerationRules'. Package [email protected] Node v20.7.0 Code
const guild = await client.guilds.fetch(guildId);
const automodRule = await guild.autoModerationRules.fetch(ruleId);
const result = await automodRule.edit(ruleConfig);
const guild = await client.guilds.fetch(guildId);
const automodRule = await guild.autoModerationRules.fetch(ruleId);
const result = await automodRule.edit(ruleConfig);
Both guild and automodRule exist and return valid objects Error
TypeError: Cannot read properties of null (reading 'autoModerationRules')
at AutoModerationRule.edit (<REDACTED>\node_modules\discord.js\src\structures\AutoModerationRule.js:146:23)
TypeError: Cannot read properties of null (reading 'autoModerationRules')
at AutoModerationRule.edit (<REDACTED>\node_modules\discord.js\src\structures\AutoModerationRule.js:146:23)
The above leads to the following method, with the cursor after the . after the guild
/**
* Edits this auto moderation rule.
* @param {AutoModerationRuleEditOptions} options Options for editing this auto moderation rule
* @returns {Promise<AutoModerationRule>}
*/
edit(options) {
return this.guild.autoModerationRules.edit(this.id, options);
^
}
/**
* Edits this auto moderation rule.
* @param {AutoModerationRuleEditOptions} options Options for editing this auto moderation rule
* @returns {Promise<AutoModerationRule>}
*/
edit(options) {
return this.guild.autoModerationRules.edit(this.id, options);
^
}
Any help would be appreciate, i am not sure what is causing this issue, thanks in advance.
40 replies