for coded
diff --git a/src/automations/statsChannelAdd.ts b/src/automations/statsChannelAdd.ts
new file mode 100644
index 0000000..42ec580
--- /dev/null
+++ b/src/automations/statsChannelAdd.ts
@@ -0,0 +1,24 @@
+import log from '../utils/log.js'
+import readConfig from '../utils/readConfig.js'
+import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
+
+export async function callback(_, member) {
+ let config = await readConfig(member.guild.id);
+
+ config.stats.forEach(async element => {
+ if (element.enabled) {
+ let string = element.text
+ if (!string) return
+ string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
+
+ let channel = await member.client.channels.fetch(element.channel)
+ if (channel.guild.id !== member.guild.id) return
+ if (!channel) return // TODO: Notify mods
+ try {
+ await channel.edit({ name: string })
+ } catch (err) {
+ console.error(err)
+ }
+ }
+ });
+}
\ No newline at end of file
diff --git a/src/automations/statsChannelRemove.ts b/src/automations/statsChannelRemove.ts
new file mode 100644
index 0000000..42ec580
--- /dev/null
+++ b/src/automations/statsChannelRemove.ts
@@ -0,0 +1,24 @@
+import log from '../utils/log.js'
+import readConfig from '../utils/readConfig.js'
+import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
+
+export async function callback(_, member) {
+ let config = await readConfig(member.guild.id);
+
+ config.stats.forEach(async element => {
+ if (element.enabled) {
+ let string = element.text
+ if (!string) return
+ string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
+
+ let channel = await member.client.channels.fetch(element.channel)
+ if (channel.guild.id !== member.guild.id) return
+ if (!channel) return // TODO: Notify mods
+ try {
+ await channel.edit({ name: string })
+ } catch (err) {
+ console.error(err)
+ }
+ }
+ });
+}
\ No newline at end of file
diff --git a/src/automations/unscan.ts b/src/automations/unscan.ts
new file mode 100644
index 0000000..1fb47f8
--- /dev/null
+++ b/src/automations/unscan.ts
@@ -0,0 +1,67 @@
+import * as scan from '../utils/scanners.js'
+
+export async function LinkCheck(message): Promise<boolean> {
+ let links = message.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi) ?? []
+ let detections = []
+ const promises = links.map(async element => {
+ try {
+ element = await scan.testLink(element)
+ } catch {}
+ detections.push({tags: element.tags || [], safe: element.safe})
+ });
+ await Promise.all(promises);
+ let types = [
+ "PHISHING", "DATING", "TRACKERS", "ADVERTISEMENTS", "FACEBOOK",
+ "AMP", "FACEBOOK TRACKERS", "IP GRABBERS", "PORN",
+ "GAMBLING", "MALWARE", "PIRACY", "RANSOMWARE",
+ "REDIRECTS", "SCAMS", "TORRENT", "HATE", "JUNK"
+ ]
+ let detectionsTypes = detections.map(element => {
+ let type = types.find(type => element.tags.includes(type))
+ if (type) return type
+ if (!element.safe) return "UNSAFE"
+ return undefined
+ }).filter(element => element !== undefined)
+ return detectionsTypes.length > 0
+}
+
+export async function NSFWCheck(element): Promise<boolean> {
+ try {
+ //@ts-ignore
+ let test = (await scan.testNSFW(element)).nsfw
+ return test
+ } catch {
+ return false
+ }
+}
+
+export async function SizeCheck(element): Promise<boolean> {
+ if (element.height == undefined || element.width == undefined) return true
+ if (element.height < 20 || element.width < 20) return false
+ return true
+}
+
+export async function MalwareCheck(element): Promise<boolean> {
+ try {
+ //@ts-ignore
+ return (await scan.testMalware(element)).safe
+ } catch {
+ return true
+ }
+}
+
+export function TestString(string, soft, strict): string {
+ for(let word of strict || []) {
+ if (string.toLowerCase().includes(word)) {
+ return "strict"
+ }
+ }
+ for(let word of soft) {
+ for(let word2 of string.match(/[a-z]+/gi) || []) {
+ if (word2 == word) {
+ return "loose"
+ }
+ }
+ }
+ return "none"
+}
\ No newline at end of file
diff --git a/src/automations/welcome.ts b/src/automations/welcome.ts
new file mode 100644
index 0000000..6505265
--- /dev/null
+++ b/src/automations/welcome.ts
@@ -0,0 +1,44 @@
+import log from '../utils/log.js'
+import readConfig from '../utils/readConfig.js'
+import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
+
+export async function callback(_, member) {
+ if (member.bot) return
+ let config = await readConfig(member.guild.id);
+ if (!config.welcome.enabled) return
+
+ if (!config.welcome.verificationRequired.role) {
+ if (config.welcome.welcomeRole) {
+ try {
+ await member.roles.add(config.welcome.welcomeRole)
+ } catch (err) {
+ console.error(err)
+ }
+ }
+ }
+
+
+ if (!config.welcome.verificationRequired.message && config.welcome.channel) {
+ let string = config.welcome.message
+ if (string) {
+ string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
+
+ if (config.welcome.channel === 'dm') {
+ try {
+ await member.send(string)
+ } catch (err) {
+ console.error(err)
+ }
+ } else {
+ let channel = await member.client.channels.fetch(config.welcome.channel)
+ if (channel.guild.id !== member.guild.id) return
+ if (!channel) return // TODO: Notify mods
+ try {
+ await channel.send(string)
+ } catch (err) {
+ console.error(err)
+ }
+ }
+ }
+ }
+}
\ No newline at end of file