Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto committed Apr 22, 2024
1 parent 4dd4d67 commit 86a1c28
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 477 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.5

* Fixed the tray icon not showing (#34)
* Upgraded packages
* Updated build script

## 1.2.4

* Fixed the RPC not working (yes, again.)
Expand Down
11 changes: 7 additions & 4 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ const config = {
]
};

builder.build({
const options = {
config,
mac: ['dmg'],
win: ['nsis'],
linux: ['snap', 'deb', 'AppImage'],
x64: true,
publish: 'never',
}).then(() => {
};
if (process.platform === 'darwin') options.mac = ['dmg'];
// Linux programs like chmod are not supported on Windows
if (process.platform !== 'win32') options.linux = ['snap', 'deb', 'AppImage'];

builder.build(options).then(() => {
console.log('\nSetup built in the "dist" folder.');
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deezer-discord-rpc",
"version": "1.2.4",
"version": "1.2.5",
"description": "A Discord RPC for Deezer",
"main": "./build/src/index.js",
"scripts": {
Expand All @@ -13,18 +13,18 @@
"copy-assets": "cpy ./src/img/* ./build/src/img/ && cpy ./src/prompt.html ./build/"
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.26.2",
"axios": "^1.6.3",
"@cliqz/adblocker-electron": "^1.27.1",
"axios": "^1.6.8",
"chalk": "4.1.2",
"discord-rpc": "^4.0.1",
"discord.js-selfbot-v13": "^2.14.9"
},
"devDependencies": {
"@types/discord-rpc": "^4.0.0",
"@types/node": "^18.7.6",
"@types/discord-rpc": "^4.0.8",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"cpy-cli": "^4.2.0",
"cpy-cli": "^5.0.0",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"eslint": "^8.56.0",
Expand Down
20 changes: 17 additions & 3 deletions src/utils/RPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ import { log } from './Log';
import { clientId } from '../variables';

export const client = new RPC.Client({
transport: 'ipc'
transport: 'ipc',
});

export function connect() {
client.on('ready', () => {
log('RPC', `Authed for user ${client.user?.username}#${client.user?.discriminator}`);
log('RPC', `Authed for user @${client.user?.username}`);
});

client.on('disconnected', () => {
log('RPC', 'Disconnected, trying to reconnect...');
const attempts = 0;
const attemptsInterval = setInterval(() => {
client.login({ clientId }).then(() => {
clearInterval(attemptsInterval);
}).catch(console.error);
log('RPC', `Reconnecting... Attempt ${attempts + 1}`);
if (attempts >= 5) {
clearInterval(attemptsInterval);
}
}, 8000);
});

client.login({ clientId }).catch(console.error);
Expand All @@ -18,4 +32,4 @@ export async function disconnect() {
log('RPC', 'Disconnecting...');
await client.clearActivity(process.pid);
await client.destroy().then(() => log('RPC', 'Disconnected'));
}
}
16 changes: 11 additions & 5 deletions src/utils/Tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ export async function init(app: Electron.App, client: import('discord-rpc').Clie
click: (menuItem) => Config.set(app, 'only_show_if_playing', menuItem.checked)
},
{
label: Config.get(app, 'use_listening_to') ? 'Reconnect to WebSocket' : 'Reconnect RPC', type: 'normal',
click: () => {
id: 'reconnect',
label: Config.get(app, 'use_listening_to') ? 'Reconnect to WebSocket' : 'Reconnect RPC',
type: 'normal',
visible: false, // how tf do I reconnect to the fcking ipc
click: (menuItem) => {
(
Config.get(app, 'use_listening_to') ?
DiscordWebSocket.connect(Config.get(app, 'discord_token'), app).catch((e) => log('WebSocket', e.toString())) :
client.connect(clientId)
client.login({ clientId })
)
.then(() => log(Config.get(app, 'use_listening_to') ? 'WebSocket' : 'RPC', 'Reconnected'))
.then(() => {
log(Config.get(app, 'use_listening_to') ? 'WebSocket' : 'RPC', 'Reconnected');
menuItem.label = Config.get(app, 'use_listening_to') ? 'Reconnect to WebSocket' : 'Reconnect RPC';
})
.catch(console.error);
}
},
Expand Down Expand Up @@ -79,7 +85,7 @@ export async function init(app: Electron.App, client: import('discord-rpc').Clie
{ type: 'separator' },
{
label: 'Quit', type: 'normal', click: async () => {
Config.get(app, 'use_listening_to') ? DiscordWebSocket.disconnect() : await RPC.disconnect();
Config.get(app, 'use_listening_to') ? DiscordWebSocket.disconnect() : RPC.disconnect().catch(console.error);
win.close();
app.quit();
process.exit(0);
Expand Down
Loading

0 comments on commit 86a1c28

Please sign in to comment.