Improve username-based roblox user grabbing

This commit is contained in:
Aidan 2023-03-13 16:05:53 +00:00
parent f0cbd286e5
commit 67051b99da
Signed by: 9382
GPG Key ID: 9BF9CD918201F681

View File

@ -260,13 +260,10 @@ function API:GetRobloxInfoFromUserId(USER_ID)
end end
function API:GetRobloxInfoFromUsername(USERNAME) function API:GetRobloxInfoFromUsername(USERNAME)
if not USERNAME then return 'empty id' end if not USERNAME then return 'empty username' end
local err, res = parseToURLArgs({username=USERNAME}) local response,headers = http_request('POST', ROBLOX_API_URL..'usernames/users', API_HEADER, {usernames={USERNAME}})
if err then return err end if not response.data[1] then return 'invalid username' end
local response,headers = http_request('GET', ROBLOX_API_URL2..'users/get-by-username'..res, API_HEADER) return self:GetRobloxInfoFromUserId(response.data[1].id)
if not response.Id then return 'no user found' end
local response2 = http_request('GET', ROBLOX_API_URL..'users/'..response.Id, API_HEADER)
return response2
end end
function API:GetRobloxInfoFromDiscordId(DISCORD_ID) function API:GetRobloxInfoFromDiscordId(DISCORD_ID)