Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -737,10 +737,29 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 737 |
const text = interaction.options.getString('message');
|
| 738 |
let count = 0;
|
| 739 |
for (const guild of client.guilds.cache.values()) {
|
| 740 |
-
const
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
}
|
| 745 |
}
|
| 746 |
await interaction.editReply({ content: `📢 Broadcasted to ${count} servers.` });
|
|
|
|
| 737 |
const text = interaction.options.getString('message');
|
| 738 |
let count = 0;
|
| 739 |
for (const guild of client.guilds.cache.values()) {
|
| 740 |
+
const config = storage.data.config[guild.id] || {};
|
| 741 |
+
|
| 742 |
+
// Check if this guild has disabled broadcasts
|
| 743 |
+
if (config.postEnabled === false) continue;
|
| 744 |
+
|
| 745 |
+
try {
|
| 746 |
+
// Check if a specific channel is set for broadcasts
|
| 747 |
+
let channel = null;
|
| 748 |
+
if (config.postChannelId) {
|
| 749 |
+
channel = await guild.channels.fetch(config.postChannelId).catch(() => null);
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
// Fallback to system channel or first text channel
|
| 753 |
+
if (!channel) {
|
| 754 |
+
channel = guild.systemChannel || guild.channels.cache.find(c => c.isTextBased());
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
if (channel) {
|
| 758 |
+
await channel.send(text).catch(() => {});
|
| 759 |
+
count++;
|
| 760 |
+
}
|
| 761 |
+
} catch (err) {
|
| 762 |
+
console.error(`Post error in ${guild.name}:`, err);
|
| 763 |
}
|
| 764 |
}
|
| 765 |
await interaction.editReply({ content: `📢 Broadcasted to ${count} servers.` });
|