OWOH-lmfao / index.js
RedValis's picture
Create index.js
c3e5539 verified
const { Client } = require('discord.js-selfbot-v13');
const http = require('http');
const client = new Client();
// Environment variables with fallbacks
const targetChannelId = process.env.TARGET_CHANNEL_ID || '1208789413006675978';
const discordToken = process.env.DISCORD_TOKEN;
const port = process.env.PORT || 8080;
let owoLoopInterval;
let isOwOLoopRunning = true;
let isProcessingSequence = false;
let sequenceState = 0;
// Create HTTP server for Hugging Face Spaces health checks
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
status: 'running',
bot: client.user?.tag || 'not logged in',
owoLoop: isOwOLoopRunning ? 'active' : 'paused',
sequence: isProcessingSequence ? 'processing' : 'idle'
}));
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
startOwOMessageLoop();
// Start HTTP server
server.listen(port, () => {
console.log(`HTTP server running on port ${port}`);
});
});
function startOwOMessageLoop() {
function sendOwOMessage() {
if (!isOwOLoopRunning || isProcessingSequence) return;
const channel = client.channels.cache.get(targetChannelId);
if (channel) {
channel.send('owo b').catch(console.error);
channel.send('owo h').catch(console.error);
}
scheduleNextMessage();
}
function scheduleNextMessage() {
if (!isOwOLoopRunning || isProcessingSequence) return;
const nusec = Math.floor(Math.random() * 10) + 1;
const delay = (15 + nusec) * 1000;
owoLoopInterval = setTimeout(sendOwOMessage, delay);
}
sendOwOMessage();
}
function stopOwOMessageLoop() {
isOwOLoopRunning = false;
if (owoLoopInterval) clearTimeout(owoLoopInterval);
}
function resumeOwOMessageLoop() {
if (!isOwOLoopRunning) {
isOwOLoopRunning = true;
startOwOMessageLoop();
}
}
function findHighestCode(content, start, end) {
const codeMatches = content.match(/`(\d{3})`/g);
if (!codeMatches) return null;
const codes = codeMatches.map(match => match.replace(/`/g, ''));
for (let i = start; i >= end; i--) {
const code = i.toString().padStart(3, '0');
if (codes.includes(code)) {
return code;
}
}
return null;
}
async function processSequence(channel) {
isProcessingSequence = true;
stopOwOMessageLoop();
await channel.send('owo inv');
sequenceState = 1;
setTimeout(() => {
if (isProcessingSequence) {
isProcessingSequence = false;
sequenceState = 0;
resumeOwOMessageLoop();
}
}, 30000);
}
client.on('messageCreate', async message => {
if (message.channel.id === targetChannelId && message.content.includes('⚠')) {
stopOwOMessageLoop();
message.channel.send('```diff\n- OWO loop paused due to verification```').catch(console.error);
message.channel.send('kms').catch(console.error);
}
if (message.channel.id === targetChannelId &&
message.content.includes('hunt is empowered by') &&
message.content.includes('[0/') &&
!isProcessingSequence) {
processSequence(message.channel);
}
if (message.channel.id === targetChannelId && isProcessingSequence) {
if (sequenceState === 1 && message.content.includes('Inventory')) {
setTimeout(async () => {
const code = findHighestCode(message.content, 57, 51);
if (code) {
await message.channel.send(`owo use ${code}`);
sequenceState = 2;
setTimeout(async () => {
const code = findHighestCode(message.content, 71, 65);
if (code) {
await message.channel.send(`owo use ${code}`);
}
setTimeout(async () => {
const code = findHighestCode(message.content, 78, 72);
if (code) {
await message.channel.send(`owo use ${code}`);
}
setTimeout(() => {
isProcessingSequence = false;
sequenceState = 0;
resumeOwOMessageLoop();
}, 1000);
}, 5000);
}, 5000);
}
}, 3000);
}
}
if (message.author.id === client.user.id) {
if (message.content.startsWith('$stopowo')) {
stopOwOMessageLoop();
message.channel.send('```diff\n- OWO loop stopped```').catch(console.error);
} else if (message.content.startsWith('$resumeowo')) {
resumeOwOMessageLoop();
message.channel.send('```diff\n+ OWO loop resumed```').catch(console.error);
}
}
});
// Error handling
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
process.on('uncaughtException', error => {
console.error('Uncaught exception:', error);
});
// Login with error handling
if (!discordToken) {
console.error('Error: DISCORD_TOKEN environment variable is required');
process.exit(1);
}
client.login(discordToken).catch(error => {
console.error('Login failed:', error);
process.exit(1);
});