mirror of
https://github.com/spacebarchat/spacebarchat.git
synced 2024-11-22 02:12:30 +01:00
discord rpc
This commit is contained in:
parent
48e391611d
commit
dd70e1192b
1
rpc/.gitignore
vendored
Normal file
1
rpc/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/node_modules/
|
52
rpc/index.js
Normal file
52
rpc/index.js
Normal file
@ -0,0 +1,52 @@
|
||||
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: `Working Discord Open Source `,
|
||||
state: `Collaboration open`,
|
||||
startTimestamp,
|
||||
largeImageKey: "logo2",
|
||||
largeImageText: "Discord Open Source",
|
||||
instance: false,
|
||||
buttons: [
|
||||
{ label: "Discord", url: "https://discord.gg/ZrnGQP6p3d" },
|
||||
{
|
||||
label: "Repository",
|
||||
url:
|
||||
"https://github.com/discord-open-source/discord-open-source",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user