diff --git a/functions/roblox-open-cloud.ts b/functions/roblox-open-cloud.ts index 475ee1b..b088def 100644 --- a/functions/roblox-open-cloud.ts +++ b/functions/roblox-open-cloud.ts @@ -1,6 +1,9 @@ const DATASTORE_URL = "https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/BanData/entries/CloudBanList"; +const MESSAGING_SERVICE_URL = + "https://apis.roblox.com/cloud/v2/universes/274816972:publishMessage"; + const SAVE_DATA_URL = "https://apis.roblox.com/cloud/v2/universes/274816972/data-stores/RealData/entries"; @@ -31,6 +34,28 @@ export async function getBanList(context: RequestContext) { }; } +export async function publishMessage( + context: RequestContext, + topic: string, + message: string, +) { + const response = await fetch(MESSAGING_SERVICE_URL, { + body: JSON.stringify({ + message, + topic, + }), + headers: { + "Content-Type": "application/json", + "x-api-key": context.env.ROBLOX_OPENCLOUD_KEY, + }, + method: "POST", + }); + + if (!response.ok) { + throw new Error("Failed to publish message\n" + (await response.text())); + } +} + export async function getSaveData( context: RequestContext, user: number,