aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/bush
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-31 11:30:50 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-12-31 11:30:50 -0500
commit68ef45a7090a9b6d2b06426ebf754c782ea744c8 (patch)
tree25d78c5dc8f68b09a7236f5f9072e92dcc853136 /src/listeners/bush
parent5481971d8dae490a467dd592ca301e72acb2254a (diff)
downloadtanzanite-68ef45a7090a9b6d2b06426ebf754c782ea744c8.tar.gz
tanzanite-68ef45a7090a9b6d2b06426ebf754c782ea744c8.tar.bz2
tanzanite-68ef45a7090a9b6d2b06426ebf754c782ea744c8.zip
add autoban I really hope I didn't screw this up
Diffstat (limited to 'src/listeners/bush')
-rw-r--r--src/listeners/bush/nameAutoBan.ts62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/listeners/bush/nameAutoBan.ts b/src/listeners/bush/nameAutoBan.ts
new file mode 100644
index 0000000..dd702a5
--- /dev/null
+++ b/src/listeners/bush/nameAutoBan.ts
@@ -0,0 +1,62 @@
+import { AllowedMentions, BushListener, BushTextChannel, type BushClientEvents } from '#lib';
+import moment from 'moment';
+
+export default class NameAutoBanListener extends BushListener {
+ public constructor() {
+ super('nameAutoBan', {
+ emitter: 'client',
+ event: 'guildMemberAdd',
+ category: 'guild'
+ });
+ }
+
+ public override async exec(...[member]: BushClientEvents['guildMemberAdd']): Promise<void> {
+ if (!client.config.isProduction) return;
+ if (member.guild.id !== client.consts.mappings.guilds.bush) return;
+ const guild = member.guild;
+
+ if (member.user.username === 'NotEnoughUpdates') {
+ if (moment(member.user.createdAt).isBefore(moment().subtract(7, 'days'))) {
+ return client.console.warn(
+ 'nameAutoBan',
+ `<<${member.user.tag}>> has not been banned because their account is older than 7 days.`
+ );
+ }
+
+ const res = await member.bushBan({
+ reason: "[AutoBan] 'NotEnoughUpdates' is a blacklisted name for this server.",
+ moderator: member.guild.me!
+ });
+
+ if (!['success', 'failed to dm'].includes(res)) {
+ return await guild.error(
+ 'nameAutoBan',
+ `Failed to autoban ${util.format.input(member.user.tag)} for 'NotEnoughUpdates', with error: ${util.format.input(res)}.`
+ );
+ }
+
+ await guild.sendLogChannel('automod', {
+ embeds: [
+ {
+ title: 'Name Auto Ban',
+ description: `**User:** ${member.user} (${member.user.tag})\n **Action:** Banned for using the blacklisted name 'NotEnoughUpdates'.`,
+ color: client.consts.colors.red,
+ author: {
+ name: member.user.tag,
+ iconURL: member.displayAvatarURL({ dynamic: true })
+ }
+ }
+ ]
+ });
+
+ const content =
+ res === 'failed to dm'
+ ? `${util.emojis.warn} Banned ${util.format.input(member.user.tag)} however I could not send them a dm.`
+ : `${util.emojis.success} Successfully banned ${util.format.input(member.user.tag)}.`;
+
+ (<BushTextChannel>guild.channels.cache.find((c) => c.name === 'general'))
+ ?.send({ content, allowedMentions: AllowedMentions.none() })
+ .catch(() => {});
+ }
+ }
+}