Spaces:
Runtime error
Runtime error
Update bot.js
Browse files
bot.js
CHANGED
|
@@ -29,11 +29,68 @@ client.on("messageCreate", (message) => {
|
|
| 29 |
const content = message.content.trim();
|
| 30 |
const prefix = "!";
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if (content === `${prefix}ping`) {
|
| 33 |
message.reply(`Pong! Latency: ${client.ws.ping}ms`);
|
| 34 |
return;
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
// !roster-add @User Role [in Team Name]
|
| 38 |
if (content.startsWith(`${prefix}roster-add`)) {
|
| 39 |
const fullText = content.slice(`${prefix}roster-add`.length).trim();
|
|
@@ -85,4 +142,4 @@ client.on("interactionCreate", async (interaction) => {
|
|
| 85 |
}
|
| 86 |
});
|
| 87 |
|
| 88 |
-
module.exports = { client };
|
|
|
|
| 29 |
const content = message.content.trim();
|
| 30 |
const prefix = "!";
|
| 31 |
|
| 32 |
+
// Track command usage
|
| 33 |
+
db.trackServerActivity(message.guildId, message.guild?.name || "Unknown", message.guild?.memberCount || 0);
|
| 34 |
+
db.trackCommandUsage(message.guildId, message.author.id, message.author.tag, content.split(" ")[0]);
|
| 35 |
+
|
| 36 |
if (content === `${prefix}ping`) {
|
| 37 |
message.reply(`Pong! Latency: ${client.ws.ping}ms`);
|
| 38 |
return;
|
| 39 |
}
|
| 40 |
|
| 41 |
+
// !servers-info
|
| 42 |
+
if (content === `${prefix}servers-info`) {
|
| 43 |
+
const allServers = db.getServerStats();
|
| 44 |
+
const globalStats = db.getGlobalStats();
|
| 45 |
+
|
| 46 |
+
if (!allServers || allServers.length === 0) {
|
| 47 |
+
message.reply("No server data available yet.");
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
let embed = `\`\`\`
|
| 52 |
+
📊 SERVERS INFO - GLOBAL STATS
|
| 53 |
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 54 |
+
Total Servers: ${client.guilds.cache.size}
|
| 55 |
+
Total Commands Used: ${globalStats?.total_commands || 0}
|
| 56 |
+
Active Users: ${globalStats?.total_users || 0}
|
| 57 |
+
\`\`\`\n`;
|
| 58 |
+
|
| 59 |
+
embed += `\n**📍 Server Activity (Top 10):**\n`;
|
| 60 |
+
|
| 61 |
+
allServers.slice(0, 10).forEach((server, index) => {
|
| 62 |
+
embed += `\n**${index + 1}. ${server.guild_name}** (ID: ${server.guild_id})\n`;
|
| 63 |
+
embed += ` • Members: ${server.member_count || 'N/A'}\n`;
|
| 64 |
+
embed += ` • Commands: ${server.commands_used}\n`;
|
| 65 |
+
embed += ` • Last Activity: <t:${Math.floor(new Date(server.last_activity).getTime() / 1000)}:R>\n`;
|
| 66 |
+
|
| 67 |
+
// Get top 5 command users for this server
|
| 68 |
+
const topUsers = db.getTopCommandUsers(server.guild_id, 5);
|
| 69 |
+
if (topUsers && topUsers.length > 0) {
|
| 70 |
+
embed += ` • Top Users:\n`;
|
| 71 |
+
topUsers.forEach((user, idx) => {
|
| 72 |
+
embed += ` ${idx + 1}. ${user.user_tag} (${user.count} commands)\n`;
|
| 73 |
+
});
|
| 74 |
+
}
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
embed += `\n\n**📋 All Connected Servers:**\n`;
|
| 78 |
+
const allConnectedServers = client.guilds.cache.map(guild => `• ${guild.name} (${guild.memberCount} members)`).join("\n");
|
| 79 |
+
|
| 80 |
+
if (allConnectedServers.length > 2000) {
|
| 81 |
+
embed += allConnectedServers.substring(0, 2000) + "...\n*(List truncated - too many servers)*";
|
| 82 |
+
} else {
|
| 83 |
+
embed += allConnectedServers;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if (embed.length > 2000) {
|
| 87 |
+
message.reply(embed.substring(0, 1990) + "...");
|
| 88 |
+
} else {
|
| 89 |
+
message.reply(embed);
|
| 90 |
+
}
|
| 91 |
+
return;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
// !roster-add @User Role [in Team Name]
|
| 95 |
if (content.startsWith(`${prefix}roster-add`)) {
|
| 96 |
const fullText = content.slice(`${prefix}roster-add`.length).trim();
|
|
|
|
| 142 |
}
|
| 143 |
});
|
| 144 |
|
| 145 |
+
module.exports = { client };
|