From 6bc2a2fa1a38ba73a1e93a29538a636851c1e35a Mon Sep 17 00:00:00 2001 From: Astoria Floyd Date: Fri, 6 Aug 2021 15:22:15 -0500 Subject: [PATCH] Final Refactor of Detection system --- bot.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bot.lua b/bot.lua index 91670b8..994307c 100644 --- a/bot.lua +++ b/bot.lua @@ -5,7 +5,9 @@ math.randomseed(seed) function messageDectection (message, search) distinctMessage = message.content - if string.find(distinctMessage, search) == 1 then + key = "!" + keyedSearch = key .. search + if string.find(distinctMessage, keyedSearch) == 1 then return true else return false @@ -18,13 +20,13 @@ client:on('ready', function() end) client:on('messageCreate', function(message) - if messageDectection(message, "!ping") == true then + if messageDectection(message, "ping") == true then message.channel:send('Pong!') end end) client:on('messageCreate', function(message) - if messageDectection(message, "!roll") == true then + if messageDectection(message, "roll") == true then dice = math.random(20) message.channel:send('You rolled a ' .. dice .. ' out of 20') if dice==20 then @@ -46,7 +48,7 @@ end) --Replacing the above with a more tolerant version client:on('messageCreate', function(message) - if messageDectection(message, "!time") == true then + if messageDectection(message, "time") == true then message.channel:send('The current time in military time is ' .. os.date() .. ' atleast in Chicago!') end end)