-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add alternate/spam account detection
- Loading branch information
Showing
6 changed files
with
125 additions
and
59 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
75 changes: 75 additions & 0 deletions
75
src/events/guildMemberUpdate/utils/onboardingAccountCheck.ts
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,75 @@ | ||
import { Constants } from "@alice-core/Constants"; | ||
import { EventUtil } from "@alice-structures/core/EventUtil"; | ||
import { EmbedCreator } from "@alice-utils/creators/EmbedCreator"; | ||
import { DateTimeFormatHelper } from "@alice-utils/helpers/DateTimeFormatHelper"; | ||
import { bold, GuildMember, GuildMemberFlags, userMention } from "discord.js"; | ||
|
||
export const run: EventUtil["run"] = async ( | ||
_, | ||
oldMember: GuildMember, | ||
newMember: GuildMember, | ||
) => { | ||
if (newMember.guild.id !== Constants.mainServer) { | ||
return; | ||
} | ||
|
||
// Do not trigger detection for rejoining members and members with verification bypass. | ||
if ( | ||
newMember.flags.any( | ||
GuildMemberFlags.DidRejoin | GuildMemberFlags.BypassesVerification, | ||
) | ||
) { | ||
return; | ||
} | ||
|
||
if ( | ||
!oldMember.flags.has(GuildMemberFlags.StartedOnboarding) || | ||
!newMember.flags.has(GuildMemberFlags.CompletedOnboarding) | ||
) { | ||
return; | ||
} | ||
|
||
const { joinedTimestamp } = newMember; | ||
|
||
if (joinedTimestamp === null) { | ||
return; | ||
} | ||
|
||
const onboardingCompleteDuration = Date.now() - joinedTimestamp; | ||
|
||
// Mark the member as a potential alternate account if they complete onboarding within | ||
// 1 minute of their join. | ||
if (onboardingCompleteDuration > 60000) { | ||
return; | ||
} | ||
|
||
const reportChannel = await newMember.guild.channels | ||
.fetch(Constants.reportChannel) | ||
.catch(() => null); | ||
|
||
if (!reportChannel?.isSendable()) { | ||
return; | ||
} | ||
|
||
await reportChannel.send({ | ||
embeds: [ | ||
EmbedCreator.createNormalEmbed({ | ||
color: "Red", | ||
timestamp: true, | ||
footerText: `User ID: ${newMember.id}`, | ||
}) | ||
.setTitle("Potential Alternate/Spam Account Detected") | ||
.setDescription( | ||
`${bold("User")}: ${newMember.user.tag} (${userMention(newMember.user.id)})\n\n` + | ||
`Completed onboarding in ${bold(DateTimeFormatHelper.secondsToDHMS(onboardingCompleteDuration / 1000))} seconds after joining the server.`, | ||
), | ||
], | ||
}); | ||
}; | ||
|
||
export const config: EventUtil["config"] = { | ||
description: | ||
"Responsible for checking if a newly joined member is a potential alternate or spam account.", | ||
togglePermissions: ["BotOwner"], | ||
toggleScope: ["GUILD"], | ||
}; |
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
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