Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
deploy: 03b4065
Browse files Browse the repository at this point in the history
  • Loading branch information
smartfrigde committed Jul 14, 2024
1 parent 8a2c8de commit ba1f681
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions armcordRPC/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,50 @@
// plugins/armcordRPC/index.js
var armcordRPC_exports = {};
__export(armcordRPC_exports, {
fetchAssetId: () => fetchAssetId,
onLoad: () => onLoad
});
var {
util: { log },
flux: {
dispatcher: FluxDispatcher,
stores: { ApplicationStore, DetectableGameSupplementalStore }
}
stores: { ApplicationStore }
},
http
} = shelter;
var apps = {};
var assetCache = {};
var fetchAssetId = async (applicationId, assetName) => {
if (!assetCache[applicationId]) {
try {
const response = await http.get(`/oauth2/applications/${applicationId}/assets`);
if (response.status !== 200) {
console.error("Error fetching resources");
return null;
}
assetCache[applicationId] = response.body;
} catch (error) {
console.error("Request failed", error);
return null;
}
}
const resource = assetCache[applicationId].find((item) => item.name === assetName);
return resource ? resource.id : null;
};
function onLoad() {
ArmCordRPC.listen(async (msg) => {
console.log(msg);
log("ArmCord RPC: detected some game");
if (msg.activity?.assets?.large_image)
msg.activity.assets.large_image = await fetchAssetId(
msg.activity.application_id,
msg.activity.assets.large_image
);
if (msg.activity?.assets?.small_image)
msg.activity.assets.small_image = await fetchAssetId(
msg.activity.application_id,
msg.activity.assets.small_image
);
if (msg.activity) {
const appId = msg.activity.application_id;
if (!apps[appId])
Expand Down
2 changes: 1 addition & 1 deletion armcordRPC/plugin.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"ArmCord RPC","author":"smartfrigde","description":"Links arRPC to ArmCord","hash":"2bd83de14b4ae955b7af6905fa618c19"}
{"name":"ArmCord RPC","author":"smartfrigde","description":"Links arRPC to ArmCord","hash":"1e27eb4ebb8790cb441aa1a0f983b5c5"}

0 comments on commit ba1f681

Please sign in to comment.