add -off in reload

This commit is contained in:
Er2 2022-03-01 11:15:33 +03:00
parent 0b2a7ac8e5
commit 5a54bc1032
1 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
{
private: true
run: (msg) =>
cat, sub = table.unpack msg.args
cat, sub, arg = table.unpack msg.args
if not (cat and sub)
return @api\reply msg, '/reload cmds ping'
@ -10,14 +10,17 @@
@api\off package.loaded[path]
package.loaded[path] = nil
suc, m = pcall require, path
if arg == '-off'
@api\reply msg, 'Turned off'
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 @
else
suc, m = pcall require, path
if not suc then return @api\reply msg, "Reload failed. #{m}"
switch cat
when 'events' then @api\on sub, m
when 'cmds' then @cmds[sub] = m
else m @
@api\reply msg, "Reloaded. #{m}"
@api\reply msg, "Reloaded. #{m}"
return
}