Spaces:
Runtime error
Runtime error
Create emergency_handler.js
Browse files- emergency_handler.js +37 -0
emergency_handler.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* emergency_handler.js
|
| 3 |
+
* A lightweight, high-priority command listener to ensure the bot responds.
|
| 4 |
+
*/
|
| 5 |
+
console.log(">>> [DEBUG] Emergency Handler loading...");
|
| 6 |
+
|
| 7 |
+
module.exports = function(client) {
|
| 8 |
+
client.on('messageCreate', async (message) => {
|
| 9 |
+
// Ignore bots
|
| 10 |
+
if (message.author.bot) return;
|
| 11 |
+
|
| 12 |
+
const content = message.content.toLowerCase();
|
| 13 |
+
|
| 14 |
+
// 1. Simple word-match test (No prefix needed)
|
| 15 |
+
if (content === 'ping') {
|
| 16 |
+
console.log(`[DEBUG] Received 'ping' from ${message.author.tag}`);
|
| 17 |
+
return message.reply('pong! I am alive and listening. 🚀');
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// 2. Simple prefix test (!test)
|
| 21 |
+
if (content === '!test') {
|
| 22 |
+
console.log(`[DEBUG] Received '!test' from ${message.author.tag}`);
|
| 23 |
+
return message.reply('✅ Success! The emergency prefix handler is working.');
|
| 24 |
+
}
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
client.on('interactionCreate', async (interaction) => {
|
| 28 |
+
if (!interaction.isChatInputCommand()) return;
|
| 29 |
+
|
| 30 |
+
if (interaction.commandName === 'ping') {
|
| 31 |
+
console.log(`[DEBUG] Received Slash Command /ping from ${interaction.user.tag}`);
|
| 32 |
+
await interaction.reply('🚀 Slash commands are working! Latency: ' + client.ws.ping + 'ms');
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
console.log(">>> [DEBUG] Emergency Handler active. Try typing 'ping' in Discord.");
|
| 37 |
+
};
|