#Discord Automod
50 messages · Page 1 of 1 (latest)
NODEJS : v20.2.0
DJS : v14.11.0
salon here would be a collection, spread its values into that array you pass there
And salons would be a Channel, not an array, so don’t [0] it
Maybe you meant to name them the other way around?
Something like that ? ```js
const salons = interaction.options.getChannel('channel');
const salon = rule.exemptChannels;
if (salon.size === 0) {
rule.edit({
name: test,
exemptChannels: [...salon],
});
} else {
rule.edit({
name: test,
exemptChannels: [...salons, ...salon],
});
}
no doesn't work
No, as I said, salons is a single Channel here, not an iterable. So don’t spread it
like that ? ```js
if (salon.size === 0) {
rule.edit({
name: test,
exemptChannels: [salons],
});
} else {
rule.edit({
name: test,
exemptChannels: [salons, ...salon],
});
}
That looks better, yes.
Promise {
<rejected> DiscordAPIError[50035]: Invalid Form Body
exempt_channels[0][BASE_TYPE_REQUIRED]: This field is required
at handleErrors (C:\Users\Phoenix\OneDrive\Bureau\Perso\Phoenix\V.14\node_modules\@discordjs\rest\dist\index.js:640:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\Phoenix\OneDrive\Bureau\Perso\Phoenix\V.14\node_modules\@discordjs\rest\dist\index.js:1021:23)
at async SequentialHandler.queueRequest (C:\Users\Phoenix\OneDrive\Bureau\Perso\Phoenix\V.14\node_modules\@discordjs\rest\dist\index.js:862:14)
at async REST.request (C:\Users\Phoenix\OneDrive\Bureau\Perso\Phoenix\node_modules\@discordjs\rest\dist\index.js:1387:22)
at async AutoModerationRuleManager.edit (C:\Users\Phoenix\OneDrive\Bureau\Perso\Phoenix\V.14\node_modules\discord.js\src\managers\AutoModerationRuleManager.js:177:18) {
requestBody: { files: undefined, json: [Object] },
rawError: { code: 50035, errors: [Object], message: 'Invalid Form Body' },
code: 50035,
status: 400,
method: 'PATCH',
url: 'https://discord.com/api/v10/guilds/1040942425922883634/auto-moderation/rules/1108050715248701582'
}
}
Ah, wait, salon will be a collection, you need to spread salon.values()
It's working thanks ! Is it the same for exemptRoles ???
It is the same in terms of the docs have all your answers. Read them
yes thanks !
Sorry it's me again, but when i add new words Discord consider it like 1 words when there are 7.
Input : some bad words enter like that : (word1, word2, word3)
Without the code showing what you did there’s nothing I can help you with. Other than referring you to the docs
triggerMetadata: {
keywordFilter: [`${word}`],
},
word is : word1, word2, word3
same when i edit
Yeah, then it‘s one element in the array only…
so i should add words one by one ?
You should pass them as array. Not stringify the list into one single element
like that ? ```js
keywordFilter: [word],
That‘s still an array with one single element. Please tell me you know how arrays work
const exemple = ['test1', 'test2', 'test3'];
Yes, that is indeed an array
Yes, but how can i do that with my code because : const word = collected.first().content
so when the member create his rule
String.prototype.split()
The split() method takes a pattern and divides a String into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.
keywordFilter: [word.split()], ?
That would be a nested array…
const word = collected.first().content;
const words = word.split();
keywordFilter: words ,
That would indeed be a string array now, just as the function expects
i have put that const words = word.split(', ') and i think it's working
I'am really sorry, it's me again. But when i try to delete an exemptRoles I can't. I have the id of the role to remove, I have the rooms present in the system but I can't remove it
could you help me ? thanks a lot
What did you try? And no need to reply-ping me, we‘re literally the only people in this thread
sorry, so i have tried a lot of things. The last i've tried is ```js
const valueToRemove = value; //Value is the id of the role
const exemptRoles = rule.exemptRoles;
const excludedRoles = Array.from(exemptRoles.values());
const updatedExemptRoles = exemptRoles.filter(role => !excludedRoles.includes(role) || role !== valueToRemove);
rule.edit({
exemptRoles: updatedExemptRoles,
});
That… looks fine to me actually. What‘s the error?
i don't have any error. Just the role is not delete from the rule.
console.log(updatedExemptRoles) before the edit call there
And make sure rule is the one you mean to edit
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.
Ah, it’s the collection again, not an array…
But that should work
How many roles does the rule have exempt?
2
Then all works correctly, no?