From 5dee01b07b9571a5ddda919b82ae17c3520a0f1a Mon Sep 17 00:00:00 2001 From: Er2 Date: Tue, 18 Jan 2022 19:34:23 +0000 Subject: [PATCH] reload --- config.lua | 2 ++ src/cmds/reload.lua | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/cmds/reload.lua diff --git a/config.lua b/config.lua index 6acd80f..eead837 100644 --- a/config.lua +++ b/config.lua @@ -3,6 +3,7 @@ return { owner = 935626920 , -- hehe cmds = { 'eval', + 'reload', 'ping', 'rub', 'start', @@ -10,6 +11,7 @@ return { events = { 'command', 'ready', + 'inlineQuery', }, parts = { 'locale', diff --git a/src/cmds/reload.lua b/src/cmds/reload.lua new file mode 100644 index 0000000..1f87b03 --- /dev/null +++ b/src/cmds/reload.lua @@ -0,0 +1,17 @@ +return { + private = true, + run = function(C, msg) + local cat, sub = table.unpack(msg.args) + if not (cat and sub) then + return C.api:reply(msg, '/reload cmds ping') + end + + local path = 'src.'..cat..'.'..sub + package.loaded[path] = nil + local err, m = pcall(require, path) + C.api:reply(msg, ('Reloaded. %s (%s)'):format( + err and 'Error:' or 'No errors', + m + )) + end +}