This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module.exports = async function cleanChannels(client) { | ||
const schema = require("../../models/filterSchema"); | ||
|
||
let autobanData = await schema.findOne({ _id: "autoban" }); | ||
let blockData = await schema.findOne({ _id: "block" }); | ||
|
||
const promises = []; | ||
|
||
let modifiedData = []; | ||
const removedData = []; | ||
|
||
for(const word of autobanData.words) { | ||
promises.push(new Promise(async resolve => { | ||
if(blockData.words.includes(word)) { | ||
blockData.words = blockData.words.filter(item => item !== word); | ||
|
||
await blockData.save(); | ||
|
||
if(!modifiedData.includes("block")) modifiedData.push("block"); | ||
|
||
resolve(`Modified: block`); | ||
} else { | ||
resolve(); | ||
} | ||
})) | ||
} | ||
|
||
await Promise.all(promises); | ||
|
||
if(!autobanData.words.length) { | ||
await autobanData.delete(); | ||
|
||
removedData.push("autoban"); | ||
} | ||
|
||
if(!blockData.words.length) { | ||
await blockData.delete(); | ||
|
||
removedData.push("block"); | ||
} | ||
|
||
return { | ||
"modified": modifiedData.filter(item => !removedData.includes(item)), | ||
"removed": removedData | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters