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
- 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 OPI 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
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.
anyone?
bump
bump
anyone?
the
AutoModerationRule
gets logged twice, and .actions
is undefinedi'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.
:class: AutoModerationActionExecution
@14.16.3
Represents the structure of an executed action when an AutoModerationRule is triggered.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.
anyone?
that was it, here's the result of
.actions
:
why could that happeni 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
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