aboutsummaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-30 15:08:04 -0400
committerAndrew Lee <andrew@alee14.me>2025-03-30 15:08:04 -0400
commit3c61c156137984cf61d3517d4d9633ca6de072f6 (patch)
treea9b76008d5fdff44ba3c91d26ae7c82c94267c3a /bot/src
parent070825d2b779b114a1c345fbca210d324bf34d53 (diff)
downloadAleeBot-3c61c156137984cf61d3517d4d9633ca6de072f6.tar.gz
AleeBot-3c61c156137984cf61d3517d4d9633ca6de072f6.tar.bz2
AleeBot-3c61c156137984cf61d3517d4d9633ca6de072f6.zip
Bot now scans for threads and automatically joins them
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/events/ClientReady.js18
-rw-r--r--bot/src/events/ThreadCreate.js8
-rw-r--r--bot/src/events/ThreadListSync.js13
3 files changed, 39 insertions, 0 deletions
diff --git a/bot/src/events/ClientReady.js b/bot/src/events/ClientReady.js
index 9669287..b97af1f 100644
--- a/bot/src/events/ClientReady.js
+++ b/bot/src/events/ClientReady.js
@@ -32,6 +32,24 @@ export default {
await botActivity(client);
await QuoteOfTheDay(client);
+ await client.guilds.cache.forEach(guild => {
+ let threadCount = 0;
+
+ guild.channels.cache.forEach(channel => {
+ if (channel.threads) {
+ threadCount += channel.threads.cache.size;
+ channel.threads.cache.forEach(thread => {
+ if (!thread.members.cache.has(client.user.id)) {
+ thread.join()
+ .catch(error => console.error(`[X] Failed to join thread ${thread.name}:`, error));
+ }
+ });
+ }
+ });
+
+ console.log(`[>] Processed threads in guild: ${guild.name} | ${threadCount} Threads`);
+ });
+
if (process.env.NODE_ENV !== 'development') {
const readyEmbed = new EmbedBuilder()
.setAuthor({name: 'AleeBot Status', iconURL: client.user.avatarURL()})
diff --git a/bot/src/events/ThreadCreate.js b/bot/src/events/ThreadCreate.js
new file mode 100644
index 0000000..61cb217
--- /dev/null
+++ b/bot/src/events/ThreadCreate.js
@@ -0,0 +1,8 @@
+import { Events } from 'discord.js';
+
+export default {
+ name: Events.ThreadCreate,
+ async execute(thread) {
+ await thread.join(thread.id);
+ }
+};
diff --git a/bot/src/events/ThreadListSync.js b/bot/src/events/ThreadListSync.js
new file mode 100644
index 0000000..00657e6
--- /dev/null
+++ b/bot/src/events/ThreadListSync.js
@@ -0,0 +1,13 @@
+import { Events } from 'discord.js';
+
+export default {
+ name: Events.ThreadListSync,
+ async execute(threads) {
+ await threads.forEach(thread => {
+ if (!thread.members.cache.has(threads.client.user.id)) {
+ thread.join()
+ .catch(error => console.error(`[X] Failed to join thread ${thread.name}:`, error));
+ }
+ });
+ }
+};