rewrite command to work with new map indexing
This commit is contained in:
parent
0f38f7a00d
commit
93b0fffce0
@ -4,56 +4,18 @@ local commands=require('./../commands.lua')
|
|||||||
discordia.extensions()
|
discordia.extensions()
|
||||||
|
|
||||||
commands:Add('map',{},'get map info', function(t)
|
commands:Add('map',{},'get map info', function(t)
|
||||||
local game = API.GAMES[t.args[1]]
|
local args = t.args
|
||||||
local map_name
|
local message = t.message
|
||||||
if not game then
|
|
||||||
map_name = table.concat(t.args,' ')
|
local game = API.GAMES[args[1]]
|
||||||
else
|
local map = not game and (API.MAPS[1][table.concat(args,' ')] or API.MAPS[2][table.concat(args,' ')]) or API.MAPS[game][table.concat(args,' ',2)]
|
||||||
map_name = table.concat(t.args,' ',2)
|
if not map then return message:reply('```No map found```') end
|
||||||
end
|
local formatted_message = '```'..
|
||||||
if not map_name then return t.message:reply('invalid arguments') end
|
'Map: '..map.DisplayName..' ('..API.GAMES[map.Game]..')\n'..
|
||||||
if game then
|
'ID: '..map.ID..'\n'..
|
||||||
for mn,Map in next, API.MAPS[game] do
|
'Creator: '..map.Creator..'\n'..
|
||||||
if (Map.DisplayName:lower():sub(1,#map_name)==map_name:lower()) then
|
'PlayCount: '..map.PlayCount..'\n'..
|
||||||
local map = API.MAPS[game][mn]
|
'Published: '..os.date('%A, %B %d %Y @ %I:%M (%p)',map.Date)..
|
||||||
local formatted_message = '```'..
|
'```'
|
||||||
'Map: '..map.DisplayName..' ('..API.GAMES[game]..')\n'..
|
return message:reply(formatted_message)
|
||||||
'ID: '..map.ID..'\n'..
|
|
||||||
'Creator: '..map.Creator..'\n'..
|
|
||||||
'PlayCount: '..map.PlayCount..'\n'..
|
|
||||||
'Published: '..os.date('%A, %B %d %Y @ %I:%M (%p)',map.Date)..
|
|
||||||
'```'
|
|
||||||
return t.message:reply(formatted_message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if API.MAPS[game][map_name] then
|
|
||||||
local map = API.MAPS[game][map_name]
|
|
||||||
local formatted_message = '```'..
|
|
||||||
'Map: '..map.DisplayName..' ('..API.GAMES[game]..')\n'..
|
|
||||||
'ID: '..map.ID..'\n'..
|
|
||||||
'Creator: '..map.Creator..'\n'..
|
|
||||||
'PlayCount: '..map.PlayCount..'\n'..
|
|
||||||
'Published: '..os.date('%A, %B %d %Y @ %I:%M (%p)',map.Date)..
|
|
||||||
'```'
|
|
||||||
return t.message:reply(formatted_message)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for _,game in next,API.GAMES do
|
|
||||||
if type(tonumber(game)) == 'number' then
|
|
||||||
if API.MAPS[game][map_name] then
|
|
||||||
local map = API.MAPS[game][map_name]
|
|
||||||
local formatted_message = '```'..
|
|
||||||
'Map: '..map.DisplayName..' ('..API.GAMES[game]..')\n'..
|
|
||||||
'ID: '..map.ID..'\n'..
|
|
||||||
'Creator: '..map.Creator..'\n'..
|
|
||||||
'PlayCount: '..map.PlayCount..'\n'..
|
|
||||||
'Published: '..os.date('%A, %B %d %Y @ %I:%M (%p)',map.Date)..
|
|
||||||
'```'
|
|
||||||
return t.message:reply(formatted_message)
|
|
||||||
else
|
|
||||||
return t.message:reply('map not found')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue
Block a user