The bot needs to know which posts are submissions and which are not.
This will help the bot sort through the posts more efficiently. Here are some thoughts I had on this.
Code
The code will be simpler, maybe just an includes statement. The module could double check the validation using an consecutive array method. Maybe?
Some suggestions
This would check to see if the title had the keyword submission in it:
data.title.includes('[submission]')
This would remove the [submission]
text from the title. This could be invoked right before adding it to data
.
if(str.includes('[submission]'){
str.replace('[submission]', '')
}
Here is a link for the MDN docs for the replace
method.
Another method for loping off the submisson
text:
if(str.includes('[submission]'){
str.substring('[submission]'.length)
}
In this example, we use the length of the [submission]
keyword to take it off the beginning of the title.
This method has some advantages:
- Simpler
- Faster
- More reliable
But also has some disadvantages:
- Hard to modify boilerplate
- Assumes the user put the tag on the beginning
- This actually makes this method less reliable.
It will definitely be easier to code. Here is the docs reference for substring
.
Format is pretty free, but I would recommend formatting it like I (@Spaceface16518) formatted the export
module.
I have formatted it like the following:
module.exports.mainFunction(input: any) {
if(conditionalFunction(input.part) === "condition") {
return "return value"
} else {
return null
}
function conditionalFunction(input: any){
if(input === condition) {
return true;
} else {
return false;
}
}
Summary
Essentially, the point of this (hypothetical) module is to make sure that the bot only pulls posts that contain actual strat submissions. There are limited ways to do this, but the real problem is after the check happens. Formatting is also an issue, and not just for consistency.