From d26ecf2c6305be44e1054b6c061960c25edf81cd Mon Sep 17 00:00:00 2001 From: Astoria Floyd Date: Sat, 7 Aug 2021 17:14:42 -0500 Subject: [PATCH] Re-Initialize now refreshes tools.lua --- bot.lua | 18 ++++++++++++------ tools.lua | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bot.lua b/bot.lua index f71d2e4..cd27190 100644 --- a/bot.lua +++ b/bot.lua @@ -1,13 +1,13 @@ local discordia = require('discordia') local client = discordia.Client() -local tools = require("./tools.lua") +Tools = dofile("./tools.lua") discordia.extensions() --Setup bot here, initializes bot client:once("ready", function() client:setGame("Astoria's bot, very sad!") print('Logged in as '.. client.user.username) - Commands = tools.initialize() + Commands = Tools.initialize() end) --Command handler @@ -22,10 +22,16 @@ client:on('messageCreate', function(message) end) client:on('messageCreate', function(message) - if tools.messageDectection(message, "reinitialize") == true then - Commands = tools.initialize() - message:reply("Re-Initialized!") - end + local user = message.guild:getMember(message.author.id) + if not user:hasPermission("administrator") then + message:reply("You cannot re-initialize this bot!") + else + if Tools.messageDectection(message, "reinitialize") == true then + Commands = Tools.initialize() + Tools = dofile("./tools.lua") + message:reply("Re-Initialized!") + end + end end) --When a user is banned, post a lenney. diff --git a/tools.lua b/tools.lua index 9b5c91c..d2c7754 100644 --- a/tools.lua +++ b/tools.lua @@ -15,7 +15,7 @@ function tools.initialize() local simpleCommands = simpleCommands.initialize() local commands = tools.tableMerge(simpleCommands, complexCommands) return commands - end +end --Reads an entire file, outputs as string. function tools.printFile(file)