Add messaging service publish method
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user