Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add getSaveData method to open cloud
  • Loading branch information
regalijan committed Apr 3, 2024
1 parent f4b3e81 commit 7561c1f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions functions/roblox-open-cloud.ts
@@ -1,6 +1,9 @@
const DATASTORE_URL =
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=BanData&entryKey=CloudBanList";

const SAVE_DATA_URL =
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=RealData&entryKey=";

export async function getBanList(context: RequestContext) {
const data = await fetch(DATASTORE_URL, {
headers: {
Expand All @@ -16,6 +19,21 @@ export async function getBanList(context: RequestContext) {
return await data.json();
}

export async function getSaveData(context: RequestContext, user: number) {
const data = await fetch(`${SAVE_DATA_URL}${user}`, {
headers: {
"x-api-key": context.env.ROBLOX_OPENCLOUD_KEY,
},
});

if (!data.ok) {
console.log(await data.json());
throw new Error(`Failed to retrieve save data for ${user}`);
}

return await data.json();
}

export async function setBanList(
context: RequestContext,
data: { [k: string]: { [k: string]: any } },
Expand Down

0 comments on commit 7561c1f

Please sign in to comment.