added docs and fixed level bridger

This commit is contained in:
2026-01-03 22:13:17 +05:30
parent 92ad60fd3c
commit 5ed739f981
10 changed files with 612 additions and 100 deletions

View File

@@ -269,9 +269,9 @@ export async function createLevelTrack(
try {
if (!process.env.BOT_API_URL) return { success: false, error: "Bot API URL not configured" };
// WORKAROUND: Unquote role_id for backend (expects u64)
// We kept it as string in frontend/NextJS to preserve precision.
const bodyJson = JSON.stringify(data).replace(/"role_id":\s*"(\d+)"/g, '"role_id": $1');
// REMOVED WORKAROUND: Backend now expects strings for u64 IDs
const bodyJson = JSON.stringify(data);
const response = await fetch(`${process.env.BOT_API_URL}/api/${guildId}/level/track`, {
method: "POST",
@@ -303,8 +303,9 @@ export async function updateLevelTrack(
try {
if (!process.env.BOT_API_URL) return { success: false, error: "Bot API URL not configured" };
// WORKAROUND: Unquote role_id for backend (expects u64)
const bodyJson = JSON.stringify(data).replace(/"role_id":\s*"(\d+)"/g, '"role_id": $1');
// REMOVED WORKAROUND: Backend now expects strings for u64 IDs
const bodyJson = JSON.stringify(data);
const response = await fetch(`${process.env.BOT_API_URL}/api/${guildId}/level/track`, {
method: "PATCH",
@@ -400,8 +401,9 @@ export async function createLevelBridge(
try {
if (!process.env.BOT_API_URL) return { success: false, error: "Bot API URL not configured" };
// WORKAROUND: Unquote role_id for backend (expects u64)
const bodyJson = JSON.stringify(bridge).replace(/("in_role_id"|"out_role_id"):\s*"(\d+)"/g, '$1: $2');
// REMOVED WORKAROUND: Backend now expects strings for u64 IDs
const bodyJson = JSON.stringify(bridge);
const response = await fetch(`${process.env.BOT_API_URL}/api/${guildId}/level_bridger`, {
method: "POST",
@@ -432,7 +434,8 @@ export async function updateLevelBridge(
try {
if (!process.env.BOT_API_URL) return { success: false, error: "Bot API URL not configured" };
const bodyJson = JSON.stringify(bridge).replace(/("in_role_id"|"out_role_id"):\s*"(\d+)"/g, '$1: $2');
const bodyJson = JSON.stringify(bridge);
const response = await fetch(`${process.env.BOT_API_URL}/api/${guildId}/level_bridger`, {
method: "PUT",
@@ -463,8 +466,8 @@ export async function deleteLevelBridge(
try {
if (!process.env.BOT_API_URL) return { success: false, error: "Bot API URL not configured" };
// Even for delete, we might need to handle the u64 issue if the ID is passed in body
const bodyJson = JSON.stringify({ in_role_id: inRoleId }).replace(/("in_role_id"):\s*"(\d+)"/g, '$1: $2');
const bodyJson = JSON.stringify({ in_role_id: inRoleId });
const response = await fetch(`${process.env.BOT_API_URL}/api/${guildId}/level_bridger`, {
method: "DELETE",