Automod triggering twice

I made a Automod system, which relies on Discord's built-in automod, however, I got a very weird issue, the link automod, triggers twice, by "triggering twice" I mean the following: - Sends the moderation DM to the user twice - Logs the punishment in a channels twice This only happens with the link automod, I have tested with the other type of automod and they work correctly. Relevant Code https://pastebin.com/bFMfaeWS - where the automodPunish function gets triggered, which at the same time sends the DM, logs the punishment, etc https://pastebin.com/PfhJmYh1 - code for the automodPunish function
Pastebin
Link automod - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
automodPunish function - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
13 Replies
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
-Carlos👑
-Carlos👑OP4mo ago
I can also share the code for the automod function (line 25 of automodPunish function) if needed, that is the function that DMs and logs the punishment anyone? bump the event is autoModerationActionExecution
-Carlos👑
-Carlos👑OP4mo ago
here's the extended version of the first part of relevant code: https://pastebin.com/KmgTAX6Q
Pastebin
Extended version - Link automod - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
-Carlos👑
-Carlos👑OP4mo ago
anyone? bump bump anyone? the AutoModerationRule gets logged twice, and .actions is undefined
d.js docs
d.js docs4mo ago
:property: AutoModerationRule#actions @14.16.3 The actions of this auto moderation rule.
-Carlos👑
-Carlos👑OP4mo ago
i'm pretty sure I did https://pastebin.com/KmgTAX6Q
Pastebin
Extended version - Link automod - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
d.js docs
d.js docs4mo ago
:class: AutoModerationActionExecution @14.16.3 Represents the structure of an executed action when an AutoModerationRule is triggered.
-Carlos👑
-Carlos👑OP4mo ago
it returns an error updated code: https://pastebin.com/KmgTAX6Q error:
TypeError: Cannot read properties of null (reading 'actions')
TypeError: Cannot read properties of null (reading 'actions')
Pastebin
Extended version - Link automod - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
-Carlos👑
-Carlos👑OP4mo ago
anyone? that was it, here's the result of .actions:
[
{
type: 1,
metadata: { durationSeconds: null, channelId: null, customMessage: '' }
},
{
type: 2,
metadata: {
durationSeconds: null,
channelId: 'same channel id',
customMessage: null
}
}
]
[
{
type: 1,
metadata: { durationSeconds: null, channelId: null, customMessage: '' }
},
{
type: 2,
metadata: {
durationSeconds: null,
channelId: 'same channel id',
customMessage: null
}
}
]
[
{
type: 1,
metadata: { durationSeconds: null, channelId: null, customMessage: '' }
},
{
type: 2,
metadata: {
durationSeconds: null,
channelId: 'same channel id',
customMessage: null
}
}
]
[
{
type: 1,
metadata: { durationSeconds: null, channelId: null, customMessage: '' }
},
{
type: 2,
metadata: {
durationSeconds: null,
channelId: 'same channel id',
customMessage: null
}
}
]
why could that happen
d.js docs
d.js docs4mo ago
:property: AutoModerationActionExecution#action @14.16.3 The action that was executed.
-Carlos👑
-Carlos👑OP4mo ago
i see, just checked and that rule has 2 actions what would the fix be here to prevent code from executing twice if the automod rule has 2 actions what do you mean by checking the action or actionType but by "checking" what do you mean and what should I check it against
d.js docs
d.js docs4mo ago
:dtypes: v10: AutoModerationActionType read more
-Carlos👑
-Carlos👑OP4mo ago
in which way would adding this would prevent the code from running twice if the automod rule has 2 actions wouldn't ignoring one of them just stop the code from running? due to the return? i see now i understand just checked with all the other automod rules and they work correctly, ty

Did you find this page helpful?