-
Notifications
You must be signed in to change notification settings - Fork 10
/
module_game.lua
47 lines (39 loc) · 947 Bytes
/
module_game.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
-- Copyright (C) 2018 Jérôme Leclercq
-- This file is part of the "Not a Bot" application
-- For conditions of distribution and use, see copyright notice in LICENSE
local bot = Bot
local client = Client
local discordia = Discordia
Module.Name = "game"
Module.Global = true
function Module:GetConfigTable()
return {
{
Array = true,
Global = true,
Name = "GameList",
Description = "List of activities",
Type = bot.ConfigType.String,
Default = {},
Sensitive = true
},
}
end
function Module:OnLoaded()
self.UpdateTimer = Bot:CreateRepeatTimer(3 * 60, -1, function ()
self:UpdateActivity()
end)
self:UpdateActivity()
return true
end
function Module:OnUnload()
self.UpdateTimer:Stop()
end
function Module:UpdateActivity()
local games = self.GlobalConfig.GameList
local newGame = games[math.random(1, #games)]
if (type(newGame) == "function") then
newGame = newGame()
end
client:setActivity(newGame)
end