(hopefully) fix double sending discover notifs

This commit is contained in:
Lea 2023-03-19 13:57:56 +01:00
parent 0eb88da2ce
commit 4b0a1786fa
Signed by: Lea
GPG key ID: 1BAFFE8347019C42
2 changed files with 7 additions and 5 deletions

View file

@ -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);
}

View file

@ -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.
}