From 4b0a1786fab3c38c61cb63328b6bf580be0cb59e Mon Sep 17 00:00:00 2001 From: Lea Date: Sun, 19 Mar 2023 13:57:56 +0100 Subject: [PATCH] (hopefully) fix double sending discover notifs --- bot/src/bot/modules/antispam.ts | 10 +++++----- lib/src/types/ServerConfig.ts | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bot/src/bot/modules/antispam.ts b/bot/src/bot/modules/antispam.ts index dc910d1..8ccefb4 100644 --- a/bot/src/bot/modules/antispam.ts +++ b/bot/src/bot/modules/antispam.ts @@ -122,6 +122,11 @@ const notifyPublicServers = async () => { try { logger.info(`Sending notification to owner of server ${serverConfig._id}`); + await dbs.SERVERS.update( + { id: serverConfig.id }, + { $set: { discoverAutospamNotify: true, antispamEnabled: true, allowBlacklistedUsers: false } }, + ); + const server = client.servers.get(serverConfig.id); const channel = await getDmChannel(server!.owner); await channel.sendMessage(`Hi there, @@ -135,11 +140,6 @@ Please ensure that AutoMod has appropriate permissions to kick and ban users. You may also want to set up a logging channel by running \`/botctl logs modaction #yourchannel\` to receive details about antispam events if you haven't done so already. Thanks for being part of Revolt!`); - - await dbs.SERVERS.update( - { id: serverConfig.id }, - { $set: { discoverAutospamNotify: true, antispamEnabled: true, allowBlacklistedUsers: false } }, - ); } catch(e) { console.error(e); } diff --git a/lib/src/types/ServerConfig.ts b/lib/src/types/ServerConfig.ts index f4d1517..5183314 100644 --- a/lib/src/types/ServerConfig.ts +++ b/lib/src/types/ServerConfig.ts @@ -29,6 +29,8 @@ class ServerConfig { dmOnKick?: boolean; // Whether users should receive a DM when kicked/banned. Default false dmOnWarn?: boolean; // Whether users should receive a DM when warned. Default false contact?: string; // How to contact the server staff. Sent on kick/ban/warn DMs. http(s)/mailto link or normal text. + + // TODO: rename this and write a migration for it (this is why you don't code when sleep deprived) discoverAutospamNotify?: boolean; // Whether we have notified the server owner that antispam is enabled for servers on discover. }