Brozy123 commited on
Commit
5051322
·
verified ·
1 Parent(s): 965a9ca

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +29 -6
index.js CHANGED
@@ -112,13 +112,36 @@ client.once('ready', async () => {
112
  console.error(`[!] Command Sync Error: ${e.message}`);
113
  }
114
 
115
- // Auto-Scan Pending Polls & Cleanup
116
- for (const guild of client.guilds.cache.values()) {
117
- const backupChannel = guild.channels.cache.find(c => c.name === 'friendlybot-storage');
118
- if (backupChannel) {
119
- backupChannel.delete().catch(() => {});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
121
- }
122
  });
123
 
124
 
 
112
  console.error(`[!] Command Sync Error: ${e.message}`);
113
  }
114
 
115
+ // Auto-Friendly Background Loop
116
+ setInterval(async () => {
117
+ const now = Date.now();
118
+ for (const guild of client.guilds.cache.values()) {
119
+ const config = storage.data.config[guild.id];
120
+ if (config?.autoFriendlyEnabled && config?.autoFriendlyChannel) {
121
+ const intervalMs = (config.autoFriendlyInterval || 40) * 60000;
122
+ const lastRun = config.lastAutoFriendly || 0;
123
+
124
+ if (now - lastRun >= intervalMs) {
125
+ try {
126
+ const channel = await guild.channels.fetch(config.autoFriendlyChannel).catch(() => null);
127
+ if (channel && channel.isTextBased()) {
128
+ const needed = 7;
129
+ const content = `⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: ${needed}\n@everyone`;
130
+ const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
131
+ await msg.react('🟩');
132
+ await msg.react('🟥');
133
+ storage.data.active_polls[guild.id] = msg.id;
134
+ config.lastAutoFriendly = now;
135
+ storage.save('config');
136
+ storage.save('active_polls');
137
+ }
138
+ } catch (err) {
139
+ console.error(`Auto-friendly error in ${guild.name}:`, err);
140
+ }
141
+ }
142
+ }
143
  }
144
+ }, 60000); // Check every minute
145
  });
146
 
147