-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(OG-Network): add presence #8366
Changes from all commits
e6490bc
ea8dd36
6e912b0
947422e
b21fa12
932ba2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.10", | ||
"author": { | ||
"id": "630070645874622494", | ||
"name": "johnfries" | ||
}, | ||
"service": "OG Network", | ||
"description": { | ||
"en": "OG Network website presence" | ||
}, | ||
"url": [ | ||
"og-network.net", | ||
"shop-og-network.net" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/6jC2EYO.png", | ||
"thumbnail": "https://www.og-network.net/assets/logo.png", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"color": "#9eeb34", | ||
"category": "games", | ||
"tags": [ | ||
"minecraft", | ||
"server" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const presence = new Presence({ clientId: "1237999667023708231" }), | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
const enum Assets { | ||
logo: "https://i.imgur.com/6jC2EYO.png", | ||
}; | ||
|
||
let startTime: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
presence.on("UpdateData", async () => { | ||
const url = window.location.href, | ||
John-Fries-J marked this conversation as resolved.
Show resolved
Hide resolved
|
||
presenceData: PresenceData = { | ||
largeImageKey: assets.logo, | ||
startTimestamp: browsingTimestamp; | ||
}; | ||
|
||
if (url.includes("/forums")) { | ||
presenceData.details = "Browsing the OG Network Forums"; | ||
if (url.includes("rules.5/")) | ||
presenceData.details = "Viewing the Rule Category."; | ||
if (url.includes("news-and-announcements.2/")) | ||
presenceData.details = "Viewing the Servers News."; | ||
} else if (url.includes("/rules")) | ||
presenceData.details = "Viewing the Servers Rules."; | ||
else if (url.includes("/apply")) | ||
presenceData.details = "Applying for something."; | ||
else if (url.includes("/vote")) | ||
presenceData.details = "Voting for the server!"; | ||
else if (url.includes("/cosmetics")) | ||
presenceData.details = "Learning about the cosmetics!"; | ||
else if (url.includes("/account")) | ||
presenceData.details = "Editing their account details."; | ||
else if (url.includes("/modifications")) | ||
presenceData.details = "Viewing the Modifications Rules"; | ||
else if (url.includes("/threads")) { | ||
const matches = /threads\/(.*?)(\.\d+)?\/?$/.exec(url); | ||
if (matches && matches[1]) | ||
presenceData.details = `Viewing Thread: ${matches[1] | ||
.replace(/-/g, " ") | ||
.trim()}`; | ||
else presenceData.details = "Viewing Thread: Unknown"; | ||
} else if (url.includes("/members")) { | ||
const matches = /members\/(.*?)\.\d+\/?$/.exec(url); | ||
if (matches && matches[1]) | ||
presenceData.details = `Viewing ${matches[1].replace( | ||
/_/g, | ||
" " | ||
)}'s profile`; | ||
else presenceData.details = "Viewing Member's profile: Unknown"; | ||
} else if ( | ||
url.includes("og-network.net") || | ||
url.includes("shop-og-network.net") | ||
) { | ||
// Check for OG Network and Shop URLs | ||
if (url.includes("/category")) { | ||
const matches = /\/category\/(.*?)(\.\d+)?\/?$/.exec(url); | ||
if (matches && matches[1]) | ||
presenceData.details = `Browsing the ${matches[1] | ||
.replace(/-/g, " ") | ||
.trim()} category`; | ||
else presenceData.details = "Browsing OG Network Store"; | ||
} else presenceData.details = "Browsing OG Network website"; | ||
} else presenceData.details = "Browsing OG Network website"; | ||
|
||
presenceData.buttons = [ | ||
{ | ||
label: "View", | ||
url, | ||
}, | ||
]; | ||
Comment on lines
+64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If using buttons, it should ideally be used on specific interesting routes rather than a catch-all button |
||
|
||
presence.setActivity(presenceData); | ||
|
||
if (!startTime) startTime = Date.now(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, use an official description