From fe40e8b980142b34d5fece7032fda991c0cc3458 Mon Sep 17 00:00:00 2001 From: filoxenace Date: Mon, 16 Feb 2026 10:59:11 -0500 Subject: [PATCH] Initial commit --- .gitattributes | 1 + README.md | 36 +++++++++++++++++++++++++++++++++++ default.project.json | 6 ++++++ rokit.toml | 7 +++++++ src/init.luau | 45 ++++++++++++++++++++++++++++++++++++++++++++ wally.toml | 8 ++++++++ 6 files changed, 103 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 default.project.json create mode 100644 rokit.toml create mode 100644 src/init.luau create mode 100644 wally.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bcb02e0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +eol=lf diff --git a/README.md b/README.md new file mode 100644 index 0000000..767afab --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# threads-client + +A Roblox server-side client for the [Threads](https://github.com/filoxen/threads) service. Handles reuploading clothing assets through your Threads instance. + +## Installation + +Add to your `wally.toml` dependencies: + +```toml +[server-dependencies] +ThreadsClient = "secret-rare/threads-client@0.1.0" +``` + +Then run: + +```bash +wally install +``` + +## Setup + +1. Add your API key to the **Secrets Store** in the Creator Dashboard with the name `THREADS_API_KEY` (or your own custom secret name). + +2. Update `BASE_URL` in the module to point to your Threads API instance. + +## Usage + +```luau +local ThreadsClient = require(path.to.ThreadsClient) + +local newAssetId = ThreadsClient.create(assetId) + +if newAssetId ~= -1 then + print("Reuploaded to:", newAssetId) +end +``` diff --git a/default.project.json b/default.project.json new file mode 100644 index 0000000..f4f820f --- /dev/null +++ b/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "threads-client", + "tree": { + "$path": "src" + } +} diff --git a/rokit.toml b/rokit.toml new file mode 100644 index 0000000..654bc45 --- /dev/null +++ b/rokit.toml @@ -0,0 +1,7 @@ +# This file lists tools managed by Rokit, a toolchain manager for Roblox projects. +# For more information, see https://github.com/rojo-rbx/rokit + +# New tools can be added by running `rokit add ` in a terminal. + +[tools] +wally = "UpliftGames/wally@0.3.2" diff --git a/src/init.luau b/src/init.luau new file mode 100644 index 0000000..99e03b9 --- /dev/null +++ b/src/init.luau @@ -0,0 +1,45 @@ +local HttpService = game:GetService("HttpService") + +local clothing_upload = {} + +-- Change this to your own Threads API instance URL +local BASE_URL = "https://threads.example.com" +-- Name of the secret in the Secrets Store (Creator Dashboard -> Secrets). +local API_KEY_SECRET_NAME = "THREADS_API_KEY" + +local API_KEY = HttpService:GetSecret(API_KEY_SECRET_NAME) + +-- Sends a reupload request to the Threads API for the given asset ID. Returns the new asset ID, or -1 on failure. +function clothing_upload.create(id: number): number + local create_url = `{BASE_URL}/create/?asset_id={id}` + + local request_data = { + Url = create_url, + Method = "POST", + Headers = { + ["Content-Type"] = "application/json", + ["x-api-key"] = API_KEY + } + } + + local success, response = pcall(function() + return HttpService:RequestAsync(request_data) + end) + + if success and response.Success then + local response_data = HttpService:JSONDecode(response.Body) + if response_data["uploaded"] then + local newAssetId = tonumber(response_data["uploaded"]["asset_id"]) :: number + print(`[ClothingUploadClient] Successfully reuploaded asset {id} -> {newAssetId}`) + return newAssetId + else + warn(`[ClothingUploadClient] Reupload failed for asset {id}: Response missing 'uploaded' field`) + end + else + local errorMsg = if response then response.StatusMessage else "Unknown Error" + warn(`[ClothingUploadClient] API request failed for asset {id}: {errorMsg}`) + end + return -1 +end + +return clothing_upload diff --git a/wally.toml b/wally.toml new file mode 100644 index 0000000..5a2877a --- /dev/null +++ b/wally.toml @@ -0,0 +1,8 @@ +[package] +name = "secret-rare/threads-client" +version = "0.1.0" +registry = "https://github.com/UpliftGames/wally-index" +license = "GPL-3.0" +realm = "server" + +[dependencies]