Final Refactor of Detection system

pull/1/head
Astoria Floyd 3 years ago
parent 62713950ef
commit 6bc2a2fa1a

@ -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)

Loading…
Cancel
Save