-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpray.lua
70 lines (62 loc) · 2.19 KB
/
pray.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
local command = {}
function command.run(message, mt)
local time = sw:getTime()
print(message.author.name .. " did !pray")
local uj = dpf.loadjson("savedata/" .. message.author.id .. ".json", defaultjson)
local lang = dpf.loadjson("langs/" .. uj.lang .. "/pray.json", "")
if not message.guild then
message.channel:send(lang.dm_message)
return
end
local cooldown = 23/24
if uj.equipped == "faithfulnecklace" then
cooldown = 20/24
end
if not uj.lastprayer then
uj.lastprayer = -3
end
if uj.lastprayer + cooldown > time:toDays() then
--extremely jank implementation, please make this cleaner if possible
local minutesleft = math.ceil(uj.lastprayer * 1440 - time:toMinutes() + cooldown * 1440)
local durationtext = ""
if math.floor(minutesleft / 60) > 0 then
durationtext = math.floor(minutesleft / 60) .. lang.time_hour
if lang.needs_plural_s == true then
if math.floor(minutesleft / 60) ~= 1 then
durationtext = durationtext .. lang.time_plural_s
end
end
end
if minutesleft % 60 > 0 then
if durationtext ~= "" then
durationtext = durationtext .. lang.time_and
end
durationtext = durationtext .. minutesleft % 60 .. lang.time_minute
if lang.needs_plural_s == true then
if minutesleft % 60 ~= 1 then
durationtext = durationtext .. lang.time_plural_s
end
end
end
message.channel:send(lang.wait_message_1 .. durationtext .. lang.wait_message_2)
return
end
uj.tokens = uj.tokens and uj.tokens + 1 or 1
uj.timesprayed = uj.timesprayed and uj.timesprayed + 1 or 1
uj.lastprayer = time:toDays()
if uj.sodapt then
if uj.sodapt.pray then
uj.lastprayer = uj.lastprayer + uj.sodapt.pray
uj.sodapt.pray = nil
if uj.sodapt == {} then
uj.sodapt = nil
end
end
end
dpf.savejson("savedata/" .. message.author.id .. ".json",uj)
message.channel:send(lang.prayed_message)
if not uj.togglechecktoken then
message.channel:send(lang.checktoken_1 .. uj.tokens .. lang.checktoken_2 .. (uj.tokens ~= 1 and lang.needs_plural_s == true and lang.time_plural_s or "") .. lang.checktoken_3)
end
end
return command