refactoring several functions into smaller forms
parent
256ee5125d
commit
7639c9309c
@ -1,7 +1,10 @@
|
|||||||
local basicCommands = {}
|
local basicCommands = {}
|
||||||
|
|
||||||
function helloWorld()
|
function basicCommands.helloWorld()
|
||||||
return("Hello world!")
|
return("Hello world!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return basicCommands
|
return basicCommands
|
||||||
|
@ -1 +1 @@
|
|||||||
{"873255296024322059":{"timestamp":1628283774,"owner":{"discriminator":"0000","avatar":null,"id":"872299874857676820","flags":1024,"public_flags":1024,"username":"team872299874857676820"},"shards":1},"url":"wss://gateway.discord.gg"}
|
{"873255296024322059":{"shards":1,"timestamp":1628289076,"owner":{"avatar":null,"discriminator":"0000","public_flags":1024,"id":"872299874857676820","username":"team872299874857676820","flags":1024}},"url":"wss://gateway.discord.gg"}
|
@ -0,0 +1,20 @@
|
|||||||
|
local rng = {}
|
||||||
|
local tools = require("./tools.lua")
|
||||||
|
|
||||||
|
function rng.d20()
|
||||||
|
tools.reseed()
|
||||||
|
dice = math.random(20)
|
||||||
|
messagePart1 = ('You rolled a ' .. dice .. ' out of 20')
|
||||||
|
if dice==20 then
|
||||||
|
messagePart2 = ('Nat 20! Crititcal Hit')
|
||||||
|
else if dice==1 then
|
||||||
|
messagePart2 = ('Nat 1! Critical Shit!')
|
||||||
|
else
|
||||||
|
messagePart2 = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
message = messagePart1 .. '\n' .. messagePart2
|
||||||
|
return message
|
||||||
|
end
|
||||||
|
|
||||||
|
return rng
|
@ -0,0 +1,26 @@
|
|||||||
|
local tools = {}
|
||||||
|
|
||||||
|
|
||||||
|
function tools.reseed()
|
||||||
|
seed = os.time()
|
||||||
|
math.randomseed(seed)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tools.printFile(file)
|
||||||
|
rawFile = io.open(file, r)
|
||||||
|
message = rawFile:read("*all")
|
||||||
|
rawFile:close()
|
||||||
|
return message
|
||||||
|
end
|
||||||
|
|
||||||
|
function tools.messageDectection(message, search)
|
||||||
|
distinctMessage = message.content
|
||||||
|
key = "!"
|
||||||
|
keyedSearch = key .. search
|
||||||
|
if string.find(distinctMessage, keyedSearch) == 1 then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tools
|
Loading…
Reference in New Issue