aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/automod
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-18 22:42:12 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-08-18 22:42:12 -0400
commit2356d2c44736fb83021dacb551625852111c8ce6 (patch)
tree10408d22fdd7a358d2f5c5917c3b59e55aa4c19d /src/listeners/automod
parent8aed6f93f7740c592cbc0e2f9fd3269c05286077 (diff)
downloadtanzanite-2356d2c44736fb83021dacb551625852111c8ce6.tar.gz
tanzanite-2356d2c44736fb83021dacb551625852111c8ce6.tar.bz2
tanzanite-2356d2c44736fb83021dacb551625852111c8ce6.zip
restructure, experimental presence and member automod, fixed bugs probably made some more bugs
Diffstat (limited to 'src/listeners/automod')
-rw-r--r--src/listeners/automod/automodCreate.ts16
-rw-r--r--src/listeners/automod/automodUpdate.ts17
-rw-r--r--src/listeners/automod/memberAutomod.ts21
-rw-r--r--src/listeners/automod/presenceAutomod.ts27
4 files changed, 81 insertions, 0 deletions
diff --git a/src/listeners/automod/automodCreate.ts b/src/listeners/automod/automodCreate.ts
new file mode 100644
index 0000000..529651c
--- /dev/null
+++ b/src/listeners/automod/automodCreate.ts
@@ -0,0 +1,16 @@
+import { BushListener, MessageAutomod, type BushClientEvents } from '#lib';
+
+export default class AutomodMessageCreateListener extends BushListener {
+ public constructor() {
+ super('automodCreate', {
+ emitter: 'client',
+ event: 'messageCreate',
+ category: 'message'
+ });
+ }
+
+ public async exec(...[message]: BushClientEvents['messageCreate']) {
+ if (message.member === null) return;
+ return new MessageAutomod(message);
+ }
+}
diff --git a/src/listeners/automod/automodUpdate.ts b/src/listeners/automod/automodUpdate.ts
new file mode 100644
index 0000000..d68759f
--- /dev/null
+++ b/src/listeners/automod/automodUpdate.ts
@@ -0,0 +1,17 @@
+import { BushListener, MessageAutomod, type BushClientEvents } from '#lib';
+
+export default class AutomodMessageUpdateListener extends BushListener {
+ public constructor() {
+ super('automodUpdate', {
+ emitter: 'client',
+ event: 'messageUpdate',
+ category: 'message'
+ });
+ }
+
+ public async exec(...[_, newMessage]: BushClientEvents['messageUpdate']) {
+ const fullMessage = newMessage.partial ? await newMessage.fetch().catch(() => null) : newMessage;
+ if (!fullMessage?.member) return;
+ return new MessageAutomod(fullMessage);
+ }
+}
diff --git a/src/listeners/automod/memberAutomod.ts b/src/listeners/automod/memberAutomod.ts
new file mode 100644
index 0000000..01eb56c
--- /dev/null
+++ b/src/listeners/automod/memberAutomod.ts
@@ -0,0 +1,21 @@
+import { BushClientEvents, BushListener, MemberAutomod } from '#lib';
+import chalk from 'chalk';
+
+export default class PresenceAutomodListener extends BushListener {
+ public constructor() {
+ super('memberAutomod', {
+ emitter: 'client',
+ event: 'guildMemberUpdate'
+ });
+ }
+
+ public async exec(...[_, newMember]: BushClientEvents['guildMemberUpdate']) {
+ if (!(await newMember.guild.hasFeature('automodMembers'))) return;
+ if (!(await newMember.guild.hasFeature('automod'))) return;
+
+ new MemberAutomod(newMember);
+ console.log(
+ `${chalk.hex('#ff7105')('[MemberAutomod]')} Created a new MemberAutomod for ${newMember.user.tag} (${newMember.user.id})`
+ );
+ }
+}
diff --git a/src/listeners/automod/presenceAutomod.ts b/src/listeners/automod/presenceAutomod.ts
new file mode 100644
index 0000000..f361508
--- /dev/null
+++ b/src/listeners/automod/presenceAutomod.ts
@@ -0,0 +1,27 @@
+import { BushClientEvents, BushListener, PresenceAutomod } from '#lib';
+import chalk from 'chalk';
+
+/* export default */ class PresenceAutomodListener extends BushListener {
+ public constructor() {
+ super('presenceAutomod', {
+ emitter: 'client',
+ event: 'presenceUpdate'
+ });
+ }
+
+ public async exec(...[_, newPresence]: BushClientEvents['presenceUpdate']) {
+ if (!newPresence.member || !newPresence.guild) return;
+
+ if (!newPresence.activities.length) return;
+
+ if (!(await newPresence.guild.hasFeature('automodPresence'))) return;
+ if (!(await newPresence.guild.hasFeature('automod'))) return;
+
+ new PresenceAutomod(newPresence);
+ console.log(
+ `${chalk.hex('#ffe605')('[PresenceAutomod]')} Created a new PresenceAutomod for ${newPresence.member.user.tag} (${
+ newPresence.member.user.id
+ })`
+ );
+ }
+}