Skip to content

Commit

Permalink
remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Sep 13, 2023
1 parent 48c37f6 commit 247f112
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,37 @@ class RPCClient {
));

this.client.login({ clientId: this.clientId }).catch(() => this.destroy());

console.log(`[RPC] Client ${this.clientId} created`);
}

setActivity(presenceData) {
presenceData = presenceData ? presenceData : this.currentPresence;

presenceData.presenceData.largeImageText = 'Debloat PreMiD v7.2.7';

if(!this.clientReady || !presenceData) return;
if (!this.clientReady || !presenceData) return;

this.client.setActivity(presenceData.presenceData).catch(() => this.destroy());

console.log(`[RPC] Client ${this.clientId} set activity`);
}

clearActivity() {
this.currentPresence = null;

if(!this.clientReady) return;
if (!this.clientReady) return;

this.client.clearActivity().catch(() => this.destroy());
}

async destroy() {
try {
if(this.clientReady) {
if (this.clientReady) {
this.client.clearActivity();
this.client.destroy();
}

rpcClients = rpcClients.filter(client => client.clientId !== this.clientId);

console.log(`[RPC] Client ${this.clientId} destroyed`);
} catch(err) { console.error(err); }
} catch (err) {
console.error(err);
}
}
}

Expand All @@ -91,23 +87,22 @@ async function getDiscordUser() {
const client = new Client({ transport: 'ipc' });
client.login({ clientId: '503557087041683458' })
.then(({ user }) => {
client.destroy()
.then(() => resolve(user))
client.destroy().then(() => resolve(user))
}).catch(err => reject(err));
});
}

function setActivity(presence) {
let client = rpcClients.find(client => client.clientId === presence.clientId);

if(!client) {
if (!client) {
client = new RPCClient(presence.clientId);
client.currentPresence = presence;
} else client.setActivity(presence);
}

function clearActivity(clientId) {
if(clientId) {
if (clientId) {
let client = rpcClients.find(client => client.clientId === clientId);
client.clearActivity();
} else rpcClients.forEach(client => client.clearActivity());
Expand All @@ -118,9 +113,8 @@ function socketError(err) {
}

function socketDisconnect() {
console.log('[SOCKET] Disconnected');
rpcClients.forEach(client => client.destroy());
}

process.on('uncaughtException', console.error);
process.on('unhandledRejection', console.error);
process.on('unhandledRejection', console.error);

0 comments on commit 247f112

Please sign in to comment.