comp-tg/src/cmds/reload.moon

24 lines
523 B
Plaintext

{
private: true
run: (msg) =>
cat, sub = table.unpack msg.args
if not (cat and sub)
return @api\reply msg, '/reload cmds ping'
path = "src.#{cat}.#{sub}"
@api\off package.loaded[path]
package.loaded[path] = nil
suc, m = pcall require, path
if not suc then return @api\reply msg, 'Reload failed. '.. m
else switch cat
when 'events' then @api\on sub, m
when 'cmds' then @cmds[sub] = m
when 'parts' then m @
@api\reply msg, "Reloaded. #{m}"
return
}