Default to file not being malware (#74)
diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts
index 0d9188a..a854fc5 100644
--- a/src/commands/settings/automod.ts
+++ b/src/commands/settings/automod.ts
@@ -410,36 +410,24 @@
}
case "allowedUsers": {
await i.deferUpdate();
- current.allowed.users = await toSelectMenu(
- interaction,
- m,
- current.allowed.users,
- "member",
- "Word Filter"
+ current.allowed.users = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter")
);
unsavedChanges = true;
break;
}
case "allowedRoles": {
await i.deferUpdate();
- current.allowed.roles = await toSelectMenu(
- interaction,
- m,
- current.allowed.roles,
- "role",
- "Word Filter"
+ current.allowed.roles = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter")
);
unsavedChanges = true;
break;
}
case "allowedChannels": {
await i.deferUpdate();
- current.allowed.channels = await toSelectMenu(
- interaction,
- m,
- current.allowed.channels,
- "channel",
- "Word Filter"
+ current.allowed.channels = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter")
);
unsavedChanges = true;
break;
@@ -556,34 +544,22 @@
await i.deferUpdate();
switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(
- interaction,
- m,
- current.allowed.users,
- "member",
- "Invite Settings"
+ current.allowed.users = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings")
);
unsavedChanges = true;
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(
- interaction,
- m,
- current.allowed.roles,
- "role",
- "Invite Settings"
+ current.allowed.roles = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings")
);
unsavedChanges = true;
break;
}
case "channels": {
- current.allowed.channels = await toSelectMenu(
- interaction,
- m,
- current.allowed.channels,
- "channel",
- "Invite Settings"
+ current.allowed.channels = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings")
);
unsavedChanges = true;
break;
@@ -803,12 +779,14 @@
}
case "roles": {
await i.deferUpdate();
- current.allowed.rolesToMention = await toSelectMenu(
- interaction,
- m,
- current.allowed.rolesToMention,
- "role",
- "Mention Settings"
+ current.allowed.rolesToMention = _.cloneDeep(
+ await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.rolesToMention,
+ "role",
+ "Mention Settings"
+ )
);
unsavedChanges = true;
break;
@@ -820,34 +798,28 @@
await i.deferUpdate();
switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(
- interaction,
- m,
- current.allowed.users,
- "member",
- "Mention Settings"
+ current.allowed.users = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings")
);
unsavedChanges = true;
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(
- interaction,
- m,
- current.allowed.roles,
- "role",
- "Mention Settings"
+ current.allowed.roles = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings")
);
unsavedChanges = true;
break;
}
case "channels": {
- current.allowed.channels = await toSelectMenu(
- interaction,
- m,
- current.allowed.channels,
- "channel",
- "Mention Settings"
+ current.allowed.channels = _.cloneDeep(
+ await toSelectMenu(
+ interaction,
+ m,
+ current.allowed.channels,
+ "channel",
+ "Mention Settings"
+ )
);
unsavedChanges = true;
break;
@@ -1004,23 +976,15 @@
case "allowed": {
switch (i.values[0]) {
case "users": {
- current.allowed.users = await toSelectMenu(
- interaction,
- m,
- current.allowed.users,
- "member",
- "Mention Settings"
+ current.allowed.users = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings")
);
unsavedChanges = true;
break;
}
case "roles": {
- current.allowed.roles = await toSelectMenu(
- interaction,
- m,
- current.allowed.roles,
- "role",
- "Mention Settings"
+ current.allowed.roles = _.cloneDeep(
+ await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings")
);
unsavedChanges = true;
break;
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index 6d3fc71..a6e94d6 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -67,7 +67,7 @@
try {
malware = (await clamscanner.scanFile(fileName)).isInfected;
} catch (e) {
- return { malware: true };
+ return { malware: false };
}
await client.database.scanCache.write(hash, "malware", malware);
return { malware };
@@ -198,12 +198,16 @@
}
export async function TestImage(url: string): Promise<string | null> {
- const text = await Tesseract.recognize(url, {
- lang: "eng",
- oem: 1,
- psm: 3
- });
- return text;
+ try {
+ const text = await Tesseract.recognize(url, {
+ lang: "eng",
+ oem: 1,
+ psm: 3
+ });
+ return text;
+ } catch {
+ return null;
+ }
}
export async function doMemberChecks(member: Discord.GuildMember): Promise<void> {