diff --git a/src/modules/commands/maps_init.lua b/src/modules/commands/maps_init.lua index 1b903ed..ebde3dd 100644 --- a/src/modules/commands/maps_init.lua +++ b/src/modules/commands/maps_init.lua @@ -1,42 +1,42 @@ -local discordia=require('discordia') -local API=require('./../strafes_net.lua') -discordia.extensions() -API.MAPS={} -for _,game in next,API.GAMES do - if type(tonumber(game)) == 'number' then - local maps = {count=0} - local res,headers = API:GetMaps(game) - local pages = tonumber(headers['Pagination-Count']) - maps.count=maps.count+#res - for _,v in next,res do - maps[v.ID]=v - end - if pages>1 then - for i=2,pages do - res,headers = API:GetMaps(game,i) - maps.count=maps.count+#res - for _,j in next,res do - maps[j.ID]=j - end - end - end - setmetatable(maps,{__index=function(self,i) - if i=='count' then return self.count end - if not tonumber(i) then - for ix,v in next,self do - if type(v)=='table' and v.DisplayName:lower():find(i:lower()) then - return v - end - end - elseif tonumber(i) then - for ix,v in next,self do - if type(v)=='table' and v.ID==i then - return v - end - end - end - end}) - API.MAPS[game]=maps - print('map init done for game:',API.GAMES[game],'count:',API.MAPS[game].count) - end -end \ No newline at end of file +-- local discordia=require('discordia') +-- local API=require('./../strafes_net.lua') +-- discordia.extensions() +-- API.MAPS={} +-- for _,game in next,API.GAMES do +-- if type(tonumber(game)) == 'number' then +-- local maps = {count=0} +-- local res,headers = API:GetMaps(game) +-- local pages = tonumber(headers['Pagination-Count']) +-- maps.count=maps.count+#res +-- for _,v in next,res do +-- maps[v.ID]=v +-- end +-- if pages>1 then +-- for i=2,pages do +-- res,headers = API:GetMaps(game,i) +-- maps.count=maps.count+#res +-- for _,j in next,res do +-- maps[j.ID]=j +-- end +-- end +-- end +-- setmetatable(maps,{__index=function(self,i) +-- if i=='count' then return self.count end +-- if not tonumber(i) then +-- for ix,v in next,self do +-- if type(v)=='table' and v.DisplayName:lower():find(i:lower()) then +-- return v +-- end +-- end +-- elseif tonumber(i) then +-- for ix,v in next,self do +-- if type(v)=='table' and v.ID==i then +-- return v +-- end +-- end +-- end +-- end}) +-- API.MAPS[game]=maps +-- print('map init done for game:',API.GAMES[game],'count:',API.MAPS[game].count) +-- end +-- end \ No newline at end of file diff --git a/src/modules/commands/user.lua b/src/modules/commands/user.lua index a189b19..7fedeaf 100644 --- a/src/modules/commands/user.lua +++ b/src/modules/commands/user.lua @@ -36,7 +36,7 @@ commands:Add('user',{},'user ', function(t) local user_info=API:GetUserFromAny(user,message) if type(user_info)=='string' then return message:reply('```'..user_info..'```') end -- for a,b in next,user_info do user_info[a]=tostring(b)end - local description = user_info.description + local description = user_info.description=='' and 'null' or user_info.description local created = tostring(date.fromISO(user_info.created):toSeconds()) local current = date():toSeconds() local accountAge = round((current-created)/86400) @@ -66,8 +66,7 @@ commands:Add('user',{},'user ', function(t) {name='Last Online',value='',inline=true}, {name='Last Location',value=LastLocation,inline=true}, {name='Banned',value=isBanned,inline=true}, - - {name='Description',value=description or 'None',inline=false}, + {name='Description',value=description,inline=false}, } } message:reply({embed=embed}) diff --git a/src/modules/strafes_net.lua b/src/modules/strafes_net.lua index 50f6cb6..6196e3d 100644 --- a/src/modules/strafes_net.lua +++ b/src/modules/strafes_net.lua @@ -194,7 +194,17 @@ function API:CalculatePoint(rank,count) end function API:GetUserFromAny(user,message) - if user=='me' then + local str = user:match('^["\'](.+)[\'"]$') + local num = user:match('^(%d+)$') + if str then + local roblox_user=API:GetRobloxInfoFromUsername(str) + if not roblox_user.id then return 'User not found' end + return roblox_user + elseif num then + local roblox_user = API:GetRobloxInfoFromUserId(user) + if not roblox_user.id then return 'Invalid user id' end + return roblox_user + elseif user=='me' then local me=message.author local roblox_user=API:GetRobloxInfoFromDiscordId(me.id) if not roblox_user.id then return 'You are not registered with the RoverAPI' end @@ -210,6 +220,26 @@ function API:GetUserFromAny(user,message) if not roblox_user.id then return 'User not found' end return roblox_user end + -- if user=='me' then + -- local me=message.author + -- local roblox_user=API:GetRobloxInfoFromDiscordId(me.id) + -- if not roblox_user.id then return 'You are not registered with the RoverAPI' end + -- return roblox_user + -- elseif user:match('<@%d+>') then + -- local user_id=user:match('<@(%d+)>') + -- local member=message.guild:getMember(user_id) + -- local roblox_user=API:GetRobloxInfoFromDiscordId(member.id) + -- if not roblox_user.id then return 'User is not registered with the RoverAPI' end + -- return roblox_user + -- elseif user:match('%d+')==user then + -- local roblox_user = API:GetRobloxInfoFromUserId(user) + -- if not roblox_user.id then return 'Invalid user id' end + -- return roblox_user + -- else + -- local roblox_user=API:GetRobloxInfoFromUsername(user) + -- if not roblox_user.id then return 'User not found' end + -- return roblox_user + -- end return 'Something went wrong (this should generally not happen)' end