Move to V2 datastore apis
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const DATASTORE_URL =
|
||||
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=BanData&entryKey=CloudBanList";
|
||||
"https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/BanData/entries/CloudBanList";
|
||||
|
||||
const SAVE_DATA_URL =
|
||||
"https://apis.roblox.com/datastores/v1/universes/274816972/standard-datastores/datastore/entries/entry?datastoreName=RealData&entryKey=";
|
||||
"https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/RealData/entries";
|
||||
|
||||
export async function getBanList(context: RequestContext) {
|
||||
const data = await fetch(DATASTORE_URL, {
|
||||
@@ -16,14 +16,26 @@ export async function getBanList(context: RequestContext) {
|
||||
throw new Error("Failed to retrieve ban list");
|
||||
}
|
||||
|
||||
return await data.json();
|
||||
return (await data.json()) as {
|
||||
etag: string;
|
||||
path: string;
|
||||
value: {
|
||||
[k: string]: {
|
||||
BanType: number;
|
||||
hidden_from_leaderboards?: boolean;
|
||||
serverconfigurator_blacklist?: boolean;
|
||||
Unbanned?: boolean;
|
||||
UnbanReduct?: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export async function getSaveData(
|
||||
context: RequestContext,
|
||||
user: number,
|
||||
): Promise<string> {
|
||||
const data = await fetch(`${SAVE_DATA_URL}${user}`, {
|
||||
const data = await fetch(`${SAVE_DATA_URL}/${user}`, {
|
||||
headers: {
|
||||
"x-api-key": context.env.ROBLOX_OPENCLOUD_KEY,
|
||||
},
|
||||
@@ -34,20 +46,21 @@ export async function getSaveData(
|
||||
throw new Error(`Failed to retrieve save data for ${user}`);
|
||||
}
|
||||
|
||||
return await data.json();
|
||||
return ((await data.json()) as { value: string }).value;
|
||||
}
|
||||
|
||||
export async function setBanList(
|
||||
context: RequestContext,
|
||||
data: { [k: string]: { [k: string]: any } },
|
||||
value: any,
|
||||
etag?: string,
|
||||
) {
|
||||
const setRequest = await fetch(DATASTORE_URL, {
|
||||
body: JSON.stringify(data),
|
||||
body: JSON.stringify(etag, value),
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"x-api-key": context.env.ROBLOX_OPENCLOUD_KEY,
|
||||
},
|
||||
method: "POST",
|
||||
method: "PATCH",
|
||||
});
|
||||
|
||||
if (!setRequest.ok) {
|
||||
|
||||
Reference in New Issue
Block a user