UNPKG

openblox

Version:

Roblox API Wrapper For Both Classic And OpenCloud APIs.

60 lines (55 loc) 1.85 kB
import type { Identifier } from "typeforge"; /** * Publishes a message to all servers of a universe. * @endpoint POST /v1/universes/{universeId}/topics/{topic} * @tags [ "Cloud Key" ] * * @example * // Openblox (Typescript Code) - Sending Message * type Message = { targetId: number, reason: string }; await MessagingApi.publishMessage<Message>({ universeId: 5097539509, topic: "kickPlr", message: { targetId: 45348281, reason: "You smell kinda funny." } }); /* Roblox Luau Code - Recieving The Message Above local MessagingService = game:GetService("MessagingService") local HttpService = game:GetService("HttpService") local Players = game:GetService("Players") MessagingService:SubscribeAsync("kickPlr", function(msg) local data = HttpService:JSONDecode(msg.Data) local plr = Players:GetPlayerByUserId(data.targetId) if not plr then return end plr:Kick(`You have been kicked for: "{data.reason}"`) end) *\/ * @exampleData true * @exampleRawBody "" */ export declare const publishMessage: <Message extends string | Record<any, any>>(this: any, args: { universeId: Identifier; topic: string; message: Message; }) => Promise<{ data: true; response: { fullResponse: unknown; url: `https://${string}`; method: import("../../../utils/utils.types").RestMethod; success: boolean; statusCode: number; headers: Headers; body: ""; }; } & { again: () => Promise<{ data: true; response: { fullResponse: unknown; url: `https://${string}`; method: import("../../../utils/utils.types").RestMethod; success: boolean; statusCode: number; headers: Headers; body: ""; }; }>; }>;