Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
const WebSocket = require("ws");
const axios = require("axios");
// Güvenli şekilde saklamanız gereken tokenler
const BOT_TOKEN = "MTI3NTg3MTQyNTg2NDkyNTM1MQ.GWtrdk.dLADDdJ3KM74z6eOaTB_rRY18boXHBd0ad_zy4"; // Bot tokeni burada saklıyoruz
const CHANNEL_ID = "1275902424246386771"; // Channel ID
const GUILD_ID = "275725540787097632"; // Guild ID
let vanity;
let websocket;
let guilds = {};
// API isteği yapma fonksiyonu
async function sendDiscordAPIRequest(method, path, body = null) {
const url = `https://discord.com/api/v9${path}`;
const headers = {
"Authorization": `Bot ${BOT_TOKEN}`, // BOT_TOKEN burada kullanılıyor
"Content-Type": "application/json",
};
const options = {
method,
url,
headers,
data: body,
};
return axios(options);
}
// Guild vanity URL güncelleme fonksiyonu
async function updateGuildVanityUrl(code) {
console.log(`Updating vanity URL with code: ${code}`);
try {
const response = await sendDiscordAPIRequest("PATCH", `/guilds/${GUILD_ID}/vanity-url`, { code });
console.log("Vanity URL successfully updated:", response.data);
} catch (error) {
console.error("Failed to update vanity URL:", error.response ? error.response.data : error.message);
}
}
// WebSocket mesajını işleyen fonksiyon
function handleWebSocketMessage(message) {
const { d, op, t } = JSON.parse(message.data);
if (t === "GUILD_UPDATE") {
handleGuildUpdate(d);
} else if (t === "READY") {
d.guilds.forEach(({ id, vanity_url_code, name }) => {
if (vanity_url_code) {
guilds[id] = vanity_url_code;
console.log(`Guild ${name} added with vanity URL code: ${vanity_url_code}`);
} else {
console.log(`Guild ${name} has no vanity URL code.`);
}
});
console.log("Guilds loaded:", guilds);
}
if (op === 10) {
const identifyPayload = {
op: 2,
d: {
token: BOT_TOKEN, // BOT_TOKEN burada kullanılıyor
intents: 1,
properties: {
os: "macos",
browser: "firefox",
device: "mybot",
},
},
};
websocket.send(JSON.stringify(identifyPayload));
}
}
// Guild güncellemelerini işleyen fonksiyon
function handleGuildUpdate(data) {
const currentVanity = guilds[data.guild_id];
if (currentVanity && currentVanity !== data.vanity_url_code) {
const start = Date.now();
updateGuildVanityUrl(currentVanity);
const end = Date.now();
vanity = `${currentVanity} update in ${end - start}ms`;
console.log(`Vanity URL updated: ${vanity}`);
} else {
console.log("No change in vanity URL or vanity URL not found.");
}
}
// WebSocket bağlantısını kuran fonksiyon
function setupWebSocket() {
websocket = new WebSocket("wss://gateway.discord.gg/?v=10&encoding=json");
websocket.onopen = () => {
console.log("WebSocket connection established");
};
websocket.onmessage = handleWebSocketMessage;
websocket.onclose = (event) => {
console.log(`WebSocket connection closed: ${event.reason} (${event.code})`);
setTimeout(setupWebSocket, 5000);
};
websocket.onerror = (error) => {
console.error("WebSocket error:", error);
};
}
setupWebSocket();
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team