Add console command
This commit is contained in:
parent
7ca36a4938
commit
b15f7097f8
51
index.js
51
index.js
@ -2,6 +2,7 @@ require('dotenv').config();
|
||||
const { Client } = require('discord.js-selfbot-v13');
|
||||
const client = new Client();
|
||||
const fs = require('fs');
|
||||
const readline = require('readline');
|
||||
|
||||
const PREFIX = process.env.PREFIX || '.';
|
||||
const MESSAGE_DELETE_TIMEOUT = 10000
|
||||
@ -16,6 +17,56 @@ for (const file of commandFiles) {
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`Logged in as ${client.user.tag}! (DZ Loves you 2k25).`);
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
prompt: `Console > `
|
||||
});
|
||||
|
||||
console.log('Type commands without the prefix to execute them in console mode.');
|
||||
console.log('--------------------------------------------------------');
|
||||
rl.prompt();
|
||||
|
||||
rl.on('line', async (line) => {
|
||||
const input = line.trim();
|
||||
if (!input) {
|
||||
rl.prompt();
|
||||
return;
|
||||
}
|
||||
|
||||
const args = input.split(/ +/);
|
||||
const commandName = args.shift().toLowerCase();
|
||||
|
||||
if (!client.commands.has(commandName)) {
|
||||
console.log(`Command not found: ${commandName}`);
|
||||
rl.prompt();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const mockMessage = {
|
||||
author: { id: client.user.id },
|
||||
client: client,
|
||||
channel: {
|
||||
id: 'console',
|
||||
send: (content) => {
|
||||
console.log('\nCommand output:');
|
||||
console.log(content);
|
||||
return Promise.resolve({ delete: () => Promise.resolve() });
|
||||
}
|
||||
},
|
||||
delete: () => Promise.resolve()
|
||||
};
|
||||
|
||||
console.log(`Executing command: ${commandName}`);
|
||||
await client.commands.get(commandName).execute(mockMessage, args, MESSAGE_DELETE_TIMEOUT);
|
||||
} catch (error) {
|
||||
console.error('Error executing command:', error);
|
||||
}
|
||||
|
||||
rl.prompt();
|
||||
});
|
||||
});
|
||||
|
||||
client.on('messageCreate', async message => {
|
||||
|
@ -1,21 +1,21 @@
|
||||
const getHumanizedDeleteDelay = (baseDelay = 5000) => {
|
||||
// Add randomness to deletion timing for more human-like behavior
|
||||
const jitter = Math.floor(Math.random() * 2000) - 1000; // -1000 to +1000ms jitter
|
||||
const jitter = Math.floor(Math.random() * 2000) - 1000;
|
||||
return Math.max(1500, baseDelay + jitter);
|
||||
};
|
||||
|
||||
const sendTempMessage = async (channel, content, baseDeleteDelay = 5000) => {
|
||||
if (channel.id === 'console') {
|
||||
return channel.send(content);
|
||||
}
|
||||
|
||||
try {
|
||||
const deleteDelay = getHumanizedDeleteDelay(baseDeleteDelay);
|
||||
const sentMessage = await channel.send(content);
|
||||
|
||||
// Log what's happening for debugging
|
||||
console.log(`[MESSAGE] Sending temp message in ${channel.id}, will delete in ${deleteDelay}ms`);
|
||||
|
||||
// Simulate a human, occasionally delayed deletion
|
||||
setTimeout(() => {
|
||||
if (Math.random() < 0.1) {
|
||||
// 10% chance for an extra delay (simulates forgetting to delete immediately)
|
||||
const extraDelay = Math.floor(Math.random() * 3000) + 1000;
|
||||
console.log(`[MESSAGE] Adding ${extraDelay}ms extra delay before deletion`);
|
||||
setTimeout(() => sentMessage.delete().catch(err => console.error('[MESSAGE] Delete error:', err)), extraDelay);
|
||||
@ -32,10 +32,8 @@ const sendTempMessage = async (channel, content, baseDeleteDelay = 5000) => {
|
||||
};
|
||||
|
||||
const sendCommandResponse = async (message, content, baseDeleteDelay = 5000, deleteOriginal = true) => {
|
||||
// Delete original command message if requested
|
||||
if (deleteOriginal) {
|
||||
try {
|
||||
// Add small delay before deleting command, like a human would
|
||||
const cmdDeleteDelay = Math.floor(Math.random() * 1000) + 500;
|
||||
setTimeout(() => message.delete().catch(() => {}), cmdDeleteDelay);
|
||||
} catch (error) {
|
||||
@ -43,7 +41,6 @@ const sendCommandResponse = async (message, content, baseDeleteDelay = 5000, del
|
||||
}
|
||||
}
|
||||
|
||||
// Send and schedule deletion of response
|
||||
return await sendTempMessage(message.channel, content, baseDeleteDelay);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user