Skip to content
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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions websites/O/OG Network/metadata.json
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"
Copy link
Member

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

},
"url": [
"og-network.net",
"shop-og-network.net"
],
"version": "1.0.0",
"logo": "https://www.og-network.net/assets/logo.png",
John-Fries-J marked this conversation as resolved.
Show resolved Hide resolved
"thumbnail": "https://www.og-network.net/assets/logo.png",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thumbnail should preferably be a wide promotional card or a screenshot if the first is not available.

"color": "#9eeb34",
"category": "games",
"tags": [
"minecraft",
"server"
]
}
77 changes: 77 additions & 0 deletions websites/O/OG Network/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const presence = new Presence({ clientId: "1237999667023708231" }),
assets = {
logo: "https://www.og-network.net/assets/logo.png",
};
John-Fries-J marked this conversation as resolved.
Show resolved Hide resolved
John-Fries-J marked this conversation as resolved.
Show resolved Hide resolved

let startTime: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason to use this after my changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startTime is only assigned, not really used. It can be removed.


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: Math.floor(
Date.now() / 1000 - startTime
? Math.round((Date.now() - startTime) / 1000)
: 0
),
John-Fries-J marked this conversation as resolved.
Show resolved Hide resolved
};

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]

Check failure on line 40 in websites/O/OG Network/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Expected { after 'if' condition
.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(

Check failure on line 47 in websites/O/OG Network/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Expected { after 'if' condition
/_/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]

Check failure on line 60 in websites/O/OG Network/presence.ts

View workflow job for this annotation

GitHub Actions / Compile and Lint

Expected { after 'if' condition
.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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read our guideliness

Presences that use buttons should follow extra requirements:
Redirects to main page are prohibited.
Promoting websites by them is prohibited.
They can't display information you couldn't fit in other fields.
Redirecting directly to audio/video stream is prohibited.

Copy link
Member

Choose a reason for hiding this comment

The 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What

});
Loading