Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 480d2d4

Browse files
author
Calvin Rohloff
committed
✨ Added token loading
1 parent 1e56a05 commit 480d2d4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ npm install
1010

1111
## Starting Development
1212

13+
Add your discord token into the 'user' file:
14+
15+
Windows: `%APPDATA%/WaveCord/user`
16+
17+
Linux: `~/.config/WaveCord/user`
18+
19+
Mac: `~/Library/Application Support/WaveCord/user`
20+
21+
#
22+
1323
Start the app in the `dev` environment:
1424

1525
```bash

src/main/app.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable global-require */
22
import { app, BrowserWindow, shell } from 'electron';
3+
import fs from 'fs';
34
import path from 'path';
45

56
export default class WaveCordApp {
@@ -12,7 +13,11 @@ export default class WaveCordApp {
1213

1314
public window: BrowserWindow | null = null;
1415

16+
public token: string = '';
17+
1518
public constructor() {
19+
app.setPath('userData', path.join(app.getPath('appData'), 'WaveCord'));
20+
1621
this.resourcesPath = app.isPackaged
1722
? path.join(process.resourcesPath, 'assets')
1823
: path.join(__dirname, '../../../assets');
@@ -23,6 +28,8 @@ export default class WaveCordApp {
2328
return;
2429
}
2530

31+
this.loadUser();
32+
2633
app.on('ready', async () => {
2734
await this.init();
2835
});
@@ -88,6 +95,13 @@ export default class WaveCordApp {
8895
});
8996
}
9097

98+
private loadUser() {
99+
const filePath = `${app.getPath('userData')}//user`;
100+
if (!fs.existsSync(filePath)) fs.writeFileSync(filePath, '', 'binary');
101+
102+
this.token = fs.readFileSync(filePath, 'utf8');
103+
}
104+
91105
private static resolveHtmlPath(htmlFileName: string) {
92106
if (process.env.NODE_ENV === 'development') {
93107
const port = process.env.PORT || 1212;

0 commit comments

Comments
 (0)