Index Js
Index Js
// Configuration
const config = {
token:
"MTI2NDQ3NjY1NzE2Nzc2MTQ2NQ.G_qUBt.YORMgagSpsG94G_1kvJ9WbWRMtuh0EdCMvJPjw", //
User token
guilds: [
{ id: "1242935750698467368", specialUrl: "19977" },
{ id: "1242935750698467368", specialUrl: "19977" },
{ id: "1242935750698467368", specialUrl: "19977" }
],
notificationChannelId: "1242935848597717073"
};
tlsSocket.on('secureConnect', () => {
console.log("Connected to Discord via TLS.");
websocket.onopen = () => {
console.log("WebSocket connection opened.");
websocket.send(JSON.stringify({
op: 2,
d: {
token,
properties: {
$os: 'linux',
$browser: 'node.js',
$device: 'node.js'
}
}
}));
};
if (t === 'READY') {
console.log("Ready event received.");
console.log("Connected to the following guilds:");
d.guilds.forEach(guild => console.log(`Guild ID: ${guild.id}`));
}
if (t === 'GUILD_UPDATE') {
console.log("GUILD_UPDATE event received.");
try {
const responses = await Promise.all(requestPromises);
await fetch(`https://discord.com/api/v9/channels/$
{notificationChannelId}/messages`, {
method: 'POST',
headers: {
'Authorization': token,
'Content-Type': 'application/json'
},
body: JSON.stringify({ content: logMessage })
});
} else {
console.log(`Special URL (${specialUrl}) is not available in guild $
{data.name}`);
if (setVanityUrlResponse.ok) {
console.log(`Successfully set the vanity URL for guild ID: $
{guildId}`);
} else {
console.error(`Failed to set the vanity URL for guild ID: $
{guildId}`);
}
}
}
} catch (error) {
console.error("Error processing guild update:", error.message);
}
}
};
});