n8n-nodes-discord-self
Version:
n8n community nodes for Discord selfbot via discord.js-selfbot-v13 (use at your own risk)
30 lines • 922 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOrCreateClient = getOrCreateClient;
exports.destroyClientForToken = destroyClientForToken;
const discord_js_selfbot_v13_1 = require("discord.js-selfbot-v13");
const tokenToClient = new Map();
async function getOrCreateClient(token) {
let entry = tokenToClient.get(token);
if (!entry) {
const client = new discord_js_selfbot_v13_1.Client();
entry = { client };
tokenToClient.set(token, entry);
entry.loginPromise = client.login(token);
}
if (entry.loginPromise)
await entry.loginPromise;
return entry.client;
}
function destroyClientForToken(token) {
const entry = tokenToClient.get(token);
if (!entry)
return;
try {
entry.client.destroy();
}
finally {
tokenToClient.delete(token);
}
}
//# sourceMappingURL=ClientManager.js.map