presence.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. There is currently a bug, where sometimes the presence flickers (at least for the german wiki, not occured with the english one yet)
  3. This is probably caused by the two presences. If anyone has an idea how to fix, be happy to do a pull request or tell me on Discord CRUGG#0001
  4. */
  5. const presence = new Presence({
  6. clientId: "613417749489778689",
  7. }),
  8. germanPresence = new Presence({
  9. clientId: "613418400042975329",
  10. });
  11. presence.on("UpdateData", async () => {
  12. if (
  13. document.location.href.includes("tora-dora.fandom.com") && // English Wiki
  14. document.location.pathname.startsWith("/wiki/")
  15. ) {
  16. // Making 100% sure it's the english wiki
  17. let page = "N/A";
  18. try {
  19. page = document.querySelectorAll(".page-header__title")[0].textContent;
  20. } catch (err) {
  21. presence.info(
  22. `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIEN_GETPAGETITLE ::: ${err}`
  23. );
  24. }
  25. presence.setActivity({
  26. details: "Viewing a page...",
  27. state: page,
  28. largeImageKey:
  29. "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png",
  30. });
  31. }
  32. germanPresence.on("UpdateData", async () => {
  33. if (
  34. document.location.href.includes("toradora.fandom.com") && // German Wiki
  35. document.location.pathname.startsWith("/de/wiki/")
  36. ) {
  37. // Making 100% sure it's the german wiki
  38. let page = "N/A";
  39. try {
  40. page = document.querySelectorAll(".page-header__title")[0].textContent;
  41. } catch (err) {
  42. germanPresence.info(
  43. `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIDE_GETPAGETITLE ::: ${err}`
  44. );
  45. }
  46. germanPresence.setActivity({
  47. details: "Schaut eine Seite an...",
  48. state: page,
  49. largeImageKey:
  50. "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png",
  51. });
  52. }
  53. });
  54. });