proper error handling and error message
This commit is contained in:
parent
64973b199d
commit
48067e6862
@ -220,13 +220,13 @@ function API:GetUserFromAny(user,message)
|
|||||||
elseif user=='me' then
|
elseif user=='me' then
|
||||||
local me=message.author
|
local me=message.author
|
||||||
local roblox_user=self:GetRobloxInfoFromDiscordId(me.id)
|
local roblox_user=self:GetRobloxInfoFromDiscordId(me.id)
|
||||||
if not roblox_user.id then return 'You are not registered with the rbhop api' end
|
if not roblox_user.id then return 'You are not registered with the fiveman1 api, use !link with the rbhop bot to link your roblox account' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
elseif user:match('<@%d+>') then
|
elseif user:match('<@%d+>') then
|
||||||
local user_id=user:match('<@(%d+)>')
|
local user_id=user:match('<@(%d+)>')
|
||||||
local member=message.guild:getMember(user_id)
|
local member=message.guild:getMember(user_id)
|
||||||
local roblox_user=self:GetRobloxInfoFromDiscordId(member.id)
|
local roblox_user=self:GetRobloxInfoFromDiscordId(member.id)
|
||||||
if not roblox_user.id then return 'User is not registered with the rbhop api' end
|
if not roblox_user.id then return 'User is not registered with the fiveman1 api, use !link with the rbhop bot to link your roblox account' end
|
||||||
return roblox_user
|
return roblox_user
|
||||||
else
|
else
|
||||||
local roblox_user=self:GetRobloxInfoFromUsername(user)
|
local roblox_user=self:GetRobloxInfoFromUsername(user)
|
||||||
@ -258,7 +258,7 @@ end
|
|||||||
function API:GetRobloxInfoFromDiscordId(DISCORD_ID)
|
function API:GetRobloxInfoFromDiscordId(DISCORD_ID)
|
||||||
if not DISCORD_ID then return 'empty id' end
|
if not DISCORD_ID then return 'empty id' end
|
||||||
local response,headers = http_request('GET', FIVEMAN_API_URL..'users/'..DISCORD_ID, API_HEADER)
|
local response,headers = http_request('GET', FIVEMAN_API_URL..'users/'..DISCORD_ID, API_HEADER)
|
||||||
if not response.result and not response.result.robloxId and response.error then return response,headers.error end
|
if response.status=='error' then return response.messages end
|
||||||
local response2 = http_request('GET', ROBLOX_API_URL..'users/'..response.result.robloxId, API_HEADER)
|
local response2 = http_request('GET', ROBLOX_API_URL..'users/'..response.result.robloxId, API_HEADER)
|
||||||
return response2
|
return response2
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user