Replace `assert` with `core.log_quiet` on command replace

This caused issues when saving the user module with commands defined
inside it, as it resulted in the user-defined commands trying to
overwrite themselves and failing.
This commit is contained in:
Guldoman 2022-08-14 02:23:56 +02:00
parent d944bd85ec
commit 6aa96556c0
No known key found for this signature in database
GPG Key ID: EA928C8BDA1A8825
1 changed files with 3 additions and 1 deletions

View File

@ -45,7 +45,9 @@ end
function command.add(predicate, map) function command.add(predicate, map)
predicate = command.generate_predicate(predicate) predicate = command.generate_predicate(predicate)
for name, fn in pairs(map) do for name, fn in pairs(map) do
assert(not command.map[name], "command already exists: " .. name) if command.map[name] then
core.log_quiet("Replacing existing command \"%s\"", name)
end
command.map[name] = { predicate = predicate, perform = fn } command.map[name] = { predicate = predicate, perform = fn }
end end
end end