summaryrefslogtreecommitdiff
path: root/src/main/richpresence.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/richpresence.ts')
-rw-r--r--src/main/richpresence.ts88
1 files changed, 46 insertions, 42 deletions
diff --git a/src/main/richpresence.ts b/src/main/richpresence.ts
index 93d9f9a..75acfdf 100644
--- a/src/main/richpresence.ts
+++ b/src/main/richpresence.ts
@@ -1,46 +1,50 @@
-import {Status} from './status';
+import { Status } from "./status";
// Only for testing as of right now -> Experimental
-const ClientId = '551884486351126528';
-const DiscordRPC = require('discord-rich-presence')(ClientId);
+const ClientId = "551884486351126528";
+const DiscordRPC = require("discord-rich-presence")(ClientId);
const slogans = [
- 'free OpenSource 2D MMORPG',
- 'Community made',
- 'Join a Server or start your own'
-]
-const dataSet:
-{[key:string]:{name:string, logo:string, description:string}} = {
- 'server.tmw2.org':{
- name: 'Moubootaur Legends',
- logo: 'tmw2',
- description: 'Playing on Moubootaur Legends ⎛tmw2.org⎠'
- },
- 'world.evolonline.org':{
- name: 'Evol Online',
- logo: 'evol',
- description: 'Playing on Evol Online ⎛evolonline.org⎠'
- },
- 'server.themanaworld.org':{
- name: 'The Mana World',
- logo: 'tmw',
- description: 'Playing on The Mana World ⎛themanaworld.org⎠'
- },
- 'noServer':{
- name: 'Manaplus',
- logo: 'manaplus',
- description: 'Playing on any of the M+ servers'
- }
- }
+ "free OpenSource 2D MMORPG",
+ "Community made",
+ "Join a Server or start your own",
+];
+const dataSet: {
+ [key: string]: { name: string; logo: string; description: string };
+} = {
+ "server.tmw2.org": {
+ name: "Moubootaur Legends",
+ logo: "tmw2",
+ description: "Playing on Moubootaur Legends ⎛tmw2.org⎠",
+ },
+ "world.evolonline.org": {
+ name: "Evol Online",
+ logo: "evol",
+ description: "Playing on Evol Online ⎛evolonline.org⎠",
+ },
+ "server.themanaworld.org": {
+ name: "The Mana World",
+ logo: "tmw",
+ description: "Playing on The Mana World ⎛themanaworld.org⎠",
+ },
+ noServer: {
+ name: "Manaplus",
+ logo: "manaplus",
+ description: "Playing on any of the M+ servers",
+ },
+};
async function setActivity() {
- const status = Status.getStatus()
+ const status = Status.getStatus();
- const slogan = slogans[Math.floor(Math.random() * slogans.length)]
+ const slogan = slogans[Math.floor(Math.random() * slogans.length)];
- const data = dataSet[status.gameStatus.server]
+ const data = dataSet[status.gameStatus.server];
- const details = status.gameStatus.server === 'Launcher' ? 'in Launcher Menu' : `🎮 ${data.name} 🎮`
- const logo = data && data.logo
+ const details =
+ status.gameStatus.server === "Launcher"
+ ? "in Launcher Menu"
+ : `🎮 ${data.name} 🎮`;
+ const logo = data && data.logo;
DiscordRPC.updatePresence({
state: `»${slogan}«`,
@@ -59,7 +63,7 @@ async function setActivity() {
});
}
-DiscordRPC.on('connected', () => {
+DiscordRPC.on("connected", () => {
setActivity();
// activity can only be set every 15 seconds
@@ -70,12 +74,12 @@ DiscordRPC.on('connected', () => {
DiscordRPC.on("error", console.log);
-DiscordRPC.on('join', (secret:string) => {
- console.log('we should join with', secret);
+DiscordRPC.on("join", (secret: string) => {
+ console.log("we should join with", secret);
});
-DiscordRPC.on('spectate', (secret:string) => {
- console.log('we should spectate with', secret);
+DiscordRPC.on("spectate", (secret: string) => {
+ console.log("we should spectate with", secret);
});
// DiscordRPC.on('joinRequest', (user) => {
@@ -86,9 +90,9 @@ DiscordRPC.on('spectate', (secret:string) => {
// }
// });
-export function quit(){
+export function quit() {
DiscordRPC.disconnect();
console.log("Shutting down Discord RPC integration");
}
-process.on('unhandledRejection', console.error); \ No newline at end of file
+process.on("unhandledRejection", console.error);