issue with regex in autoModerationRules

await message.guild.autoModerationRules.create({
name: 'This message has been deleted because it contains a bad word. By ' + client.user.username,
creator: message.author.id,
enabled: true,
eventType: 1,
triggerType: 1,
triggerMetadata:
{
regexPatterns
},
actions: [
{
type: 1,
metadata: {
customMessage: 'This message has been deleted because it contains a bad word.\nBy ' + client.user.username
}
},
{
type: 2,
metadata: {
channel: message.channel.id,
}
},
{
type: 3,
metadata: {
durationSeconds: 300,
}
}
]
})
await message.guild.autoModerationRules.create({
name: 'This message has been deleted because it contains a bad word. By ' + client.user.username,
creator: message.author.id,
enabled: true,
eventType: 1,
triggerType: 1,
triggerMetadata:
{
regexPatterns
},
actions: [
{
type: 1,
metadata: {
customMessage: 'This message has been deleted because it contains a bad word.\nBy ' + client.user.username
}
},
{
type: 2,
metadata: {
channel: message.channel.id,
}
},
{
type: 3,
metadata: {
durationSeconds: 300,
}
}
]
})
its not working it show this error
DiscordAPIError: Invalid Form Body
trigger_metadata.regex_patterns./discord(?:app\.com\/invite|\.(?:(?:com\/invit|m)e|li|io|gg))|\u0645\u062E(?:\u0627\u0646\u064A|\u0646)\u062B|\u0627(?:\u0632\u063A\u0628|\u0645)\u0643|\u062C\u0631\u0627\u0631|\u0642(?:\u0648\u0627\u062F|\u062D\u0628)|\u0646\u064A\u0643|\u0643\u0633/|ـ: "/discord(?:app\.com\/invite|\.(?:(?:com\/invit|m)e|li|io|gg))|\u0645\u062E(?:\u0627\u0646\u064A|\u0646)\u062B|\u0627(?:\u0632\u063A\u0628|\u0645)\u0643|\u062C\u0631\u0627\u0631|\u0642(?:\u0648\u0627\u062F|\u062D\u0628)|\u0646\u064A\u0643|\u0643\u0633/|ـ" has invalid syntax
at RequestHandler.execute (/root/system/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/root/system/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async AutoModerationRuleManager.create (/root/system/node_modules/discord.js/src/managers/AutoModerationRuleManager.js:116:18)
at async Object.run (/root/system/commands/⚙️ Settings/badword.js:313:9)
at async Object.run (/root/system/events/handler/messageCreate.js:81:7) {
method: 'post',
path: '/guilds/1017666948902965260/auto-moderation/rules',
code: 50035,
httpStatus: 400,
requestData: {
json: {
name: 'This message has been deleted because it contains a bad word. By Right System',
event_type: 1,
trigger_type: 1,
trigger_metadata: [Object],
actions: [Array],
enabled: true,
exempt_roles: undefined,
exempt_channels: undefined
},
files: []
}
}
DiscordAPIError: Invalid Form Body
trigger_metadata.regex_patterns./discord(?:app\.com\/invite|\.(?:(?:com\/invit|m)e|li|io|gg))|\u0645\u062E(?:\u0627\u0646\u064A|\u0646)\u062B|\u0627(?:\u0632\u063A\u0628|\u0645)\u0643|\u062C\u0631\u0627\u0631|\u0642(?:\u0648\u0627\u062F|\u062D\u0628)|\u0646\u064A\u0643|\u0643\u0633/|ـ: "/discord(?:app\.com\/invite|\.(?:(?:com\/invit|m)e|li|io|gg))|\u0645\u062E(?:\u0627\u0646\u064A|\u0646)\u062B|\u0627(?:\u0632\u063A\u0628|\u0645)\u0643|\u062C\u0631\u0627\u0631|\u0642(?:\u0648\u0627\u062F|\u062D\u0628)|\u0646\u064A\u0643|\u0643\u0633/|ـ" has invalid syntax
at RequestHandler.execute (/root/system/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/root/system/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async AutoModerationRuleManager.create (/root/system/node_modules/discord.js/src/managers/AutoModerationRuleManager.js:116:18)
at async Object.run (/root/system/commands/⚙️ Settings/badword.js:313:9)
at async Object.run (/root/system/events/handler/messageCreate.js:81:7) {
method: 'post',
path: '/guilds/1017666948902965260/auto-moderation/rules',
code: 50035,
httpStatus: 400,
requestData: {
json: {
name: 'This message has been deleted because it contains a bad word. By Right System',
event_type: 1,
trigger_type: 1,
trigger_metadata: [Object],
actions: [Array],
enabled: true,
exempt_roles: undefined,
exempt_channels: undefined
},
files: []
}
}
7 Replies
d.js toolkit
d.js toolkit14mo 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!
Turki
TurkiOP14mo ago
regexPatterns is array with more then 1 regex /discord(?:app\\.com\\/invite|\\.(?:(?:com\\/invit|m)e|li|io|gg))|\\u0645\\u062E(?:\\u0627\\u0646\\u064A|\\u0646)\\u062B|\\u0627(?:\\u0632\\u063A\\u0628|\\u0645)\\u0643|\\u062C\\u0631\\u0627\\u0631|\\u0642(?:\\u0648\\u0627\\u062F|\\u062D\\u0628)|\\u0646\\u064A\\u0643|\\u0643\\u0633/|ـ this is one of the regex's
Looped
Looped14mo ago
Ensure that your regex patterns are correct because the above regex pattern seems to be invalid
Turki
TurkiOP14mo ago
if i put one it work fine 2 it stop working
Looped
Looped14mo ago
What I would recommend is putting them one by one into your array until an error pops up (unless there is a very high amount of expressions in the array)
Looped
Looped14mo ago
And ensure that you follow the following rule in the regexPatterns property.
No description
Looped
Looped14mo ago
If you read the error code properly, it says: "has invalid syntax" and displays which one does, which is what I have highlighted in my first answer. Please check your regex expression and try again
Want results from more Discord servers?
Add your server