mirror of
https://github.com/spacebarchat/spacebarchat.git
synced 2024-11-22 02:12:30 +01:00
Add discord rpc and npm
This commit is contained in:
parent
1cea515472
commit
7598e328c5
1
rpc/.gitignore
vendored
Normal file
1
rpc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/node_modules/
|
53
rpc/index.js
Normal file
53
rpc/index.js
Normal file
@ -0,0 +1,53 @@
|
||||
const { Client } = require("discord-rpc");
|
||||
|
||||
var startTimestamp = new Date();
|
||||
|
||||
async function reconnect() {
|
||||
try {
|
||||
await login();
|
||||
} catch (error) {
|
||||
console.error("discord not open:", error);
|
||||
setTimeout(async () => {
|
||||
await reconnect();
|
||||
}, 1000 * 10);
|
||||
}
|
||||
}
|
||||
|
||||
reconnect();
|
||||
|
||||
async function login() {
|
||||
console.log("login");
|
||||
|
||||
rpc = new Client({
|
||||
transport: "ipc",
|
||||
});
|
||||
|
||||
rpc.on("ready", () => {
|
||||
console.log("logged in: ", rpc.user.username);
|
||||
|
||||
rpc.setActivity({
|
||||
details: `A free open source discord-compatible platform`,
|
||||
state: `Collaboration open`,
|
||||
startTimestamp,
|
||||
smallImageKey: "flam3rboy",
|
||||
smallImageText: "Working",
|
||||
largeImageKey: "logo2",
|
||||
largeImageText: "Fosscord",
|
||||
instance: false,
|
||||
buttons: [
|
||||
{ label: "Discord", url: "https://discord.gg/ZrnGQP6p3d" },
|
||||
{
|
||||
label: "Repository",
|
||||
url: "https://github.com/fosscord/fosscord",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
rpc.on("disconnected", async () => {
|
||||
console.log("disconnected");
|
||||
await reconnect();
|
||||
});
|
||||
|
||||
return rpc.login({ clientId: "807686638742142988" });
|
||||
}
|
1547
rpc/package-lock.json
generated
Normal file
1547
rpc/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
rpc/package.json
Normal file
15
rpc/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "rpc",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord-rpc": "github:discordjs/rpc",
|
||||
"pm2": "^4.5.4"
|
||||
}
|
||||
}
|
1
rpc/start.bat
Normal file
1
rpc/start.bat
Normal file
@ -0,0 +1 @@
|
||||
node index.js
|
@ -27,7 +27,7 @@ IF ERRORLEVEL 1 (
|
||||
where /q node
|
||||
IF ERRORLEVEL 1 (
|
||||
ECHO Error: node is not installed.
|
||||
ECHO Please Install NodeJS from: https://nodejs.org/en/download/
|
||||
ECHO Please Install NodeJS from: https://nodejs.org/en/download
|
||||
ECHO And make sure its in the path
|
||||
GOTO :end
|
||||
)
|
||||
@ -35,7 +35,7 @@ IF ERRORLEVEL 1 (
|
||||
where /q pnpm
|
||||
IF ERRORLEVEL 1 (
|
||||
ECHO 'Error: pnpm is not installed.' >&2
|
||||
ECHO Please install npm from: https://pnpm.io
|
||||
ECHO Please install npm from: https://nodejs.org/en/download
|
||||
ECHO And make sure its in the path
|
||||
GOTO :end
|
||||
)
|
||||
@ -66,6 +66,19 @@ git clone https://github.com/fosscord/react-native-withcss react-native-withcss
|
||||
|
||||
echo {"folders":[{"path":"overview"},{"path":"cdn"},{"path":"api"},{"path":"gateway"},{"path":"media"},{"path":"server-util"},{"path":"ui"},{"path":"client"},{"path":"plugins"},{"path":"themes"},{"path":"landingpage"},{"path":"dashboard"},{"path":"support"},{"path":"css-mediaquery"},{"path":"react-native-withcss"}]}> fosscord.code-workspace
|
||||
|
||||
CHOICE /c yn /m "Do you want to install the Discord Rich Presence?"
|
||||
IF %ERRORLEVEL% == 2 GOTO :end
|
||||
cd ..
|
||||
cd rpc
|
||||
|
||||
npm install
|
||||
|
||||
npm i pm2 -g
|
||||
pm2 start --name rpc index.js
|
||||
pm2 save
|
||||
pm2-startup install
|
||||
:end
|
||||
|
||||
ECHO finished installation
|
||||
@ECHO on
|
||||
PAUSE
|
||||
|
@ -25,13 +25,13 @@ if ! [ -x "$(command -v git)" ]; then
|
||||
fi
|
||||
if ! [ -x "$(command -v node)" ]; then
|
||||
echo Error: node is not installed.
|
||||
echo Please Install NodeJS from: https://nodejs.org/en/download/
|
||||
echo Please Install NodeJS from: https://nodejs.org/en/download
|
||||
echo And make sure its in the path
|
||||
exit 1
|
||||
fi
|
||||
if ! [ -x "$(command -v pnpm)" ]; then
|
||||
echo 'Error: npm is not installed.' >&2
|
||||
echo Please install npm from: https://pnpm.io
|
||||
echo Please install npm from: https://nodejs.org/en/download
|
||||
echo And make sure its in the path
|
||||
exit 1
|
||||
fi
|
||||
@ -60,3 +60,5 @@ git clone https://github.com/fosscord/css-mediaquery css-mediaquery
|
||||
git clone https://github.com/fosscord/react-native-withcss react-native-withcss
|
||||
|
||||
echo '{"folders":[{"path":"overview"},{"path":"cdn"},{"path":"api"},{"path":"gateway"},{"path":"media"},{"path":"server-util"},{"path":"ui"},{"path":"client"},{"path":"plugins"},{"path":"themes"},{"path":"landingpage"},{"path":"dashboard"},{"path":"support"},{"path":"css-mediaquery"},{"path":"react-native-withcss"}]}' >> fosscord.code-workspace
|
||||
|
||||
echo Installation finished
|
3
scripts/update/update-npm.bat
Normal file
3
scripts/update/update-npm.bat
Normal file
@ -0,0 +1,3 @@
|
||||
@ECHO off
|
||||
ECHO Update for PNPM...
|
||||
FOR /D %%a IN (%CD%\fosscord\*) do echo -------------- && echo %%~fa && cd %%~fa && npm i
|
10
scripts/update/update-npm.sh
Normal file
10
scripts/update/update-npm.sh
Normal file
@ -0,0 +1,10 @@
|
||||
echo Update for Git...
|
||||
cd ../../../
|
||||
for D in */; do
|
||||
echo --------------
|
||||
echo "$D";
|
||||
cd $D
|
||||
npm i
|
||||
cd ..
|
||||
done
|
||||
echo Done
|
Loading…
Reference in New Issue
Block a user